aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2012-02-19 19:17:47 +0100
committerWillem Jan Palenstijn2012-02-20 22:17:33 +0100
commit905f9591ab664cdef498d689d413ea2d40ebb442 (patch)
treeab9015fc592caf06dd033550028ffffbc2f65df6 /graphics
parent297d15e122e39ca1c80dc255b1d36b03111630fc (diff)
downloadscummvm-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')
-rw-r--r--graphics/VectorRendererSpec.cpp32
-rw-r--r--graphics/VectorRendererSpec.h2
2 files changed, 33 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;
}
}
diff --git a/graphics/VectorRendererSpec.h b/graphics/VectorRendererSpec.h
index 39505d3c27..7812e77b22 100644
--- a/graphics/VectorRendererSpec.h
+++ b/graphics/VectorRendererSpec.h
@@ -201,6 +201,8 @@ protected:
while (first != last) blendPixelPtr(first++, color, alpha);
}
+ void darkenFill(PixelType *first, PixelType *last);
+
const PixelFormat _format;
const PixelType _redMask, _greenMask, _blueMask, _alphaMask;