canvas/source/vcl/spritehelper.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
New commits: commit 52637f46cc79eb7f65a97524e92a0b2f45d3d598 Author: Patrick Luby <plub...@neooffice.org> AuthorDate: Fri Aug 4 16:36:42 2023 -0400 Commit: Patrick Luby <plub...@neooffice.org> CommitDate: Sat Aug 5 22:58:28 2023 +0200 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.wegh...@posteo.de> Reviewed-by: Patrick Luby <plub...@neooffice.org> 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();