diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index de249e87116..a3ec66a29d0 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -620,7 +620,10 @@ applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) { template inline void VectorRendererSpec:: blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) { - if (sizeof(PixelType) == 4) { + if (alpha == 0xff) { + // fully opaque pixel, don't blend + *ptr = color | _alphaMask; + } else if (sizeof(PixelType) == 4) { const byte sR = (color & _redMask) >> _format.rShift; const byte sG = (color & _greenMask) >> _format.gShift; const byte sB = (color & _blueMask) >> _format.bShift; @@ -628,15 +631,17 @@ blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) { byte dR = (*ptr & _redMask) >> _format.rShift; byte dG = (*ptr & _greenMask) >> _format.gShift; byte dB = (*ptr & _blueMask) >> _format.bShift; + byte dA = (*ptr & _alphaMask) >> _format.aShift; dR += ((sR - dR) * alpha) >> 8; dG += ((sG - dG) * alpha) >> 8; dB += ((sB - dB) * alpha) >> 8; + dA += ((0xff - dA) * alpha) >> 8; *ptr = ((dR << _format.rShift) & _redMask) | ((dG << _format.gShift) & _greenMask) | ((dB << _format.bShift) & _blueMask) - | (*ptr & _alphaMask); + | ((dA << _format.aShift) & _alphaMask); } else if (sizeof(PixelType) == 2) { int idst = *ptr; int isrc = color; @@ -651,7 +656,9 @@ blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) { (_blueMask & ((idst & _blueMask) + ((int)(((int)(isrc & _blueMask) - (int)(idst & _blueMask)) * alpha) >> 8))) | - (idst & _alphaMask)); + (_alphaMask & ((idst & _alphaMask) + + ((int)(((int)(_alphaMask) - + (int)(idst & _alphaMask)) * alpha) >> 8)))); } else { error("Unsupported BPP format: %u", (uint)sizeof(PixelType)); }