Made SDL_PIXELFORMAT_ARGB8888 the default texture format for consistency across renderer implementations.
authorSam Lantinga
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,15 +1443,17 @@
    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 -                    case SDL_PIXELFORMAT_BGR888:
    1.60                          sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.61                          break;
    1.62 -                    case SDL_PIXELFORMAT_RGB888:
    1.63 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
    1.64 +                    case SDL_PIXELFORMAT_ARGB8888:
    1.65 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
    1.66 +                        break;
    1.67 +                    case SDL_PIXELFORMAT_BGR888:
    1.68 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.69                          break;
    1.70                  }
    1.71                  break;
    1.72 @@ -1455,20 +1471,6 @@
    1.73                          break;
    1.74                  }
    1.75                  break;
    1.76 -            case SDL_PIXELFORMAT_RGB888:
    1.77 -                switch (renderer->target->format)
    1.78 -                {
    1.79 -                    case SDL_PIXELFORMAT_ABGR8888:
    1.80 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.81 -                        break;
    1.82 -                    case SDL_PIXELFORMAT_ARGB8888:
    1.83 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
    1.84 -                        break;
    1.85 -                    case SDL_PIXELFORMAT_BGR888:
    1.86 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
    1.87 -                        break;
    1.88 -                }
    1.89 -                break;
    1.90              }
    1.91          }
    1.92          else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
    1.93 @@ -1476,18 +1478,18 @@
    1.94      else {
    1.95          switch (texture->format)
    1.96          {
    1.97 -            case SDL_PIXELFORMAT_ABGR8888:
    1.98 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
    1.99 -                break;
   1.100              case SDL_PIXELFORMAT_ARGB8888:
   1.101                  sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.102                  break;
   1.103 -            case SDL_PIXELFORMAT_BGR888:
   1.104 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.105 +            case SDL_PIXELFORMAT_ABGR8888:
   1.106 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.107                  break;
   1.108              case SDL_PIXELFORMAT_RGB888:
   1.109                  sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.110                  break;
   1.111 +            case SDL_PIXELFORMAT_BGR888:
   1.112 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.113 +                break;
   1.114              // TODO: new shader to change yv planes YV12 format
   1.115              case SDL_PIXELFORMAT_IYUV:
   1.116              case SDL_PIXELFORMAT_YV12:
   1.117 @@ -1599,6 +1601,18 @@
   1.118          if (renderer->target->format != texture->format) {
   1.119              switch (texture->format)
   1.120              {
   1.121 +            case SDL_PIXELFORMAT_ARGB8888:
   1.122 +                switch (renderer->target->format)
   1.123 +                {
   1.124 +                    case SDL_PIXELFORMAT_ABGR8888:
   1.125 +                    case SDL_PIXELFORMAT_BGR888:
   1.126 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.127 +                        break;
   1.128 +                    case SDL_PIXELFORMAT_RGB888:
   1.129 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.130 +                        break;
   1.131 +                }
   1.132 +                break;
   1.133              case SDL_PIXELFORMAT_ABGR8888:
   1.134                  switch (renderer->target->format)
   1.135                  {
   1.136 @@ -1611,15 +1625,17 @@
   1.137                          break;
   1.138                  }
   1.139                  break;
   1.140 -            case SDL_PIXELFORMAT_ARGB8888:
   1.141 +            case SDL_PIXELFORMAT_RGB888:
   1.142                  switch (renderer->target->format)
   1.143                  {
   1.144                      case SDL_PIXELFORMAT_ABGR8888:
   1.145 -                    case SDL_PIXELFORMAT_BGR888:
   1.146                          sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.147                          break;
   1.148 -                    case SDL_PIXELFORMAT_RGB888:
   1.149 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.150 +                    case SDL_PIXELFORMAT_ARGB8888:
   1.151 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.152 +                        break;
   1.153 +                    case SDL_PIXELFORMAT_BGR888:
   1.154 +                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.155                          break;
   1.156                  }
   1.157                  break;
   1.158 @@ -1637,20 +1653,6 @@
   1.159                          break;
   1.160                  }
   1.161                  break;
   1.162 -            case SDL_PIXELFORMAT_RGB888:
   1.163 -                switch (renderer->target->format)
   1.164 -                {
   1.165 -                    case SDL_PIXELFORMAT_ABGR8888:
   1.166 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.167 -                        break;
   1.168 -                    case SDL_PIXELFORMAT_ARGB8888:
   1.169 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.170 -                        break;
   1.171 -                    case SDL_PIXELFORMAT_BGR888:
   1.172 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.173 -                        break;
   1.174 -                }
   1.175 -                break;
   1.176              }
   1.177          }
   1.178          else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
   1.179 @@ -1658,18 +1660,18 @@
   1.180      else {
   1.181          switch (texture->format)
   1.182          {
   1.183 -            case SDL_PIXELFORMAT_ABGR8888:
   1.184 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.185 -                break;
   1.186              case SDL_PIXELFORMAT_ARGB8888:
   1.187                  sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   1.188                  break;
   1.189 -            case SDL_PIXELFORMAT_BGR888:
   1.190 -                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.191 +            case SDL_PIXELFORMAT_ABGR8888:
   1.192 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   1.193                  break;
   1.194              case SDL_PIXELFORMAT_RGB888:
   1.195                  sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   1.196                  break;
   1.197 +            case SDL_PIXELFORMAT_BGR888:
   1.198 +                sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   1.199 +                break;
   1.200              default:
   1.201                  return -1;
   1.202          }
     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}