Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations.
authorSam Lantinga <slouken@libsdl.org>
Sat, 21 Jun 2014 21:46:42 -0700
changeset 8904c38e754cafd3
parent 8903 8e09eceea61e
child 8905 1519c462cee6
Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations.
src/render/opengles2/SDL_render_gles2.c
src/render/software/SDL_render_sw.c
     1.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sat Jun 21 21:30:49 2014 -0700
     1.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sat Jun 21 21:46:42 2014 -0700
     1.3 @@ -49,10 +49,12 @@
     1.4          "opengles2",
     1.5          (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
     1.6          4,
     1.7 -        {SDL_PIXELFORMAT_ABGR8888,
     1.8 +        {
     1.9          SDL_PIXELFORMAT_ARGB8888,
    1.10 +        SDL_PIXELFORMAT_ABGR8888,
    1.11          SDL_PIXELFORMAT_RGB888,
    1.12 -        SDL_PIXELFORMAT_BGR888},
    1.13 +        SDL_PIXELFORMAT_BGR888
    1.14 +        },
    1.15          0,
    1.16          0
    1.17      }
    1.18 @@ -477,10 +479,10 @@
    1.19      /* Determine the corresponding GLES texture format params */
    1.20      switch (texture->format)
    1.21      {
    1.22 +    case SDL_PIXELFORMAT_ARGB8888:
    1.23      case SDL_PIXELFORMAT_ABGR8888:
    1.24 -    case SDL_PIXELFORMAT_ARGB8888:
    1.25 +    case SDL_PIXELFORMAT_RGB888:
    1.26      case SDL_PIXELFORMAT_BGR888:
    1.27 -    case SDL_PIXELFORMAT_RGB888:
    1.28          format = GL_RGBA;
    1.29          type = GL_UNSIGNED_BYTE;
    1.30          break;
    1.31 @@ -1417,6 +1419,18 @@
    1.32          if (renderer->target->format != texture->format) {
    1.33              switch (texture->format)
    1.34              {
    1.35 +            case SDL_PIXELFORMAT_ARGB8888:
    1.36 +                switch (renderer->target->format)
    1.37 +                {
    1.38 +                    case SDL_PIXELFORMAT_ABGR8888:
    1.39 +                    case SDL_PIXELFORMAT_BGR888:
    1.40 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.41 +                        break;
    1.42 +                    case SDL_PIXELFORMAT_RGB888:
    1.43 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
    1.44 +                        break;
    1.45 +                }
    1.46 +                break;
    1.47              case SDL_PIXELFORMAT_ABGR8888:
    1.48                  switch (renderer->target->format)
    1.49                  {
    1.50 @@ -1429,16 +1443,18 @@
    1.51                          break;
    1.52                  }
    1.53                  break;
    1.54 -            case SDL_PIXELFORMAT_ARGB8888:
    1.55 +            case SDL_PIXELFORMAT_RGB888:
    1.56                  switch (renderer->target->format)
    1.57                  {
    1.58                      case SDL_PIXELFORMAT_ABGR8888:
    1.59 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.60 +                        break;
    1.61 +                    case SDL_PIXELFORMAT_ARGB8888:
    1.62 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
    1.63 +                        break;
    1.64                      case SDL_PIXELFORMAT_BGR888:
    1.65                          sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.66                          break;
    1.67 -                    case SDL_PIXELFORMAT_RGB888:
    1.68 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
    1.69 -                        break;
    1.70                  }
    1.71                  break;
    1.72              case SDL_PIXELFORMAT_BGR888:
    1.73 @@ -1455,20 +1471,6 @@
    1.74                          break;
    1.75                  }
    1.76                  break;
    1.77 -            case SDL_PIXELFORMAT_RGB888:
    1.78 -                switch (renderer->target->format)
    1.79 -                {
    1.80 -                    case SDL_PIXELFORMAT_ABGR8888:
    1.81 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.82 -                        break;
    1.83 -                    case SDL_PIXELFORMAT_ARGB8888:
    1.84 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
    1.85 -                        break;
    1.86 -                    case SDL_PIXELFORMAT_BGR888:
    1.87 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.88 -                        break;
    1.89 -                }
    1.90 -                break;
    1.91              }
    1.92          }
    1.93          else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
    1.94 @@ -1476,18 +1478,18 @@
    1.95      else {
    1.96          switch (texture->format)
    1.97          {
    1.98 +            case SDL_PIXELFORMAT_ARGB8888:
    1.99 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.100 +                break;
   1.101              case SDL_PIXELFORMAT_ABGR8888:
   1.102                  sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.103                  break;
   1.104 -            case SDL_PIXELFORMAT_ARGB8888:
   1.105 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.106 +            case SDL_PIXELFORMAT_RGB888:
   1.107 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.108                  break;
   1.109              case SDL_PIXELFORMAT_BGR888:
   1.110                  sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.111                  break;
   1.112 -            case SDL_PIXELFORMAT_RGB888:
   1.113 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.114 -                break;
   1.115              // TODO: new shader to change yv planes YV12 format
   1.116              case SDL_PIXELFORMAT_IYUV:
   1.117              case SDL_PIXELFORMAT_YV12:
   1.118 @@ -1599,6 +1601,18 @@
   1.119          if (renderer->target->format != texture->format) {
   1.120              switch (texture->format)
   1.121              {
   1.122 +            case SDL_PIXELFORMAT_ARGB8888:
   1.123 +                switch (renderer->target->format)
   1.124 +                {
   1.125 +                    case SDL_PIXELFORMAT_ABGR8888:
   1.126 +                    case SDL_PIXELFORMAT_BGR888:
   1.127 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.128 +                        break;
   1.129 +                    case SDL_PIXELFORMAT_RGB888:
   1.130 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.131 +                        break;
   1.132 +                }
   1.133 +                break;
   1.134              case SDL_PIXELFORMAT_ABGR8888:
   1.135                  switch (renderer->target->format)
   1.136                  {
   1.137 @@ -1611,16 +1625,18 @@
   1.138                          break;
   1.139                  }
   1.140                  break;
   1.141 -            case SDL_PIXELFORMAT_ARGB8888:
   1.142 +            case SDL_PIXELFORMAT_RGB888:
   1.143                  switch (renderer->target->format)
   1.144                  {
   1.145                      case SDL_PIXELFORMAT_ABGR8888:
   1.146 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.147 +                        break;
   1.148 +                    case SDL_PIXELFORMAT_ARGB8888:
   1.149 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.150 +                        break;
   1.151                      case SDL_PIXELFORMAT_BGR888:
   1.152                          sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.153                          break;
   1.154 -                    case SDL_PIXELFORMAT_RGB888:
   1.155 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.156 -                        break;
   1.157                  }
   1.158                  break;
   1.159              case SDL_PIXELFORMAT_BGR888:
   1.160 @@ -1637,20 +1653,6 @@
   1.161                          break;
   1.162                  }
   1.163                  break;
   1.164 -            case SDL_PIXELFORMAT_RGB888:
   1.165 -                switch (renderer->target->format)
   1.166 -                {
   1.167 -                    case SDL_PIXELFORMAT_ABGR8888:
   1.168 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.169 -                        break;
   1.170 -                    case SDL_PIXELFORMAT_ARGB8888:
   1.171 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.172 -                        break;
   1.173 -                    case SDL_PIXELFORMAT_BGR888:
   1.174 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.175 -                        break;
   1.176 -                }
   1.177 -                break;
   1.178              }
   1.179          }
   1.180          else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
   1.181 @@ -1658,18 +1660,18 @@
   1.182      else {
   1.183          switch (texture->format)
   1.184          {
   1.185 +            case SDL_PIXELFORMAT_ARGB8888:
   1.186 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.187 +                break;
   1.188              case SDL_PIXELFORMAT_ABGR8888:
   1.189                  sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.190                  break;
   1.191 -            case SDL_PIXELFORMAT_ARGB8888:
   1.192 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.193 +            case SDL_PIXELFORMAT_RGB888:
   1.194 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.195                  break;
   1.196              case SDL_PIXELFORMAT_BGR888:
   1.197                  sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.198                  break;
   1.199 -            case SDL_PIXELFORMAT_RGB888:
   1.200 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.201 -                break;
   1.202              default:
   1.203                  return -1;
   1.204          }
     2.1 --- a/src/render/software/SDL_render_sw.c	Sat Jun 21 21:30:49 2014 -0700
     2.2 +++ b/src/render/software/SDL_render_sw.c	Sat Jun 21 21:46:42 2014 -0700
     2.3 @@ -82,14 +82,14 @@
     2.4       SDL_RENDERER_SOFTWARE | SDL_RENDERER_TARGETTEXTURE,
     2.5       8,
     2.6       {
     2.7 -      SDL_PIXELFORMAT_RGB555,
     2.8 -      SDL_PIXELFORMAT_RGB565,
     2.9 +      SDL_PIXELFORMAT_ARGB8888,
    2.10 +      SDL_PIXELFORMAT_ABGR8888,
    2.11 +      SDL_PIXELFORMAT_RGBA8888,
    2.12 +      SDL_PIXELFORMAT_BGRA8888,
    2.13        SDL_PIXELFORMAT_RGB888,
    2.14        SDL_PIXELFORMAT_BGR888,
    2.15 -      SDL_PIXELFORMAT_ARGB8888,
    2.16 -      SDL_PIXELFORMAT_RGBA8888,
    2.17 -      SDL_PIXELFORMAT_ABGR8888,
    2.18 -      SDL_PIXELFORMAT_BGRA8888
    2.19 +      SDL_PIXELFORMAT_RGB555,
    2.20 +      SDL_PIXELFORMAT_RGB565
    2.21       },
    2.22       0,
    2.23       0}