mirror of https://github.com/encounter/SDL.git
Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations.
This commit is contained in:
parent
7b7828a46e
commit
5df11f8aa1
|
@ -49,10 +49,12 @@ SDL_RenderDriver GLES2_RenderDriver = {
|
||||||
"opengles2",
|
"opengles2",
|
||||||
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
|
||||||
4,
|
4,
|
||||||
{SDL_PIXELFORMAT_ABGR8888,
|
{
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
|
SDL_PIXELFORMAT_ABGR8888,
|
||||||
SDL_PIXELFORMAT_RGB888,
|
SDL_PIXELFORMAT_RGB888,
|
||||||
SDL_PIXELFORMAT_BGR888},
|
SDL_PIXELFORMAT_BGR888
|
||||||
|
},
|
||||||
0,
|
0,
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
@ -477,10 +479,10 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
||||||
/* Determine the corresponding GLES texture format params */
|
/* Determine the corresponding GLES texture format params */
|
||||||
switch (texture->format)
|
switch (texture->format)
|
||||||
{
|
{
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
format = GL_RGBA;
|
format = GL_RGBA;
|
||||||
type = GL_UNSIGNED_BYTE;
|
type = GL_UNSIGNED_BYTE;
|
||||||
break;
|
break;
|
||||||
|
@ -1417,6 +1419,18 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
||||||
if (renderer->target->format != texture->format) {
|
if (renderer->target->format != texture->format) {
|
||||||
switch (texture->format)
|
switch (texture->format)
|
||||||
{
|
{
|
||||||
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
|
switch (renderer->target->format)
|
||||||
|
{
|
||||||
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
|
break;
|
||||||
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
switch (renderer->target->format)
|
switch (renderer->target->format)
|
||||||
{
|
{
|
||||||
|
@ -1429,15 +1443,17 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
switch (renderer->target->format)
|
switch (renderer->target->format)
|
||||||
{
|
{
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
||||||
|
break;
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1455,20 +1471,6 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
|
||||||
switch (renderer->target->format)
|
|
||||||
{
|
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
|
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
|
||||||
|
@ -1476,18 +1478,18 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
|
||||||
else {
|
else {
|
||||||
switch (texture->format)
|
switch (texture->format)
|
||||||
{
|
{
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
||||||
break;
|
break;
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
||||||
|
break;
|
||||||
// TODO: new shader to change yv planes YV12 format
|
// TODO: new shader to change yv planes YV12 format
|
||||||
case SDL_PIXELFORMAT_IYUV:
|
case SDL_PIXELFORMAT_IYUV:
|
||||||
case SDL_PIXELFORMAT_YV12:
|
case SDL_PIXELFORMAT_YV12:
|
||||||
|
@ -1599,6 +1601,18 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||||
if (renderer->target->format != texture->format) {
|
if (renderer->target->format != texture->format) {
|
||||||
switch (texture->format)
|
switch (texture->format)
|
||||||
{
|
{
|
||||||
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
|
switch (renderer->target->format)
|
||||||
|
{
|
||||||
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
|
break;
|
||||||
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
switch (renderer->target->format)
|
switch (renderer->target->format)
|
||||||
{
|
{
|
||||||
|
@ -1611,15 +1625,17 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
switch (renderer->target->format)
|
switch (renderer->target->format)
|
||||||
{
|
{
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
||||||
|
break;
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1637,20 +1653,6 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
|
||||||
switch (renderer->target->format)
|
|
||||||
{
|
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
|
else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
|
||||||
|
@ -1658,18 +1660,18 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
|
||||||
else {
|
else {
|
||||||
switch (texture->format)
|
switch (texture->format)
|
||||||
{
|
{
|
||||||
case SDL_PIXELFORMAT_ABGR8888:
|
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
|
||||||
break;
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_BGR888:
|
case SDL_PIXELFORMAT_ABGR8888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
|
||||||
break;
|
break;
|
||||||
case SDL_PIXELFORMAT_RGB888:
|
case SDL_PIXELFORMAT_RGB888:
|
||||||
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
|
||||||
break;
|
break;
|
||||||
|
case SDL_PIXELFORMAT_BGR888:
|
||||||
|
sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,14 +82,14 @@ SDL_RenderDriver SW_RenderDriver = {
|
||||||
SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
|
SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
|
||||||
8,
|
8,
|
||||||
{
|
{
|
||||||
SDL_PIXELFORMAT_RGB555,
|
SDL_PIXELFORMAT_ARGB8888,
|
||||||
SDL_PIXELFORMAT_RGB565,
|
SDL_PIXELFORMAT_ABGR8888,
|
||||||
|
SDL_PIXELFORMAT_RGBA8888,
|
||||||
|
SDL_PIXELFORMAT_BGRA8888,
|
||||||
SDL_PIXELFORMAT_RGB888,
|
SDL_PIXELFORMAT_RGB888,
|
||||||
SDL_PIXELFORMAT_BGR888,
|
SDL_PIXELFORMAT_BGR888,
|
||||||
SDL_PIXELFORMAT_ARGB8888,
|
SDL_PIXELFORMAT_RGB555,
|
||||||
SDL_PIXELFORMAT_RGBA8888,
|
SDL_PIXELFORMAT_RGB565
|
||||||
SDL_PIXELFORMAT_ABGR8888,
|
|
||||||
SDL_PIXELFORMAT_BGRA8888
|
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
0}
|
0}
|
||||||
|
|
Loading…
Reference in New Issue