diff options
author | Patrick Luby <plubius@neooffice.org> | 2023-08-07 12:17:36 -0400 |
---|---|---|
committer | Patrick Luby <plubius@neooffice.org> | 2023-08-10 14:01:10 +0200 |
commit | 12fd870113a663dde5ceb38c61f1986a34095d0e (patch) | |
tree | 04982fbf6a4ed1de1fda1346e73385b375e76e52 /drawinglayer | |
parent | 0d8a5f89bff51480d721395729a67e7b4260aea5 (diff) |
tdf#156630 eliminate opaque parts when drawing animated PNG images
Due to the switch from transparency to alpha in commit
81994cb2b8b32453a92bcb011830fcb884f22ff3, flip the background colors
for the VirtualDevices and invert an alpha mask.
On macOS, with Skia/Raster with a Retina display (i.e. 2.0 window
scale), the alpha mask gets upscaled. Also, when Skia is enabled,
the alpha mask gets inverted in the first export to PDF after
launching the application. These two bugs appear to be caused by
asynchronous rendering of the returned bitmap. So, we force a copy
of the alpha mask in case it changes before the bitmap is actually
drawn.
Lastly, respect system animation settings when determining if the image
should be animated.
Change-Id: I8144691a6c99bf8361b301b88d22172991463f26
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155429
Tested-by: Jenkins
Reviewed-by: Patrick Luby <plubius@neooffice.org>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx index f3c4cf69911c..7c9f7b3f3397 100644 --- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx +++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx @@ -104,6 +104,10 @@ namespace drawinglayer::primitive2d maVirtualDeviceMask->EnableMapMode(false); maVirtualDevice->SetOutputSizePixel(aTarget); maVirtualDeviceMask->SetOutputSizePixel(aTarget); + + // tdf#156630 make erase calls fill with transparency + maVirtualDevice->SetBackground(COL_BLACK); + maVirtualDeviceMask->SetBackground(COL_ALPHA_TRANSPARENT); } maVirtualDevice->Erase(); @@ -176,12 +180,26 @@ namespace drawinglayer::primitive2d BitmapEx bitmap; if( useAlphaMask ) { - const AlphaMask aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel())); + AlphaMask aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel())); + + // Related tdf#156630 force snapshot of alpha mask + // On macOS, with Skia/Raster with a Retina display (i.e. + // 2.0 window scale), the alpha mask gets upscaled. Also, + // when Skia is enabled, the alpha mask gets inverted in + // the first export to PDF after launching the application. + // These two bugs appear to be caused by asynchronous + // rendering of the returned bitmap. So, we force a copy + // of the alpha mask in case it changes before the bitmap + // is actually drawn. + AlphaMask::ScopedReadAccess pAccessAlpha(aMaskBitmap); + bitmap = BitmapEx(aMainBitmap, aMaskBitmap); } else { - const Bitmap aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel())); + Bitmap aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel())); + // tdf#156630 invert the alpha mask + aMaskBitmap.Invert(); // convert from transparency to alpha bitmap = BitmapEx(aMainBitmap, aMaskBitmap); } |