From 9262c0de9b661c7b4f5b910a7277f426c19012c3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 14 Nov 2018 22:38:58 -0500 Subject: [PATCH] software: fix blits with color mods that change during a command queue run. --- src/render/software/SDL_render_sw.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 7effafaa0..1afc05b80 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -554,20 +554,17 @@ PrepTextureForCopy(const SDL_RenderCommand *cmd) const SDL_BlendMode blend = cmd->data.draw.blend; SDL_Texture *texture = cmd->data.draw.texture; SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + const SDL_bool colormod = ((r & g & b) != 0xFF); + const SDL_bool alphamod = (a != 0xFF); + const SDL_bool blending = ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD)); - if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { - SDL_SetSurfaceRLE(surface, 0); - SDL_SetSurfaceColorMod(surface, r, g, b); - } - - if ((texture->modMode & SDL_TEXTUREMODULATE_ALPHA) && surface->format->Amask) { - SDL_SetSurfaceRLE(surface, 0); - SDL_SetSurfaceAlphaMod(surface, a); - } - - if ((blend == SDL_BLENDMODE_ADD) || (blend == SDL_BLENDMODE_MOD)) { + if (colormod || alphamod || blending) { SDL_SetSurfaceRLE(surface, 0); } + + /* !!! FIXME: we can probably avoid some of these calls. */ + SDL_SetSurfaceColorMod(surface, r, g, b); + SDL_SetSurfaceAlphaMod(surface, a); SDL_SetSurfaceBlendMode(surface, blend); }