Code style cleanup in the GLES and GLES2 render backends.
authorAlex Szpakowski <slime73@gmail.com>
Sat, 16 May 2015 17:35:36 -0300
changeset 9604b8d8f9674717
parent 9603 8e570fd79352
child 9605 be71aef6c347
Code style cleanup in the GLES and GLES2 render backends.
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
src/render/opengles2/SDL_shaders_gles2.c
     1.1 --- a/src/render/opengles/SDL_render_gles.c	Sat May 16 16:55:56 2015 -0300
     1.2 +++ b/src/render/opengles/SDL_render_gles.c	Sat May 16 17:35:36 2015 -0300
     1.3 @@ -220,12 +220,10 @@
     1.4  GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
     1.5  {
     1.6     GLES_FBOList *result = data->framebuffers;
     1.7 -   while ((result) && ((result->w != w) || (result->h != h)) )
     1.8 -   {
     1.9 +   while ((result) && ((result->w != w) || (result->h != h)) ) {
    1.10         result = result->next;
    1.11     }
    1.12 -   if (result == NULL)
    1.13 -   {
    1.14 +   if (result == NULL) {
    1.15         result = SDL_malloc(sizeof(GLES_FBOList));
    1.16         result->w = w;
    1.17         result->h = h;
    1.18 @@ -572,8 +570,9 @@
    1.19      GLES_ActivateRenderer(renderer);
    1.20  
    1.21      /* Bail out if we're supposed to update an empty rectangle */
    1.22 -    if (rect->w <= 0 || rect->h <= 0)
    1.23 +    if (rect->w <= 0 || rect->h <= 0) {
    1.24          return 0;
    1.25 +    }
    1.26  
    1.27      /* Reformat the texture data into a tightly packed array */
    1.28      srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
    1.29 @@ -608,8 +607,7 @@
    1.30                      src);
    1.31      SDL_free(blob);
    1.32  
    1.33 -    if (renderdata->glGetError() != GL_NO_ERROR)
    1.34 -    {
    1.35 +    if (renderdata->glGetError() != GL_NO_ERROR) {
    1.36          return SDL_SetError("Failed to update texture");
    1.37      }
    1.38      return 0;
    1.39 @@ -650,7 +648,7 @@
    1.40      GLenum status;
    1.41  
    1.42      GLES_ActivateRenderer(renderer);
    1.43 -    
    1.44 +
    1.45      if (!data->GL_OES_framebuffer_object_supported) {
    1.46          return SDL_SetError("Can't enable render target support in this renderer");
    1.47      }
    1.48 @@ -1206,8 +1204,12 @@
    1.49      data->glEnable(GL_TEXTURE_2D);
    1.50      data->glBindTexture(texturedata->type, texturedata->texture);
    1.51  
    1.52 -    if(texw) *texw = (float)texturedata->texw;
    1.53 -    if(texh) *texh = (float)texturedata->texh;
    1.54 +    if (texw) {
    1.55 +        *texw = (float)texturedata->texw;
    1.56 +    }
    1.57 +    if (texh) {
    1.58 +        *texh = (float)texturedata->texh;
    1.59 +    }
    1.60  
    1.61      return 0;
    1.62  }
     2.1 --- a/src/render/opengles2/SDL_render_gles2.c	Sat May 16 16:55:56 2015 -0300
     2.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Sat May 16 17:35:36 2015 -0300
     2.3 @@ -224,8 +224,7 @@
     2.4  {
     2.5      GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
     2.6  
     2.7 -    if (!data->debug_enabled)
     2.8 -    {
     2.9 +    if (!data->debug_enabled) {
    2.10          return;
    2.11      }
    2.12      while (data->glGetError() != GL_NO_ERROR) {
    2.13 @@ -239,8 +238,7 @@
    2.14      GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
    2.15      int ret = 0;
    2.16  
    2.17 -    if (!data->debug_enabled)
    2.18 -    {
    2.19 +    if (!data->debug_enabled) {
    2.20          return 0;
    2.21      }
    2.22      /* check gl errors (can return multiple errors) */
    2.23 @@ -313,12 +311,10 @@
    2.24  GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h)
    2.25  {
    2.26     GLES2_FBOList *result = data->framebuffers;
    2.27 -   while ((result) && ((result->w != w) || (result->h != h)) )
    2.28 -   {
    2.29 +   while ((result) && ((result->w != w) || (result->h != h)) ) {
    2.30         result = result->next;
    2.31     }
    2.32 -   if (result == NULL)
    2.33 -   {
    2.34 +   if (result == NULL) {
    2.35         result = SDL_malloc(sizeof(GLES2_FBOList));
    2.36         result->w = w;
    2.37         result->h = h;
    2.38 @@ -428,8 +424,7 @@
    2.39              GLES2_ShaderCacheEntry *entry;
    2.40              GLES2_ShaderCacheEntry *next;
    2.41              entry = data->shader_cache.head;
    2.42 -            while (entry)
    2.43 -            {
    2.44 +            while (entry) {
    2.45                  data->glDeleteShader(entry->id);
    2.46                  next = entry->next;
    2.47                  SDL_free(entry);
    2.48 @@ -677,8 +672,9 @@
    2.49      GLES2_ActivateRenderer(renderer);
    2.50  
    2.51      /* Bail out if we're supposed to update an empty rectangle */
    2.52 -    if (rect->w <= 0 || rect->h <= 0)
    2.53 +    if (rect->w <= 0 || rect->h <= 0) {
    2.54          return 0;
    2.55 +    }
    2.56  
    2.57      /* Create a texture subimage with the supplied data */
    2.58      data->glBindTexture(tdata->texture_type, tdata->texture);
    2.59 @@ -755,8 +751,9 @@
    2.60      GLES2_ActivateRenderer(renderer);
    2.61  
    2.62      /* Bail out if we're supposed to update an empty rectangle */
    2.63 -    if (rect->w <= 0 || rect->h <= 0)
    2.64 +    if (rect->w <= 0 || rect->h <= 0) {
    2.65          return 0;
    2.66 +    }
    2.67  
    2.68      data->glBindTexture(tdata->texture_type, tdata->texture_v);
    2.69      GLES2_TexSubImage2D(data, tdata->texture_type,
    2.70 @@ -852,8 +849,7 @@
    2.71      GLES2_ActivateRenderer(renderer);
    2.72  
    2.73      /* Destroy the texture */
    2.74 -    if (tdata)
    2.75 -    {
    2.76 +    if (tdata) {
    2.77          data->glDeleteTextures(1, &tdata->texture);
    2.78          if (tdata->texture_v) {
    2.79              data->glDeleteTextures(1, &tdata->texture_v);
    2.80 @@ -892,20 +888,20 @@
    2.81  
    2.82      /* Check if we've already cached this program */
    2.83      entry = data->program_cache.head;
    2.84 -    while (entry)
    2.85 -    {
    2.86 -        if (entry->vertex_shader == vertex && entry->fragment_shader == fragment)
    2.87 +    while (entry) {
    2.88 +        if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) {
    2.89              break;
    2.90 +        }
    2.91          entry = entry->next;
    2.92      }
    2.93 -    if (entry)
    2.94 -    {
    2.95 -        if (data->program_cache.head != entry)
    2.96 -        {
    2.97 -            if (entry->next)
    2.98 +    if (entry) {
    2.99 +        if (data->program_cache.head != entry) {
   2.100 +            if (entry->next) {
   2.101                  entry->next->prev = entry->prev;
   2.102 -            if (entry->prev)
   2.103 +            }
   2.104 +            if (entry->prev) {
   2.105                  entry->prev->next = entry->next;
   2.106 +            }
   2.107              entry->prev = NULL;
   2.108              entry->next = data->program_cache.head;
   2.109              data->program_cache.head->prev = entry;
   2.110 @@ -916,8 +912,7 @@
   2.111  
   2.112      /* Create a program cache entry */
   2.113      entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
   2.114 -    if (!entry)
   2.115 -    {
   2.116 +    if (!entry) {
   2.117          SDL_OutOfMemory();
   2.118          return NULL;
   2.119      }
   2.120 @@ -935,8 +930,7 @@
   2.121      data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center");
   2.122      data->glLinkProgram(entry->id);
   2.123      data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
   2.124 -    if (!linkSuccessful)
   2.125 -    {
   2.126 +    if (!linkSuccessful) {
   2.127          data->glDeleteProgram(entry->id);
   2.128          SDL_free(entry);
   2.129          SDL_SetError("Failed to link shader program");
   2.130 @@ -969,13 +963,10 @@
   2.131      data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f);
   2.132  
   2.133      /* Cache the linked program */
   2.134 -    if (data->program_cache.head)
   2.135 -    {
   2.136 +    if (data->program_cache.head) {
   2.137          entry->next = data->program_cache.head;
   2.138          data->program_cache.head->prev = entry;
   2.139 -    }
   2.140 -    else
   2.141 -    {
   2.142 +    } else {
   2.143          data->program_cache.tail = entry;
   2.144      }
   2.145      data->program_cache.head = entry;
   2.146 @@ -986,14 +977,15 @@
   2.147      ++fragment->references;
   2.148  
   2.149      /* Evict the last entry from the cache if we exceed the limit */
   2.150 -    if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS)
   2.151 -    {
   2.152 +    if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) {
   2.153          shaderEntry = data->program_cache.tail->vertex_shader;
   2.154 -        if (--shaderEntry->references <= 0)
   2.155 +        if (--shaderEntry->references <= 0) {
   2.156              GLES2_EvictShader(renderer, shaderEntry);
   2.157 +        }
   2.158          shaderEntry = data->program_cache.tail->fragment_shader;
   2.159 -        if (--shaderEntry->references <= 0)
   2.160 +        if (--shaderEntry->references <= 0) {
   2.161              GLES2_EvictShader(renderer, shaderEntry);
   2.162 +        }
   2.163          data->glDeleteProgram(data->program_cache.tail->id);
   2.164          data->program_cache.tail = data->program_cache.tail->prev;
   2.165          SDL_free(data->program_cache.tail->next);
   2.166 @@ -1015,47 +1007,46 @@
   2.167  
   2.168      /* Find the corresponding shader */
   2.169      shader = GLES2_GetShader(type, blendMode);
   2.170 -    if (!shader)
   2.171 -    {
   2.172 +    if (!shader) {
   2.173          SDL_SetError("No shader matching the requested characteristics was found");
   2.174          return NULL;
   2.175      }
   2.176  
   2.177      /* Find a matching shader instance that's supported on this hardware */
   2.178 -    for (i = 0; i < shader->instance_count && !instance; ++i)
   2.179 -    {
   2.180 -        for (j = 0; j < data->shader_format_count && !instance; ++j)
   2.181 -        {
   2.182 -            if (!shader->instances)
   2.183 +    for (i = 0; i < shader->instance_count && !instance; ++i) {
   2.184 +        for (j = 0; j < data->shader_format_count && !instance; ++j) {
   2.185 +            if (!shader->instances) {
   2.186                  continue;
   2.187 -            if (!shader->instances[i])
   2.188 +            }
   2.189 +            if (!shader->instances[i]) {
   2.190                  continue;
   2.191 -            if (shader->instances[i]->format != data->shader_formats[j])
   2.192 +            }
   2.193 +            if (shader->instances[i]->format != data->shader_formats[j]) {
   2.194                  continue;
   2.195 +            }
   2.196              instance = shader->instances[i];
   2.197          }
   2.198      }
   2.199 -    if (!instance)
   2.200 -    {
   2.201 +    if (!instance) {
   2.202          SDL_SetError("The specified shader cannot be loaded on the current platform");
   2.203          return NULL;
   2.204      }
   2.205  
   2.206      /* Check if we've already cached this shader */
   2.207      entry = data->shader_cache.head;
   2.208 -    while (entry)
   2.209 -    {
   2.210 -        if (entry->instance == instance)
   2.211 +    while (entry) {
   2.212 +        if (entry->instance == instance) {
   2.213              break;
   2.214 +        }
   2.215          entry = entry->next;
   2.216      }
   2.217 -    if (entry)
   2.218 +    if (entry) {
   2.219          return entry;
   2.220 +    }
   2.221  
   2.222      /* Create a shader cache entry */
   2.223      entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry));
   2.224 -    if (!entry)
   2.225 -    {
   2.226 +    if (!entry) {
   2.227          SDL_OutOfMemory();
   2.228          return NULL;
   2.229      }
   2.230 @@ -1064,19 +1055,15 @@
   2.231  
   2.232      /* Compile or load the selected shader instance */
   2.233      entry->id = data->glCreateShader(instance->type);
   2.234 -    if (instance->format == (GLenum)-1)
   2.235 -    {
   2.236 +    if (instance->format == (GLenum)-1) {
   2.237          data->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL);
   2.238          data->glCompileShader(entry->id);
   2.239          data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
   2.240 -    }
   2.241 -    else
   2.242 -    {
   2.243 +    } else {
   2.244          data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
   2.245          compileSuccessful = GL_TRUE;
   2.246      }
   2.247 -    if (!compileSuccessful)
   2.248 -    {
   2.249 +    if (!compileSuccessful) {
   2.250          char *info = NULL;
   2.251          int length = 0;
   2.252  
   2.253 @@ -1099,8 +1086,7 @@
   2.254      }
   2.255  
   2.256      /* Link the shader entry in at the front of the cache */
   2.257 -    if (data->shader_cache.head)
   2.258 -    {
   2.259 +    if (data->shader_cache.head) {
   2.260          entry->next = data->shader_cache.head;
   2.261          data->shader_cache.head->prev = entry;
   2.262      }
   2.263 @@ -1115,12 +1101,15 @@
   2.264      GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
   2.265  
   2.266      /* Unlink the shader from the cache */
   2.267 -    if (entry->next)
   2.268 +    if (entry->next) {
   2.269          entry->next->prev = entry->prev;
   2.270 -    if (entry->prev)
   2.271 +    }
   2.272 +    if (entry->prev) {
   2.273          entry->prev->next = entry->next;
   2.274 -    if (data->shader_cache.head == entry)
   2.275 +    }
   2.276 +    if (data->shader_cache.head == entry) {
   2.277          data->shader_cache.head = entry->next;
   2.278 +    }
   2.279      --data->shader_cache.count;
   2.280  
   2.281      /* Deallocate the shader */
   2.282 @@ -1139,8 +1128,7 @@
   2.283  
   2.284      /* Select an appropriate shader pair for the specified modes */
   2.285      vtype = GLES2_SHADER_VERTEX_DEFAULT;
   2.286 -    switch (source)
   2.287 -    {
   2.288 +    switch (source) {
   2.289      case GLES2_IMAGESOURCE_SOLID:
   2.290          ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
   2.291          break;
   2.292 @@ -1171,22 +1159,26 @@
   2.293  
   2.294      /* Load the requested shaders */
   2.295      vertex = GLES2_CacheShader(renderer, vtype, blendMode);
   2.296 -    if (!vertex)
   2.297 +    if (!vertex) {
   2.298          goto fault;
   2.299 +    }
   2.300      fragment = GLES2_CacheShader(renderer, ftype, blendMode);
   2.301 -    if (!fragment)
   2.302 +    if (!fragment) {
   2.303          goto fault;
   2.304 +    }
   2.305  
   2.306      /* Check if we need to change programs at all */
   2.307      if (data->current_program &&
   2.308          data->current_program->vertex_shader == vertex &&
   2.309 -        data->current_program->fragment_shader == fragment)
   2.310 +        data->current_program->fragment_shader == fragment) {
   2.311          return 0;
   2.312 +    }
   2.313  
   2.314      /* Generate a matching program */
   2.315      program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode);
   2.316 -    if (!program)
   2.317 +    if (!program) {
   2.318          goto fault;
   2.319 +    }
   2.320  
   2.321      /* Select that program in OpenGL */
   2.322      data->glUseProgram(program->id);
   2.323 @@ -1195,16 +1187,19 @@
   2.324      data->current_program = program;
   2.325  
   2.326      /* Activate an orthographic projection */
   2.327 -    if (GLES2_SetOrthographicProjection(renderer) < 0)
   2.328 +    if (GLES2_SetOrthographicProjection(renderer) < 0) {
   2.329          goto fault;
   2.330 +    }
   2.331  
   2.332      /* Clean up and return */
   2.333      return 0;
   2.334  fault:
   2.335 -    if (vertex && vertex->references <= 0)
   2.336 +    if (vertex && vertex->references <= 0) {
   2.337          GLES2_EvictShader(renderer, vertex);
   2.338 -    if (fragment && fragment->references <= 0)
   2.339 +    }
   2.340 +    if (fragment && fragment->references <= 0) {
   2.341          GLES2_EvictShader(renderer, fragment);
   2.342 +    }
   2.343      data->current_program = NULL;
   2.344      return -1;
   2.345  }
   2.346 @@ -1419,8 +1414,9 @@
   2.347  #if !SDL_GLES2_USE_VBOS
   2.348      data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, vertexData);
   2.349  #else
   2.350 -    if (!data->vertex_buffers[attr])
   2.351 +    if (!data->vertex_buffers[attr]) {
   2.352          data->glGenBuffers(1, &data->vertex_buffers[attr]);
   2.353 +    }
   2.354  
   2.355      data->glBindBuffer(GL_ARRAY_BUFFER, data->vertex_buffers[attr]);
   2.356  
   2.357 @@ -1548,58 +1544,53 @@
   2.358      if (renderer->target) {
   2.359          /* Check if we need to do color mapping between the source and render target textures */
   2.360          if (renderer->target->format != texture->format) {
   2.361 -            switch (texture->format)
   2.362 -            {
   2.363 +            switch (texture->format) {
   2.364              case SDL_PIXELFORMAT_ARGB8888:
   2.365 -                switch (renderer->target->format)
   2.366 -                {
   2.367 -                    case SDL_PIXELFORMAT_ABGR8888:
   2.368 -                    case SDL_PIXELFORMAT_BGR888:
   2.369 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.370 -                        break;
   2.371 -                    case SDL_PIXELFORMAT_RGB888:
   2.372 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   2.373 -                        break;
   2.374 +                switch (renderer->target->format) {
   2.375 +                case SDL_PIXELFORMAT_ABGR8888:
   2.376 +                case SDL_PIXELFORMAT_BGR888:
   2.377 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.378 +                    break;
   2.379 +                case SDL_PIXELFORMAT_RGB888:
   2.380 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   2.381 +                    break;
   2.382                  }
   2.383                  break;
   2.384              case SDL_PIXELFORMAT_ABGR8888:
   2.385 -                switch (renderer->target->format)
   2.386 -                {
   2.387 -                    case SDL_PIXELFORMAT_ARGB8888:
   2.388 -                    case SDL_PIXELFORMAT_RGB888:
   2.389 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.390 -                        break;
   2.391 -                    case SDL_PIXELFORMAT_BGR888:
   2.392 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   2.393 -                        break;
   2.394 +                switch (renderer->target->format) {
   2.395 +                case SDL_PIXELFORMAT_ARGB8888:
   2.396 +                case SDL_PIXELFORMAT_RGB888:
   2.397 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.398 +                    break;
   2.399 +                case SDL_PIXELFORMAT_BGR888:
   2.400 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
   2.401 +                    break;
   2.402                  }
   2.403                  break;
   2.404              case SDL_PIXELFORMAT_RGB888:
   2.405 -                switch (renderer->target->format)
   2.406 -                {
   2.407 -                    case SDL_PIXELFORMAT_ABGR8888:
   2.408 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.409 -                        break;
   2.410 -                    case SDL_PIXELFORMAT_ARGB8888:
   2.411 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   2.412 -                        break;
   2.413 -                    case SDL_PIXELFORMAT_BGR888:
   2.414 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.415 -                        break;
   2.416 +                switch (renderer->target->format) {
   2.417 +                case SDL_PIXELFORMAT_ABGR8888:
   2.418 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.419 +                    break;
   2.420 +                case SDL_PIXELFORMAT_ARGB8888:
   2.421 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   2.422 +                    break;
   2.423 +                case SDL_PIXELFORMAT_BGR888:
   2.424 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.425 +                    break;
   2.426                  }
   2.427                  break;
   2.428              case SDL_PIXELFORMAT_BGR888:
   2.429 -                switch (renderer->target->format)
   2.430 -                {
   2.431 -                    case SDL_PIXELFORMAT_ABGR8888:
   2.432 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   2.433 -                        break;
   2.434 -                    case SDL_PIXELFORMAT_ARGB8888:
   2.435 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   2.436 -                        break;
   2.437 -                    case SDL_PIXELFORMAT_RGB888:
   2.438 -                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.439 -                        break;
   2.440 +                switch (renderer->target->format) {
   2.441 +                case SDL_PIXELFORMAT_ABGR8888:
   2.442 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
   2.443 +                    break;
   2.444 +                case SDL_PIXELFORMAT_ARGB8888:
   2.445 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
   2.446 +                    break;
   2.447 +                case SDL_PIXELFORMAT_RGB888:
   2.448 +                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.449 +                    break;
   2.450                  }
   2.451                  break;
   2.452              case SDL_PIXELFORMAT_IYUV:
   2.453 @@ -1615,11 +1606,11 @@
   2.454              default:
   2.455                  return SDL_SetError("Unsupported texture format");
   2.456              }
   2.457 +        } else {
   2.458 +            sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
   2.459          }
   2.460 -        else sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;   /* Texture formats match, use the non color mapping shader (even if the formats are not ABGR) */
   2.461      } else {
   2.462 -        switch (texture->format)
   2.463 -        {
   2.464 +        switch (texture->format) {
   2.465              case SDL_PIXELFORMAT_ARGB8888:
   2.466                  sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
   2.467                  break;
   2.468 @@ -1884,8 +1875,12 @@
   2.469  
   2.470      data->glBindTexture(texturedata->texture_type, texturedata->texture);
   2.471  
   2.472 -    if(texw) *texw = 1.0;
   2.473 -    if(texh) *texh = 1.0;
   2.474 +    if (texw) {
   2.475 +        *texw = 1.0;
   2.476 +    }
   2.477 +    if (texh) {
   2.478 +        *texh = 1.0;
   2.479 +    }
   2.480  
   2.481      return 0;
   2.482  }
   2.483 @@ -2041,12 +2036,12 @@
   2.484  #else /* !ZUNE_HD */
   2.485      data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
   2.486      data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
   2.487 -    if (hasCompiler)
   2.488 +    if (hasCompiler) {
   2.489          ++nFormats;
   2.490 +    }
   2.491  #endif /* ZUNE_HD */
   2.492      data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
   2.493 -    if (!data->shader_formats)
   2.494 -    {
   2.495 +    if (!data->shader_formats) {
   2.496          GLES2_DestroyRenderer(renderer);
   2.497          SDL_OutOfMemory();
   2.498          goto error;
   2.499 @@ -2056,8 +2051,9 @@
   2.500      data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
   2.501  #else /* !ZUNE_HD */
   2.502      data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats);
   2.503 -    if (hasCompiler)
   2.504 +    if (hasCompiler) {
   2.505          data->shader_formats[nFormats - 1] = (GLenum)-1;
   2.506 +    }
   2.507  #endif /* ZUNE_HD */
   2.508  
   2.509      data->framebuffers = NULL;
     3.1 --- a/src/render/opengles2/SDL_shaders_gles2.c	Sat May 16 16:55:56 2015 -0300
     3.2 +++ b/src/render/opengles2/SDL_shaders_gles2.c	Sat May 16 17:35:36 2015 -0300
     3.3 @@ -810,13 +810,11 @@
     3.4  
     3.5  const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode)
     3.6  {
     3.7 -    switch (type)
     3.8 -    {
     3.9 +    switch (type) {
    3.10      case GLES2_SHADER_VERTEX_DEFAULT:
    3.11          return &GLES2_VertexShader_Default;
    3.12      case GLES2_SHADER_FRAGMENT_SOLID_SRC:
    3.13 -    switch (blendMode)
    3.14 -    {
    3.15 +    switch (blendMode) {
    3.16      case SDL_BLENDMODE_NONE:
    3.17          return &GLES2_FragmentShader_None_SolidSrc;
    3.18      case SDL_BLENDMODE_BLEND:
    3.19 @@ -829,8 +827,7 @@
    3.20          return NULL;
    3.21      }
    3.22      case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
    3.23 -        switch (blendMode)
    3.24 -    {
    3.25 +        switch (blendMode) {
    3.26          case SDL_BLENDMODE_NONE:
    3.27              return &GLES2_FragmentShader_None_TextureABGRSrc;
    3.28          case SDL_BLENDMODE_BLEND:
    3.29 @@ -843,8 +840,7 @@
    3.30              return NULL;
    3.31      }
    3.32      case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
    3.33 -        switch (blendMode)
    3.34 -    {
    3.35 +        switch (blendMode) {
    3.36          case SDL_BLENDMODE_NONE:
    3.37              return &GLES2_FragmentShader_None_TextureARGBSrc;
    3.38          case SDL_BLENDMODE_BLEND:
    3.39 @@ -858,8 +854,7 @@
    3.40      }
    3.41  
    3.42      case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
    3.43 -        switch (blendMode)
    3.44 -    {
    3.45 +        switch (blendMode) {
    3.46          case SDL_BLENDMODE_NONE:
    3.47              return &GLES2_FragmentShader_None_TextureRGBSrc;
    3.48          case SDL_BLENDMODE_BLEND:
    3.49 @@ -873,8 +868,7 @@
    3.50      }
    3.51  
    3.52      case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
    3.53 -        switch (blendMode)
    3.54 -    {
    3.55 +        switch (blendMode) {
    3.56          case SDL_BLENDMODE_NONE:
    3.57              return &GLES2_FragmentShader_None_TextureBGRSrc;
    3.58          case SDL_BLENDMODE_BLEND: