tdf#156540 invert alpha when drawing sprites
Due to the switch from transparency to alpha in commit
81994cb2b8b32453a92bcb011830fcb884f22ff3, a sprite's
alpha mask needs to be inverted when Skia is enabled and
the fAlpha value needs to be inverted when Skia is disabled.
Change-Id: Ie802924b07ddbab536a2eddb57bf82e5146cffe7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155358
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Reviewed-by: Patrick Luby <plubius@neooffice.org>
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index 3494a5f..54ad522 100644
--- a/canvas/source/vcl/spritehelper.cxx
+++ b/canvas/source/vcl/spritehelper.cxx
@@ -31,6 +31,7 @@
#include <vcl/bitmapex.hxx>
#include <vcl/canvastools.hxx>
#include <vcl/outdev.hxx>
#include <vcl/skia/SkiaHelper.hxx>
#include <canvas/canvastools.hxx>
@@ -136,10 +137,17 @@ namespace vclcanvas
BitmapEx aMask( mpBackBufferMask->getOutDev().GetBitmapEx( aEmptyPoint,
aOutputSize ) );
AlphaMask aAlpha( aMask.GetBitmap() );
#if HAVE_FEATURE_SKIA
// tdf#156540 invert alpha mask when using Skia
if ( SkiaHelper::isVCLSkiaEnabled() )
aAlpha.Invert();
#endif
// Note: since we retrieved aBmp and aMask
// directly from an OutDev, it's already a
// 'display bitmap' on windows.
maContent = BitmapEx( aBmp.GetBitmap(), AlphaMask( aMask.GetBitmap()) );
maContent = BitmapEx( aBmp.GetBitmap(), aAlpha );
}
}
@@ -180,7 +188,13 @@ namespace vclcanvas
aMoveTransform.translate( aOutPos.X(), aOutPos.Y() );
aTransform = aMoveTransform * aTransform * aSizeTransform;
rTargetSurface.DrawTransformedBitmapEx( aTransform, *maContent, fAlpha );
// tdf#156540 invert alpha when Skia is disabled
bool bAlpha = false;
#if HAVE_FEATURE_SKIA
if ( SkiaHelper::isVCLSkiaEnabled() )
bAlpha = true;
#endif
rTargetSurface.DrawTransformedBitmapEx( aTransform, *maContent, bAlpha ? fAlpha : 1.0 - fAlpha );
rTargetSurface.Pop();