From 1be03b4089df447fce67ab0adf8ed9fc06cf32b9 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 17 Aug 2019 22:26:33 -0300 Subject: [PATCH] render: avoid a couple redundant memcmp calls in all drawing functions. Improves performance slightly. --- src/render/SDL_render.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 6e7ec61b0..760adb089 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -410,14 +410,17 @@ QueueCmdClear(SDL_Renderer *renderer) static int PrepQueueCmdDraw(SDL_Renderer *renderer, const Uint8 r, const Uint8 g, const Uint8 b, const Uint8 a) { + /* Guarantee that the draw color, viewport, and clip rect are set before + * draws, so the backends don't have to worry about that state not being + * valid at draw time. */ int retval = 0; - if (retval == 0) { + if (retval == 0 && !renderer->color_queued) { retval = QueueCmdSetDrawColor(renderer, r, g, b, a); } - if (retval == 0) { + if (retval == 0 && !renderer->viewport_queued) { retval = QueueCmdSetViewport(renderer); } - if (retval == 0) { + if (retval == 0 && !renderer->cliprect_queued) { retval = QueueCmdSetClipRect(renderer); } return retval;