mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 16:55:35 +00:00
DirectFB: fixed creation of palette textures
This commit is contained in:
parent
83d600904b
commit
77acd44f28
|
@ -1146,9 +1146,11 @@ SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
|
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
|
||||||
|
if (!IsSupportedFormat(renderer, format)) {
|
||||||
SDL_SetError("Palettized textures are not supported");
|
SDL_SetError("Palettized textures are not supported");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (w <= 0 || h <= 0) {
|
if (w <= 0 || h <= 0) {
|
||||||
SDL_SetError("Texture dimensions can't be 0");
|
SDL_SetError("Texture dimensions can't be 0");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1341,6 +1343,18 @@ SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface)
|
||||||
} else {
|
} else {
|
||||||
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
|
SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SDL_VIDEO_RENDER_DIRECTFB
|
||||||
|
/* DirectFB allows palette format for textures.
|
||||||
|
* Copy SDL_Surface palette to the texture */
|
||||||
|
if (SDL_ISPIXELFORMAT_INDEXED(format)) {
|
||||||
|
if (SDL_strcasecmp(renderer->info.name, "directfb") == 0) {
|
||||||
|
extern void DirectFB_SetTexturePalette(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Palette *pal);
|
||||||
|
DirectFB_SetTexturePalette(renderer, texture, surface->format->palette);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SDL_PixelFormat *dst_fmt;
|
SDL_PixelFormat *dst_fmt;
|
||||||
SDL_Surface *temp = NULL;
|
SDL_Surface *temp = NULL;
|
||||||
|
|
|
@ -324,6 +324,22 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Copy the SDL_Surface palette to the DirectFB texture palette */
|
||||||
|
void DirectFB_SetTexturePalette(SDL_Renderer *renderer, SDL_Texture *texture, SDL_Palette *pal)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
DFBColor dfbpal[256];
|
||||||
|
DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata;
|
||||||
|
for (i = 0; i < pal->ncolors; i++) {
|
||||||
|
dfbpal[i].a = pal->colors[i].a;
|
||||||
|
dfbpal[i].r = pal->colors[i].r;
|
||||||
|
dfbpal[i].g = pal->colors[i].g;
|
||||||
|
dfbpal[i].b = pal->colors[i].b;
|
||||||
|
}
|
||||||
|
data->palette->SetEntries(data->palette, dfbpal, pal->ncolors, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue