Commit 5df11f8aa1fca1d0081c9f538b96361f2c8a6201

Sam Lantinga 2014-06-21T21:46:42

Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations.

diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index d108e9a..2d7c7ba 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -49,10 +49,12 @@ SDL_RenderDriver GLES2_RenderDriver = {
         "opengles2",
         (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
         4,
-        {SDL_PIXELFORMAT_ABGR8888,
+        {
         SDL_PIXELFORMAT_ARGB8888,
+        SDL_PIXELFORMAT_ABGR8888,
         SDL_PIXELFORMAT_RGB888,
-        SDL_PIXELFORMAT_BGR888},
+        SDL_PIXELFORMAT_BGR888
+        },
         0,
         0
     }
@@ -477,10 +479,10 @@ GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     /* Determine the corresponding GLES texture format params */
     switch (texture->format)
     {
-    case SDL_PIXELFORMAT_ABGR8888:
     case SDL_PIXELFORMAT_ARGB8888:
-    case SDL_PIXELFORMAT_BGR888:
+    case SDL_PIXELFORMAT_ABGR8888:
     case SDL_PIXELFORMAT_RGB888:
+    case SDL_PIXELFORMAT_BGR888:
         format = GL_RGBA;
         type = GL_UNSIGNED_BYTE;
         break;
@@ -1417,54 +1419,54 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
         if (renderer->target->format != texture->format) {
             switch (texture->format)
             {
-            case SDL_PIXELFORMAT_ABGR8888:
+            case SDL_PIXELFORMAT_ARGB8888:
                 switch (renderer->target->format)
                 {
-                    case SDL_PIXELFORMAT_ARGB8888:
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_ABGR8888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_ARGB8888:
+            case SDL_PIXELFORMAT_ABGR8888:
                 switch (renderer->target->format)
                 {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_ARGB8888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_BGR888:
+            case SDL_PIXELFORMAT_RGB888:
                 switch (renderer->target->format)
                 {
                     case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                     case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
                         break;
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_RGB888:
+            case SDL_PIXELFORMAT_BGR888:
                 switch (renderer->target->format)
                 {
                     case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
                         break;
                     case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
                         break;
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                 }
@@ -1476,18 +1478,18 @@ GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *s
     else {
         switch (texture->format)
         {
-            case SDL_PIXELFORMAT_ABGR8888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                break;
             case SDL_PIXELFORMAT_ARGB8888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                 break;
-            case SDL_PIXELFORMAT_BGR888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+            case SDL_PIXELFORMAT_ABGR8888:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                 break;
             case SDL_PIXELFORMAT_RGB888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
                 break;
+            case SDL_PIXELFORMAT_BGR888:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                break;
             // TODO: new shader to change yv planes YV12 format
             case SDL_PIXELFORMAT_IYUV:
             case SDL_PIXELFORMAT_YV12:
@@ -1599,54 +1601,54 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect 
         if (renderer->target->format != texture->format) {
             switch (texture->format)
             {
-            case SDL_PIXELFORMAT_ABGR8888:
+            case SDL_PIXELFORMAT_ARGB8888:
                 switch (renderer->target->format)
                 {
-                    case SDL_PIXELFORMAT_ARGB8888:
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_ABGR8888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_ARGB8888:
+            case SDL_PIXELFORMAT_ABGR8888:
                 switch (renderer->target->format)
                 {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_ARGB8888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_BGR888:
+            case SDL_PIXELFORMAT_RGB888:
                 switch (renderer->target->format)
                 {
                     case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                     case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
                         break;
-                    case SDL_PIXELFORMAT_RGB888:
+                    case SDL_PIXELFORMAT_BGR888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                 }
                 break;
-            case SDL_PIXELFORMAT_RGB888:
+            case SDL_PIXELFORMAT_BGR888:
                 switch (renderer->target->format)
                 {
                     case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
                         break;
                     case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
                         break;
-                    case SDL_PIXELFORMAT_BGR888:
+                    case SDL_PIXELFORMAT_RGB888:
                         sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                         break;
                 }
@@ -1658,18 +1660,18 @@ GLES2_RenderCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect 
     else {
         switch (texture->format)
         {
-            case SDL_PIXELFORMAT_ABGR8888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                break;
             case SDL_PIXELFORMAT_ARGB8888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                 break;
-            case SDL_PIXELFORMAT_BGR888:
-                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+            case SDL_PIXELFORMAT_ABGR8888:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
                 break;
             case SDL_PIXELFORMAT_RGB888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
                 break;
+            case SDL_PIXELFORMAT_BGR888:
+                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                break;
             default:
                 return -1;
         }
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 29d331f..aa640e4 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -82,14 +82,14 @@ SDL_RenderDriver SW_RenderDriver = {
      SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
      8,
      {
-      SDL_PIXELFORMAT_RGB555,
-      SDL_PIXELFORMAT_RGB565,
-      SDL_PIXELFORMAT_RGB888,
-      SDL_PIXELFORMAT_BGR888,
       SDL_PIXELFORMAT_ARGB8888,
-      SDL_PIXELFORMAT_RGBA8888,
       SDL_PIXELFORMAT_ABGR8888,
-      SDL_PIXELFORMAT_BGRA8888
+      SDL_PIXELFORMAT_RGBA8888,
+      SDL_PIXELFORMAT_BGRA8888,
+      SDL_PIXELFORMAT_RGB888,
+      SDL_PIXELFORMAT_BGR888,
+      SDL_PIXELFORMAT_RGB555,
+      SDL_PIXELFORMAT_RGB565
      },
      0,
      0}