diff options
author | Willem Jan Palenstijn | 2012-02-19 19:17:47 +0100 |
---|---|---|
committer | Willem Jan Palenstijn | 2012-02-20 22:17:33 +0100 |
commit | 905f9591ab664cdef498d689d413ea2d40ebb442 (patch) | |
tree | ab9015fc592caf06dd033550028ffffbc2f65df6 /graphics/VectorRendererSpec.cpp | |
parent | 297d15e122e39ca1c80dc255b1d36b03111630fc (diff) | |
download | scummvm-rg350-905f9591ab664cdef498d689d413ea2d40ebb442.tar.gz scummvm-rg350-905f9591ab664cdef498d689d413ea2d40ebb442.tar.bz2 scummvm-rg350-905f9591ab664cdef498d689d413ea2d40ebb442.zip |
GUI: Speed up alpha blending with black for classic dialog backgrounds
Diffstat (limited to 'graphics/VectorRendererSpec.cpp')
-rw-r--r-- | graphics/VectorRendererSpec.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp index efe38cbc5d..28b475f8db 100644 --- a/graphics/VectorRendererSpec.cpp +++ b/graphics/VectorRendererSpec.cpp @@ -527,6 +527,35 @@ blendPixelPtr(PixelType *ptr, PixelType color, uint8 alpha) { (idst & _alphaMask)); } +template<typename PixelType> +inline void VectorRendererSpec<PixelType>:: +darkenFill(PixelType *ptr, PixelType *end) { + PixelType mask = (PixelType)((3 << _format.rShift) | (3 << _format.gShift) | (3 << _format.bShift)); + + if (!g_system->hasFeature(OSystem::kFeatureOverlaySupportsAlpha)) { + // !kFeatureOverlaySupportsAlpha (but might have alpha bits) + + while (ptr != end) { + *ptr = ((*ptr & ~mask) >> 2) | _alphaMask; + ++ptr; + } + } else { + // kFeatureOverlaySupportsAlpha + // assuming at least 3 alpha bits + + mask |= 3 << _format.aShift; + PixelType addA = (PixelType)(255 >> _format.aLoss) << _format.aShift; + addA -= (addA >> 2); + + while (ptr != end) { + // Darken the colour, and increase the alpha + // (0% -> 75%, 100% -> 100%) + *ptr = (PixelType)(((*ptr & ~mask) >> 2) + addA); + ++ptr; + } + } +} + /******************************************************************** ******************************************************************** * Primitive shapes drawing - Public API calls - VectorRendererSpec * @@ -1020,8 +1049,9 @@ drawBevelSquareAlg(int x, int y, int w, int h, int bevel, PixelType top_color, P PixelType *ptr_fill = (PixelType *)_activeSurface->getBasePtr(x, y); if (fill) { + assert((_bgColor & ~_alphaMask) == 0); // only support black while (height--) { - blendFill(ptr_fill, ptr_fill + w, _bgColor, 200); + darkenFill(ptr_fill, ptr_fill + w); ptr_fill += pitch; } } |