SDL: Less code since color is constant when done with triangles

From 51e4115ed87c5dbb51650c84268a80db2342c830 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Fri, 24 Sep 2021 17:09:04 +0200
Subject: [PATCH] Less code since color is constant when done with triangles

---
 src/render/SDL_render.c | 32 +++++++++++---------------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 4f42df2165..ccc1a648fe 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -904,7 +904,7 @@ void VerifyDrawQueueFunctions(const SDL_Renderer *renderer)
     SDL_assert(renderer->QueueSetDrawColor != NULL);
     SDL_assert(renderer->QueueDrawPoints != NULL);
     SDL_assert(renderer->QueueDrawLines != NULL);
-    SDL_assert(renderer->QueueFillRects != NULL);
+    SDL_assert(renderer->QueueFillRects != NULL || renderer->QueueGeometry != NULL);
     SDL_assert(renderer->QueueCopy != NULL || renderer->QueueGeometry != NULL);
     SDL_assert(renderer->RunCommandQueue != NULL);
 }
@@ -3296,8 +3296,8 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
     if (renderer->QueueGeometry && renderer->QueueCopy == NULL) {
         float xy[8];
         const int xy_stride = 2 * sizeof (float);
-        SDL_Color col, color[4];
-        const int color_stride = sizeof (SDL_Color);
+        SDL_Color color;
+        const int color_stride = 0;
         float uv[8];
         const int uv_stride = 2 * sizeof (float);
         const int num_vertices = 4;
@@ -3307,13 +3307,8 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
         float minu, minv, maxu, maxv;
         float minx, miny, maxx, maxy;
 
-        SDL_GetTextureColorMod(texture, &col.r, &col.g, &col.b);
-        SDL_GetTextureAlphaMod(texture, &col.a);
-
-        color[0] = col;
-        color[1] = col;
-        color[2] = col;
-        color[3] = col;
+        SDL_GetTextureColorMod(texture, &color.r, &color.g, &color.b);
+        SDL_GetTextureAlphaMod(texture, &color.a);
 
         minu = (float) (real_srcrect.x) / (float) texture->w;
         minv = (float) (real_srcrect.y) / (float) texture->h;
@@ -3344,7 +3339,7 @@ SDL_RenderCopyF(SDL_Renderer * renderer, SDL_Texture * texture,
         xy[7] = maxy;
 
         retval = QueueCmdGeometry(renderer, texture,
-                xy, xy_stride, (int *)color, color_stride, uv, uv_stride,
+                xy, xy_stride, (int *)&color, color_stride, uv, uv_stride,
                 num_vertices,
                 indices, num_indices, size_indices,
                 renderer->scale.x, renderer->scale.y);
@@ -3451,8 +3446,8 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
     if (renderer->QueueGeometry && renderer->QueueCopyEx == NULL) {
         float xy[8];
         const int xy_stride = 2 * sizeof (float);
-        SDL_Color col, color[4];
-        const int color_stride = sizeof (SDL_Color);
+        SDL_Color color;
+        const int color_stride = 0;
         float uv[8];
         const int uv_stride = 2 * sizeof (float);
         const int num_vertices = 4;
@@ -3470,13 +3465,8 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
         const float s = SDL_sin(radian_angle);
         const float c = SDL_cos(radian_angle);
 
-        SDL_GetTextureColorMod(texture, &col.r, &col.g, &col.b);
-        SDL_GetTextureAlphaMod(texture, &col.a);
-
-        color[0] = col;
-        color[1] = col;
-        color[2] = col;
-        color[3] = col;
+        SDL_GetTextureColorMod(texture, &color.r, &color.g, &color.b);
+        SDL_GetTextureAlphaMod(texture, &color.a);
 
         minu = (float) (real_srcrect.x) / (float) texture->w;
         minv = (float) (real_srcrect.y) / (float) texture->h;
@@ -3536,7 +3526,7 @@ SDL_RenderCopyExF(SDL_Renderer * renderer, SDL_Texture * texture,
         xy[7] = (s_minx + c_maxy) + centery;
 
         retval = QueueCmdGeometry(renderer, texture,
-                xy, xy_stride, (int *)color, color_stride, uv, uv_stride,
+                xy, xy_stride, (int *)&color, color_stride, uv, uv_stride,
                 num_vertices,
                 indices, num_indices, size_indices,
                 renderer->scale.x, renderer->scale.y);