diff options
Diffstat (limited to 'graphics/VectorRendererSpec.cpp')
-rw-r--r-- | graphics/VectorRendererSpec.cpp | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index 491a9d7f42..a9594f7dd2 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -620,7 +620,10 @@ applyScreenShading(GUI::ThemeEngine::ShadingStyle shadingStyle) { template<typename PixelType> inline void VectorRendererSpec<PixelType>:: 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)); } @@ -691,11 +698,10 @@ 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 + // Darken the color, and increase the alpha // (0% -> 75%, 100% -> 100%) *ptr = (PixelType)(((*ptr & ~mask) >> 2) + addA); ++ptr; @@ -1266,51 +1272,50 @@ template<typename PixelType> void VectorRendererSpec<PixelType>:: drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, PixelType bottom_color, bool fill) { int pitch = _activeSurface->pitch / _activeSurface->format.bytesPerPixel; + int i, j; + PixelType *ptr_left; - int height = h; - PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y); - + // Fill Background + ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); + i = h; if (fill) { assert((_bgColor & ~_alphaMask) == 0); // only support black - while (height--) { - darkenFill(ptr_fill, ptr_fill + w); - ptr_fill += pitch; + while (i--) { + darkenFill(ptr_left, ptr_left + w); + ptr_left += pitch; } } - int i, j; - x = MAX(x - bevel, 0); y = MAX(y - bevel, 0); w = MIN(w + (bevel * 2), (int)_activeSurface->w); h = MIN(h + (bevel * 2), (int)_activeSurface->h); - PixelType *ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); - + ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y); i = bevel; while (i--) { colorFill<PixelType>(ptr_left, ptr_left + w, top_color); ptr_left += pitch; } - i = h - bevel; ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + bevel); + i = h - bevel; while (i--) { colorFill<PixelType>(ptr_left, ptr_left + bevel, top_color); ptr_left += pitch; } - i = bevel; ptr_left = (PixelType *)_activeSurface->getBasePtr(x, y + h - bevel); + i = bevel; while (i--) { colorFill<PixelType>(ptr_left + i, ptr_left + w, bottom_color); ptr_left += pitch; } + ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y); i = h - bevel; j = bevel - 1; - ptr_left = (PixelType *)_activeSurface->getBasePtr(x + w - bevel, y); while (i--) { colorFill<PixelType>(ptr_left + j, ptr_left + bevel, bottom_color); if (j > 0) j--; |