aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Comstedt2014-01-10 15:45:37 +0100
committerMarcus Comstedt2014-01-10 15:56:53 +0100
commit51d7405a7b741b8028b83e1548b3b8260230c5a1 (patch)
treea2509ec12e29a54b9e47ceb91d12206583e96894
parent66ad9e76eeda77f2ca4d10db82cfd31dba38d127 (diff)
downloadscummvm-rg350-51d7405a7b741b8028b83e1548b3b8260230c5a1.tar.gz
scummvm-rg350-51d7405a7b741b8028b83e1548b3b8260230c5a1.tar.bz2
scummvm-rg350-51d7405a7b741b8028b83e1548b3b8260230c5a1.zip
GRAPHICS: Fix computation of addA in darkenFill()
The old computation had rounding issues, causing alpha to leak into the red (usually) component. There's a much easier way to compute it that does not lead to such problems: What should really happen is that the two top bits of the A component should be set to 1 (thus adding 75% alpha). So compute it that way for speed and precision.
-rw-r--r--graphics/VectorRendererSpec.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index ce04db8a67..de249e8711 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -691,8 +691,7 @@ darkenFill(PixelType *ptr, PixelType *end) {
// assuming at least 3 alpha bits
mask |= 3 << _format.aShift;
- PixelType addA = (PixelType)(255 >> _format.aLoss) << _format.aShift;
- addA -= (addA >> 2);
+ PixelType addA = (PixelType)(3 << (_format.aShift + 6 - _format.aLoss));
while (ptr != end) {
// Darken the colour, and increase the alpha