static int DirectFB_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Color * colors, int firstcolor, int ncolors) { DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata; if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { DFBColor entries[256]; int i; if (ncolors > 256) ncolors = 256; for (i = 0; i < ncolors; ++i) { entries[i].r = colors[i].r; entries[i].g = colors[i].g; entries[i].b = colors[i].b; entries[i].a = 0xff; } SDL_DFB_CHECKERR(data-> palette->SetEntries(data->palette, entries, ncolors, firstcolor)); return 0; } else { return SDL_SetError("YUV textures don't have a palette"); } error: return -1; }
void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display) { SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; DWORD i; SDL_DisplayMode mode; for (i = 0;; ++i) { if (!WIN_GetDisplayMode(_this, data->DeviceName, i, &mode)) { break; } if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) { /* We don't support palettized modes now */ SDL_free(mode.driverdata); continue; } if (mode.format != SDL_PIXELFORMAT_UNKNOWN) { if (!SDL_AddDisplayMode(display, &mode)) { SDL_free(mode.driverdata); } } else { SDL_free(mode.driverdata); } } }
static int DirectFB_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, SDL_Color * colors, int firstcolor, int ncolors) { DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata; if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { DFBColor entries[256]; int i; SDL_DFB_CHECKERR(data-> palette->GetEntries(data->palette, entries, ncolors, firstcolor)); for (i = 0; i < ncolors; ++i) { colors[i].r = entries[i].r; colors[i].g = entries[i].g; colors[i].b = entries[i].b; colors[i].a = SDL_ALPHA_OPAQUE; } return 0; } else { return SDL_SetError("YUV textures don't have a palette"); } error: return -1; }
/* * Create a surface on the stack for quick blit operations */ static SDL_INLINE SDL_bool SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void * pixels, int pitch, SDL_Surface * surface, SDL_PixelFormat * format, SDL_BlitMap * blitmap) { if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) { SDL_SetError("Indexed pixel formats not supported"); return SDL_FALSE; } if (SDL_InitFormat(format, pixel_format) < 0) { return SDL_FALSE; } SDL_zerop(surface); surface->flags = SDL_PREALLOC; surface->format = format; surface->pixels = pixels; surface->w = width; surface->h = height; surface->pitch = pitch; /* We don't actually need to set up the clip rect for our purposes */ /* SDL_SetClipRect(surface, NULL); */ /* Allocate an empty mapping */ SDL_zerop(blitmap); blitmap->info.r = 0xFF; blitmap->info.g = 0xFF; blitmap->info.b = 0xFF; blitmap->info.a = 0xFF; surface->map = blitmap; /* The surface is ready to go */ surface->refcount = 1; return SDL_TRUE; }
static SDL_bool DDRAW_IsTextureFormatAvailable(IDirectDraw * ddraw, Uint32 display_format, Uint32 texture_format) { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; if (SDL_ISPIXELFORMAT_FOURCC(texture_format)) { //TODO I don't expect DDRAW to support all 4CC formats, but I don't know which ones return SDL_TRUE; } //These are only basic checks if (SDL_ISPIXELFORMAT_INDEXED(texture_format)) { return SDL_FALSE; } if (!SDL_PixelFormatEnumToMasks (texture_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { return SDL_FALSE; } switch (bpp) { case 4: case 8: case 16: case 24: case 32: break; default: return SDL_FALSE; } return SDL_TRUE; }
/** * This is a semi-private blit function and it performs low-level surface * scaled blitting only. */ int SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { static const Uint32 complex_copy_flags = ( SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_COLORKEY ); /* Save off the original dst width, height */ int dstW = dstrect->w; int dstH = dstrect->h; SDL_Rect full_rect; SDL_Rect final_dst = *dstrect; SDL_Rect final_src = *srcrect; /* Clip the dst surface to the dstrect */ full_rect.x = 0; full_rect.y = 0; full_rect.w = dst->w; full_rect.h = dst->h; if (!SDL_IntersectRect(&final_dst, &full_rect, &final_dst)) { return 0; } /* Did the dst width change? */ if ( dstW != final_dst.w ) { /* scale the src width appropriately */ final_src.w = final_src.w * dst->clip_rect.w / dstW; } /* Did the dst height change? */ if ( dstH != final_dst.h ) { /* scale the src width appropriately */ final_src.h = final_src.h * dst->clip_rect.h / dstH; } /* Clip the src surface to the srcrect */ full_rect.x = 0; full_rect.y = 0; full_rect.w = src->w; full_rect.h = src->h; if (!SDL_IntersectRect(&final_src, &full_rect, &final_src)) { return 0; } if (!(src->map->info.flags & SDL_COPY_NEAREST)) { src->map->info.flags |= SDL_COPY_NEAREST; SDL_InvalidateMap(src->map); } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { return SDL_SoftStretch( src, &final_src, dst, &final_dst ); } else { return SDL_LowerBlit( src, &final_src, dst, &final_dst ); } }
static SDL_bool PixelFormatToDDPIXELFORMAT(Uint32 format, LPDDPIXELFORMAT dst) { SDL_zerop(dst); dst->dwSize = sizeof(*dst); if (SDL_ISPIXELFORMAT_FOURCC(format)) { dst->dwFlags = DDPF_FOURCC; dst->dwFourCC = format; } else if (SDL_ISPIXELFORMAT_INDEXED(format)) { SDL_SetError("Indexed pixelformats are not supported."); return SDL_FALSE; } else { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; if (!SDL_PixelFormatEnumToMasks (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { SDL_SetError("pixelformat not supported"); return SDL_FALSE; } if (!Rmask && !Gmask && !Bmask) { dst->dwFlags = DDPF_ALPHA; dst->dwAlphaBitDepth = bpp; } else { dst->dwFlags = DDPF_RGB; dst->dwRGBBitCount = bpp; dst->dwRBitMask = Rmask; dst->dwGBitMask = Gmask; dst->dwBBitMask = Bmask; if (Amask) { dst->dwFlags |= DDPF_ALPHAPIXELS; dst->dwRGBAlphaBitMask = Amask; } } } return SDL_TRUE; }
/** * This is a semi-private blit function and it performs low-level surface * scaled blitting only. */ int SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { static const Uint32 complex_copy_flags = ( SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_COLORKEY ); if (!(src->map->info.flags & SDL_COPY_NEAREST)) { src->map->info.flags |= SDL_COPY_NEAREST; SDL_InvalidateMap(src->map); } if ( !(src->map->info.flags & complex_copy_flags) && src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { return SDL_SoftStretch( src, srcrect, dst, dstrect ); } else { return SDL_LowerBlit( src, srcrect, dst, dstrect ); } }
/** * This is a semi-private blit function and it performs low-level surface * scaled blitting only. */ int SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect) { /* Save off the original dst width, height */ int dstW = dstrect->w; int dstH = dstrect->h; SDL_Rect final_dst = *dstrect; SDL_Rect final_src = *srcrect; /* Clip the dst surface to the dstrect */ SDL_SetClipRect( dst, &final_dst ); /* Did the dst width change? */ if ( dstW != dst->clip_rect.w ) { /* scale the src width appropriately */ final_src.w = final_src.w * dst->clip_rect.w / dstW; } /* Did the dst height change? */ if ( dstH != dst->clip_rect.h ) { /* scale the src width appropriately */ final_src.h = final_src.h * dst->clip_rect.h / dstH; } /* Clip the src surface to the srcrect */ SDL_SetClipRect( src, &final_src ); src->map->info.flags |= SDL_COPY_NEAREST; if ( src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { return SDL_SoftStretch( src, &final_src, dst, &final_dst ); } else { return SDL_LowerBlit( src, &final_src, dst, &final_dst ); } }
SDL_Texture * SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) { SDL_Texture *texture; CHECK_RENDERER_MAGIC(renderer, NULL); if (!format) { format = renderer->info.texture_formats[0]; } if (SDL_ISPIXELFORMAT_INDEXED(format)) { SDL_SetError("Palettized textures are not supported"); return NULL; } if (w <= 0 || h <= 0) { SDL_SetError("Texture dimensions can't be 0"); return NULL; } texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); if (!texture) { SDL_OutOfMemory(); return NULL; } texture->magic = &texture_magic; texture->format = format; texture->access = access; texture->w = w; texture->h = h; texture->r = 255; texture->g = 255; texture->b = 255; texture->a = 255; texture->renderer = renderer; texture->next = renderer->textures; if (renderer->textures) { renderer->textures->prev = texture; } renderer->textures = texture; if (IsSupportedFormat(renderer, format)) { if (renderer->CreateTexture(renderer, texture) < 0) { SDL_DestroyTexture(texture); return 0; } } else { texture->native = SDL_CreateTexture(renderer, GetClosestSupportedFormat(renderer, format), access, w, h); if (!texture->native) { SDL_DestroyTexture(texture); return NULL; } if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { texture->yuv = SDL_SW_CreateYUVTexture(format, w, h); if (!texture->yuv) { SDL_DestroyTexture(texture); return NULL; } } else if (access == SDL_TEXTUREACCESS_STREAMING) { /* The pitch is 4 byte aligned */ texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3); texture->pixels = SDL_calloc(1, texture->pitch * h); if (!texture->pixels) { SDL_DestroyTexture(texture); return NULL; } } } return texture; }
static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_Window *window = renderer->window; SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DFB_DEVICEDATA(display->device); DirectFB_TextureData *data; DFBSurfaceDescription dsc; DFBSurfacePixelFormat pixelformat; DirectFB_ActivateRenderer(renderer); SDL_DFB_ALLOC_CLEAR(data, sizeof(*data)); texture->driverdata = data; /* find the right pixelformat */ pixelformat = DirectFB_SDLToDFBPixelFormat(texture->format); if (pixelformat == DSPF_UNKNOWN) { SDL_SetError("Unknown pixel format %d\n", data->format); goto error; } data->format = texture->format; data->pitch = texture->w * DFB_BYTES_PER_PIXEL(pixelformat); if (DirectFB_AcquireVidLayer(renderer, texture) != 0) { /* fill surface description */ dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; dsc.width = texture->w; dsc.height = texture->h; if(texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { /* dfb has problems with odd sizes -make them even internally */ dsc.width += (dsc.width % 2); dsc.height += (dsc.height % 2); } /* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance * No DSCAPS_SYSTEMONLY either - let dfb decide * 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8 * Depends on other settings as well. Let dfb decide. */ dsc.caps = DSCAPS_PREMULTIPLIED; #if 0 if (texture->access == SDL_TEXTUREACCESS_STREAMING) dsc.caps |= DSCAPS_SYSTEMONLY; else dsc.caps |= DSCAPS_VIDEOONLY; #endif dsc.pixelformat = pixelformat; data->pixels = NULL; /* Create the surface */ SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, &data->surface)); if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { #if 1 SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &data->palette)); #else /* DFB has issues with blitting LUT8 surfaces. * Creating a new palette does not help. */ DFBPaletteDescription pal_desc; pal_desc.flags = DPDESC_SIZE; /* | DPDESC_ENTRIES */ pal_desc.size = 256; SDL_DFB_CHECKERR(devdata->dfb->CreatePalette(devdata->dfb, &pal_desc,&data->palette)); SDL_DFB_CHECKERR(data->surface->SetPalette(data->surface, data->palette)); #endif } } #if (DFB_VERSION_ATLEAST(1,2,0)) data->render_options = DSRO_NONE; #endif if (texture->access == SDL_TEXTUREACCESS_STREAMING) { /* 3 plane YUVs return 1 bpp, but we need more space for other planes */ if(texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { SDL_DFB_ALLOC_CLEAR(data->pixels, (texture->h * data->pitch + ((texture->h + texture->h % 2) * (data->pitch + data->pitch % 2) * 2) / 4)); } else { SDL_DFB_ALLOC_CLEAR(data->pixels, texture->h * data->pitch); } } return 0; error: SDL_DFB_RELEASE(data->palette); SDL_DFB_RELEASE(data->surface); SDL_DFB_FREE(texture->driverdata); return -1; }
/* * Create an empty RGB surface of the appropriate depth */ SDL_Surface * SDL_CreateRGBSurface(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_Surface *surface; Uint32 format; /* The flags are no longer used, make the compiler happy */ (void)flags; /* Get the pixel format */ format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask); if (format == SDL_PIXELFORMAT_UNKNOWN) { SDL_SetError("Unknown pixel format"); return NULL; } /* Allocate the surface */ surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface)); if (surface == NULL) { SDL_OutOfMemory(); return NULL; } surface->format = SDL_AllocFormat(format); if (!surface->format) { SDL_FreeSurface(surface); return NULL; } surface->w = width; surface->h = height; surface->pitch = SDL_CalculatePitch(surface); SDL_SetClipRect(surface, NULL); if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); if (!palette) { SDL_FreeSurface(surface); return NULL; } if (palette->ncolors == 2) { /* Create a black and white bitmap palette */ palette->colors[0].r = 0xFF; palette->colors[0].g = 0xFF; palette->colors[0].b = 0xFF; palette->colors[1].r = 0x00; palette->colors[1].g = 0x00; palette->colors[1].b = 0x00; } SDL_SetSurfacePalette(surface, palette); SDL_FreePalette(palette); } /* Get the pixels */ if (surface->w && surface->h) { surface->pixels = SDL_malloc(surface->h * surface->pitch); if (!surface->pixels) { SDL_FreeSurface(surface); SDL_OutOfMemory(); return NULL; } /* This is important for bitmaps */ SDL_memset(surface->pixels, 0, surface->h * surface->pitch); } /* Allocate an empty mapping */ surface->map = SDL_AllocBlitMap(); if (!surface->map) { SDL_FreeSurface(surface); return NULL; } /* By default surface with an alpha mask are set up for blending */ if (Amask) { SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); } /* The surface is ready to go */ surface->refcount = 1; return surface; }
static HBITMAP GDI_CreateDIBSection(HDC hdc, int w, int h, int pitch, Uint32 format, HPALETTE * hpal, void ** pixels) { int bmi_size; LPBITMAPINFO bmi; bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); if (!bmi) { SDL_OutOfMemory(); return NULL; } bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); bmi->bmiHeader.biWidth = w; bmi->bmiHeader.biHeight = -h; /* topdown bitmap */ bmi->bmiHeader.biPlanes = 1; bmi->bmiHeader.biSizeImage = h * pitch; bmi->bmiHeader.biXPelsPerMeter = 0; bmi->bmiHeader.biYPelsPerMeter = 0; bmi->bmiHeader.biClrUsed = 0; bmi->bmiHeader.biClrImportant = 0; bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8; if (SDL_ISPIXELFORMAT_INDEXED(format)) { bmi->bmiHeader.biCompression = BI_RGB; if (hpal) { int i, ncolors; LOGPALETTE *palette; ncolors = (1 << SDL_BITSPERPIXEL(format)); palette = (LOGPALETTE *) SDL_malloc(sizeof(*palette) + ncolors * sizeof(PALETTEENTRY)); if (!palette) { SDL_free(bmi); SDL_OutOfMemory(); return NULL; } palette->palVersion = 0x300; palette->palNumEntries = ncolors; for (i = 0; i < ncolors; ++i) { palette->palPalEntry[i].peRed = 0xFF; palette->palPalEntry[i].peGreen = 0xFF; palette->palPalEntry[i].peBlue = 0xFF; palette->palPalEntry[i].peFlags = 0; } *hpal = CreatePalette(palette); SDL_free(palette); } } else { int bpp; Uint32 Rmask, Gmask, Bmask, Amask; bmi->bmiHeader.biCompression = BI_BITFIELDS; SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); ((Uint32 *) bmi->bmiColors)[0] = Rmask; ((Uint32 *) bmi->bmiColors)[1] = Gmask; ((Uint32 *) bmi->bmiColors)[2] = Bmask; if (hpal) { *hpal = NULL; } } return CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, pixels, NULL, 0); }
/* * Create an empty RGB surface of the appropriate depth using the given * enum SDL_PIXELFORMAT_* format */ SDL_Surface * SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth, Uint32 format) { SDL_Surface *surface; /* The flags are no longer used, make the compiler happy */ (void)flags; /* Allocate the surface */ surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface)); if (surface == NULL) { SDL_OutOfMemory(); return NULL; } surface->format = SDL_AllocFormat(format); if (!surface->format) { SDL_FreeSurface(surface); return NULL; } surface->w = width; surface->h = height; surface->pitch = SDL_CalculatePitch(format, width); SDL_SetClipRect(surface, NULL); if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); if (!palette) { SDL_FreeSurface(surface); return NULL; } if (palette->ncolors == 2) { /* Create a black and white bitmap palette */ palette->colors[0].r = 0xFF; palette->colors[0].g = 0xFF; palette->colors[0].b = 0xFF; palette->colors[1].r = 0x00; palette->colors[1].g = 0x00; palette->colors[1].b = 0x00; } SDL_SetSurfacePalette(surface, palette); SDL_FreePalette(palette); } /* Get the pixels */ if (surface->w && surface->h) { /* Assumptions checked in surface_size_assumptions assert above */ Sint64 size = ((Sint64)surface->h * surface->pitch); if (size < 0 || size > SDL_MAX_SINT32) { /* Overflow... */ SDL_FreeSurface(surface); SDL_OutOfMemory(); return NULL; } surface->pixels = SDL_malloc((size_t)size); if (!surface->pixels) { SDL_FreeSurface(surface); SDL_OutOfMemory(); return NULL; } /* This is important for bitmaps */ SDL_memset(surface->pixels, 0, surface->h * surface->pitch); } /* Allocate an empty mapping */ surface->map = SDL_AllocBlitMap(); if (!surface->map) { SDL_FreeSurface(surface); return NULL; } /* By default surface with an alpha mask are set up for blending */ if (surface->format->Amask) { SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); } /* The surface is ready to go */ surface->refcount = 1; return surface; }
static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_Window *window = SDL_GetWindowFromID(renderer->window); SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); SDL_DFB_DEVICEDATA(display->device); DirectFB_TextureData *data; DFBResult ret; DFBSurfaceDescription dsc; SDL_DFB_CALLOC(data, 1, sizeof(*data)); texture->driverdata = data; data->format = texture->format; data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format)); if (DirectFB_AcquireVidLayer(renderer, texture) != 0) { /* fill surface description */ dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; dsc.width = texture->w; dsc.height = texture->h; /* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance * No DSCAPS_SYSTEMONLY either - let dfb decide * 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8 * Depends on other settings as well. Let dfb decide. */ dsc.caps = DSCAPS_PREMULTIPLIED; #if 0 if (texture->access == SDL_TEXTUREACCESS_STREAMING) dsc.caps |= DSCAPS_SYSTEMONLY; else dsc.caps |= DSCAPS_VIDEOONLY; #endif /* find the right pixelformat */ dsc.pixelformat = SDLToDFBPixelFormat(data->format); if (dsc.pixelformat == DSPF_UNKNOWN) { SDL_SetError("Unknown pixel format %d\n", data->format); goto error; } data->pixels = NULL; /* Create the surface */ SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, &data->surface)); if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &data->palette)); } } #if (DFB_VERSION_ATLEAST(1,2,0)) data->render_options = DSRO_NONE; #endif if (texture->access == SDL_TEXTUREACCESS_STREAMING) { data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); SDL_DFB_CALLOC(data->pixels, 1, texture->h * data->pitch); } return 0; error: SDL_DFB_RELEASE(data->palette); SDL_DFB_RELEASE(data->surface); SDL_DFB_FREE(texture->driverdata); return -1; }