summaryrefslogtreecommitdiff
path: root/canvas
diff options
context:
space:
mode:
authorPatrick Luby <plubius@neooffice.org>2023-08-04 16:36:42 -0400
committerPatrick Luby <plubius@neooffice.org>2023-08-05 22:58:28 +0200
commit52637f46cc79eb7f65a97524e92a0b2f45d3d598 (patch)
tree0eb090c683ecf5e8cb71df72f27342231b2e9edc /canvas
parent484182b04d35f15437c09008cede361edde71d01 (diff)
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>
Diffstat (limited to 'canvas')
-rw-r--r--canvas/source/vcl/spritehelper.cxx18
1 files changed, 16 insertions, 2 deletions
diff --git a/canvas/source/vcl/spritehelper.cxx b/canvas/source/vcl/spritehelper.cxx
index 3494a5fbda8f..54ad52216de7 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();