Commit fcee3e734d61ab5b19e57a79bc6fd7a4f7cbca84

Alex Szpakowski 2015-05-16T17:35:36

Code style cleanup in the GLES and GLES2 render backends.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 617bf65..53f6242 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -220,12 +220,10 @@ GLES_FBOList *
 GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h)
 {
    GLES_FBOList *result = data->framebuffers;
-   while ((result) && ((result->w != w) || (result->h != h)) )
-   {
+   while ((result) && ((result->w != w) || (result->h != h)) ) {
        result = result->next;
    }
-   if (result == NULL)
-   {
+   if (result == NULL) {
        result = SDL_malloc(sizeof(GLES_FBOList));
        result->w = w;
        result->h = h;
@@ -572,8 +570,9 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     GLES_ActivateRenderer(renderer);
 
     /* Bail out if we're supposed to update an empty rectangle */
-    if (rect->w <= 0 || rect->h <= 0)
+    if (rect->w <= 0 || rect->h <= 0) {
         return 0;
+    }
 
     /* Reformat the texture data into a tightly packed array */
     srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format);
@@ -608,8 +607,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                     src);
     SDL_free(blob);
 
-    if (renderdata->glGetError() != GL_NO_ERROR)
-    {
+    if (renderdata->glGetError() != GL_NO_ERROR) {
         return SDL_SetError("Failed to update texture");
     }
     return 0;
@@ -650,7 +648,7 @@ GLES_SetRenderTarget(SDL_Renderer * renderer, SDL_Texture * texture)
     GLenum status;
 
     GLES_ActivateRenderer(renderer);
-    
+
     if (!data->GL_OES_framebuffer_object_supported) {
         return SDL_SetError("Can't enable render target support in this renderer");
     }
@@ -1206,8 +1204,12 @@ static int GLES_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, floa
     data->glEnable(GL_TEXTURE_2D);
     data->glBindTexture(texturedata->type, texturedata->texture);
 
-    if(texw) *texw = (float)texturedata->texw;
-    if(texh) *texh = (float)texturedata->texh;
+    if (texw) {
+        *texw = (float)texturedata->texw;
+    }
+    if (texh) {
+        *texh = (float)texturedata->texh;
+    }
 
     return 0;
 }
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 05ef00a..3637c2f 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -224,8 +224,7 @@ GL_ClearErrors(SDL_Renderer *renderer)
 {
     GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
 
-    if (!data->debug_enabled)
-    {
+    if (!data->debug_enabled) {
         return;
     }
     while (data->glGetError() != GL_NO_ERROR) {
@@ -239,8 +238,7 @@ GL_CheckAllErrors (const char *prefix, SDL_Renderer *renderer, const char *file,
     GLES2_DriverContext *data = (GLES2_DriverContext *) renderer->driverdata;
     int ret = 0;
 
-    if (!data->debug_enabled)
-    {
+    if (!data->debug_enabled) {
         return 0;
     }
     /* check gl errors (can return multiple errors) */
@@ -313,12 +311,10 @@ GLES2_FBOList *
 GLES2_GetFBO(GLES2_DriverContext *data, Uint32 w, Uint32 h)
 {
    GLES2_FBOList *result = data->framebuffers;
-   while ((result) && ((result->w != w) || (result->h != h)) )
-   {
+   while ((result) && ((result->w != w) || (result->h != h)) ) {
        result = result->next;
    }
-   if (result == NULL)
-   {
+   if (result == NULL) {
        result = SDL_malloc(sizeof(GLES2_FBOList));
        result->w = w;
        result->h = h;
@@ -428,8 +424,7 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer)
             GLES2_ShaderCacheEntry *entry;
             GLES2_ShaderCacheEntry *next;
             entry = data->shader_cache.head;
-            while (entry)
-            {
+            while (entry) {
                 data->glDeleteShader(entry->id);
                 next = entry->next;
                 SDL_free(entry);
@@ -677,8 +672,9 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
     GLES2_ActivateRenderer(renderer);
 
     /* Bail out if we're supposed to update an empty rectangle */
-    if (rect->w <= 0 || rect->h <= 0)
+    if (rect->w <= 0 || rect->h <= 0) {
         return 0;
+    }
 
     /* Create a texture subimage with the supplied data */
     data->glBindTexture(tdata->texture_type, tdata->texture);
@@ -755,8 +751,9 @@ GLES2_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
     GLES2_ActivateRenderer(renderer);
 
     /* Bail out if we're supposed to update an empty rectangle */
-    if (rect->w <= 0 || rect->h <= 0)
+    if (rect->w <= 0 || rect->h <= 0) {
         return 0;
+    }
 
     data->glBindTexture(tdata->texture_type, tdata->texture_v);
     GLES2_TexSubImage2D(data, tdata->texture_type,
@@ -852,8 +849,7 @@ GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
     GLES2_ActivateRenderer(renderer);
 
     /* Destroy the texture */
-    if (tdata)
-    {
+    if (tdata) {
         data->glDeleteTextures(1, &tdata->texture);
         if (tdata->texture_v) {
             data->glDeleteTextures(1, &tdata->texture_v);
@@ -892,20 +888,20 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
 
     /* Check if we've already cached this program */
     entry = data->program_cache.head;
-    while (entry)
-    {
-        if (entry->vertex_shader == vertex && entry->fragment_shader == fragment)
+    while (entry) {
+        if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) {
             break;
+        }
         entry = entry->next;
     }
-    if (entry)
-    {
-        if (data->program_cache.head != entry)
-        {
-            if (entry->next)
+    if (entry) {
+        if (data->program_cache.head != entry) {
+            if (entry->next) {
                 entry->next->prev = entry->prev;
-            if (entry->prev)
+            }
+            if (entry->prev) {
                 entry->prev->next = entry->next;
+            }
             entry->prev = NULL;
             entry->next = data->program_cache.head;
             data->program_cache.head->prev = entry;
@@ -916,8 +912,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
 
     /* Create a program cache entry */
     entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry));
-    if (!entry)
-    {
+    if (!entry) {
         SDL_OutOfMemory();
         return NULL;
     }
@@ -935,8 +930,7 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
     data->glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_CENTER, "a_center");
     data->glLinkProgram(entry->id);
     data->glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful);
-    if (!linkSuccessful)
-    {
+    if (!linkSuccessful) {
         data->glDeleteProgram(entry->id);
         SDL_free(entry);
         SDL_SetError("Failed to link shader program");
@@ -969,13 +963,10 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
     data->glUniform4f(entry->uniform_locations[GLES2_UNIFORM_COLOR], 1.0f, 1.0f, 1.0f, 1.0f);
 
     /* Cache the linked program */
-    if (data->program_cache.head)
-    {
+    if (data->program_cache.head) {
         entry->next = data->program_cache.head;
         data->program_cache.head->prev = entry;
-    }
-    else
-    {
+    } else {
         data->program_cache.tail = entry;
     }
     data->program_cache.head = entry;
@@ -986,14 +977,15 @@ GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
     ++fragment->references;
 
     /* Evict the last entry from the cache if we exceed the limit */
-    if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS)
-    {
+    if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) {
         shaderEntry = data->program_cache.tail->vertex_shader;
-        if (--shaderEntry->references <= 0)
+        if (--shaderEntry->references <= 0) {
             GLES2_EvictShader(renderer, shaderEntry);
+        }
         shaderEntry = data->program_cache.tail->fragment_shader;
-        if (--shaderEntry->references <= 0)
+        if (--shaderEntry->references <= 0) {
             GLES2_EvictShader(renderer, shaderEntry);
+        }
         data->glDeleteProgram(data->program_cache.tail->id);
         data->program_cache.tail = data->program_cache.tail->prev;
         SDL_free(data->program_cache.tail->next);
@@ -1015,47 +1007,46 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b
 
     /* Find the corresponding shader */
     shader = GLES2_GetShader(type, blendMode);
-    if (!shader)
-    {
+    if (!shader) {
         SDL_SetError("No shader matching the requested characteristics was found");
         return NULL;
     }
 
     /* Find a matching shader instance that's supported on this hardware */
-    for (i = 0; i < shader->instance_count && !instance; ++i)
-    {
-        for (j = 0; j < data->shader_format_count && !instance; ++j)
-        {
-            if (!shader->instances)
+    for (i = 0; i < shader->instance_count && !instance; ++i) {
+        for (j = 0; j < data->shader_format_count && !instance; ++j) {
+            if (!shader->instances) {
                 continue;
-            if (!shader->instances[i])
+            }
+            if (!shader->instances[i]) {
                 continue;
-            if (shader->instances[i]->format != data->shader_formats[j])
+            }
+            if (shader->instances[i]->format != data->shader_formats[j]) {
                 continue;
+            }
             instance = shader->instances[i];
         }
     }
-    if (!instance)
-    {
+    if (!instance) {
         SDL_SetError("The specified shader cannot be loaded on the current platform");
         return NULL;
     }
 
     /* Check if we've already cached this shader */
     entry = data->shader_cache.head;
-    while (entry)
-    {
-        if (entry->instance == instance)
+    while (entry) {
+        if (entry->instance == instance) {
             break;
+        }
         entry = entry->next;
     }
-    if (entry)
+    if (entry) {
         return entry;
+    }
 
     /* Create a shader cache entry */
     entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry));
-    if (!entry)
-    {
+    if (!entry) {
         SDL_OutOfMemory();
         return NULL;
     }
@@ -1064,19 +1055,15 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b
 
     /* Compile or load the selected shader instance */
     entry->id = data->glCreateShader(instance->type);
-    if (instance->format == (GLenum)-1)
-    {
+    if (instance->format == (GLenum)-1) {
         data->glShaderSource(entry->id, 1, (const char **)&instance->data, NULL);
         data->glCompileShader(entry->id);
         data->glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful);
-    }
-    else
-    {
+    } else {
         data->glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length);
         compileSuccessful = GL_TRUE;
     }
-    if (!compileSuccessful)
-    {
+    if (!compileSuccessful) {
         char *info = NULL;
         int length = 0;
 
@@ -1099,8 +1086,7 @@ GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode b
     }
 
     /* Link the shader entry in at the front of the cache */
-    if (data->shader_cache.head)
-    {
+    if (data->shader_cache.head) {
         entry->next = data->shader_cache.head;
         data->shader_cache.head->prev = entry;
     }
@@ -1115,12 +1101,15 @@ GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry)
     GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
 
     /* Unlink the shader from the cache */
-    if (entry->next)
+    if (entry->next) {
         entry->next->prev = entry->prev;
-    if (entry->prev)
+    }
+    if (entry->prev) {
         entry->prev->next = entry->next;
-    if (data->shader_cache.head == entry)
+    }
+    if (data->shader_cache.head == entry) {
         data->shader_cache.head = entry->next;
+    }
     --data->shader_cache.count;
 
     /* Deallocate the shader */
@@ -1139,8 +1128,7 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM
 
     /* Select an appropriate shader pair for the specified modes */
     vtype = GLES2_SHADER_VERTEX_DEFAULT;
-    switch (source)
-    {
+    switch (source) {
     case GLES2_IMAGESOURCE_SOLID:
         ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC;
         break;
@@ -1171,22 +1159,26 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM
 
     /* Load the requested shaders */
     vertex = GLES2_CacheShader(renderer, vtype, blendMode);
-    if (!vertex)
+    if (!vertex) {
         goto fault;
+    }
     fragment = GLES2_CacheShader(renderer, ftype, blendMode);
-    if (!fragment)
+    if (!fragment) {
         goto fault;
+    }
 
     /* Check if we need to change programs at all */
     if (data->current_program &&
         data->current_program->vertex_shader == vertex &&
-        data->current_program->fragment_shader == fragment)
+        data->current_program->fragment_shader == fragment) {
         return 0;
+    }
 
     /* Generate a matching program */
     program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode);
-    if (!program)
+    if (!program) {
         goto fault;
+    }
 
     /* Select that program in OpenGL */
     data->glUseProgram(program->id);
@@ -1195,16 +1187,19 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendM
     data->current_program = program;
 
     /* Activate an orthographic projection */
-    if (GLES2_SetOrthographicProjection(renderer) < 0)
+    if (GLES2_SetOrthographicProjection(renderer) < 0) {
         goto fault;
+    }
 
     /* Clean up and return */
     return 0;
 fault:
-    if (vertex && vertex->references <= 0)
+    if (vertex && vertex->references <= 0) {
         GLES2_EvictShader(renderer, vertex);
-    if (fragment && fragment->references <= 0)
+    }
+    if (fragment && fragment->references <= 0) {
         GLES2_EvictShader(renderer, fragment);
+    }
     data->current_program = NULL;
     return -1;
 }
@@ -1419,8 +1414,9 @@ GLES2_UpdateVertexBuffer(SDL_Renderer *renderer, GLES2_Attribute attr,
 #if !SDL_GLES2_USE_VBOS
     data->glVertexAttribPointer(attr, attr == GLES2_ATTRIBUTE_ANGLE ? 1 : 2, GL_FLOAT, GL_FALSE, 0, vertexData);
 #else
-    if (!data->vertex_buffers[attr])
+    if (!data->vertex_buffers[attr]) {
         data->glGenBuffers(1, &data->vertex_buffers[attr]);
+    }
 
     data->glBindBuffer(GL_ARRAY_BUFFER, data->vertex_buffers[attr]);
 
@@ -1548,58 +1544,53 @@ GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture)
     if (renderer->target) {
         /* Check if we need to do color mapping between the source and render target textures */
         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;
+                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:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ARGB8888:
-                    case SDL_PIXELFORMAT_RGB888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
-                    case SDL_PIXELFORMAT_BGR888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
-                        break;
+                switch (renderer->target->format) {
+                case SDL_PIXELFORMAT_ARGB8888:
+                case SDL_PIXELFORMAT_RGB888:
+                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
+                    break;
+                case SDL_PIXELFORMAT_BGR888:
+                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR;
+                    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;
+                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;
             case SDL_PIXELFORMAT_BGR888:
-                switch (renderer->target->format)
-                {
-                    case SDL_PIXELFORMAT_ABGR8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
-                        break;
-                    case SDL_PIXELFORMAT_ARGB8888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
-                        break;
-                    case SDL_PIXELFORMAT_RGB888:
-                        sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
-                        break;
+                switch (renderer->target->format) {
+                case SDL_PIXELFORMAT_ABGR8888:
+                    sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR;
+                    break;
+                case SDL_PIXELFORMAT_ARGB8888:
+                    sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB;
+                    break;
+                case SDL_PIXELFORMAT_RGB888:
+                    sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
+                    break;
                 }
                 break;
             case SDL_PIXELFORMAT_IYUV:
@@ -1615,11 +1606,11 @@ GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture)
             default:
                 return SDL_SetError("Unsupported texture format");
             }
+        } 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) */
     } else {
-        switch (texture->format)
-        {
+        switch (texture->format) {
             case SDL_PIXELFORMAT_ARGB8888:
                 sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB;
                 break;
@@ -1884,8 +1875,12 @@ static int GLES2_BindTexture (SDL_Renderer * renderer, SDL_Texture *texture, flo
 
     data->glBindTexture(texturedata->texture_type, texturedata->texture);
 
-    if(texw) *texw = 1.0;
-    if(texh) *texh = 1.0;
+    if (texw) {
+        *texw = 1.0;
+    }
+    if (texh) {
+        *texh = 1.0;
+    }
 
     return 0;
 }
@@ -2041,12 +2036,12 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
 #else /* !ZUNE_HD */
     data->glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats);
     data->glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler);
-    if (hasCompiler)
+    if (hasCompiler) {
         ++nFormats;
+    }
 #endif /* ZUNE_HD */
     data->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum));
-    if (!data->shader_formats)
-    {
+    if (!data->shader_formats) {
         GLES2_DestroyRenderer(renderer);
         SDL_OutOfMemory();
         goto error;
@@ -2056,8 +2051,9 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
     data->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV;
 #else /* !ZUNE_HD */
     data->glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)data->shader_formats);
-    if (hasCompiler)
+    if (hasCompiler) {
         data->shader_formats[nFormats - 1] = (GLenum)-1;
+    }
 #endif /* ZUNE_HD */
 
     data->framebuffers = NULL;
diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c
index 48040f9..78a3956 100644
--- a/src/render/opengles2/SDL_shaders_gles2.c
+++ b/src/render/opengles2/SDL_shaders_gles2.c
@@ -810,13 +810,11 @@ static GLES2_Shader GLES2_FragmentShader_TextureNV21Src = {
 
 const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode)
 {
-    switch (type)
-    {
+    switch (type) {
     case GLES2_SHADER_VERTEX_DEFAULT:
         return &GLES2_VertexShader_Default;
     case GLES2_SHADER_FRAGMENT_SOLID_SRC:
-    switch (blendMode)
-    {
+    switch (blendMode) {
     case SDL_BLENDMODE_NONE:
         return &GLES2_FragmentShader_None_SolidSrc;
     case SDL_BLENDMODE_BLEND:
@@ -829,8 +827,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo
         return NULL;
     }
     case GLES2_SHADER_FRAGMENT_TEXTURE_ABGR_SRC:
-        switch (blendMode)
-    {
+        switch (blendMode) {
         case SDL_BLENDMODE_NONE:
             return &GLES2_FragmentShader_None_TextureABGRSrc;
         case SDL_BLENDMODE_BLEND:
@@ -843,8 +840,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo
             return NULL;
     }
     case GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC:
-        switch (blendMode)
-    {
+        switch (blendMode) {
         case SDL_BLENDMODE_NONE:
             return &GLES2_FragmentShader_None_TextureARGBSrc;
         case SDL_BLENDMODE_BLEND:
@@ -858,8 +854,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo
     }
 
     case GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC:
-        switch (blendMode)
-    {
+        switch (blendMode) {
         case SDL_BLENDMODE_NONE:
             return &GLES2_FragmentShader_None_TextureRGBSrc;
         case SDL_BLENDMODE_BLEND:
@@ -873,8 +868,7 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMo
     }
 
     case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
-        switch (blendMode)
-    {
+        switch (blendMode) {
         case SDL_BLENDMODE_NONE:
             return &GLES2_FragmentShader_None_TextureBGRSrc;
         case SDL_BLENDMODE_BLEND: