summaryrefslogtreecommitdiff
path: root/drawinglayer
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-30 15:24:48 +0200
committerCaolán McNamara <caolanm@redhat.com>2020-07-02 20:47:04 +0200
commitb666333c6c4eb2013ff3d8d9119c660ed1e9c372 (patch)
tree0ac07c807811feedadd7bc50cbe40bd2a57d971c /drawinglayer
parentbbcc31c7261daba266b31a8d7d58fe0c1c87febe (diff)
avoid costly to-monochrome-bitmap conversion with Skia (tdf#134365)
The BitmapEx 1bpp monochrome bitmap mask constructor forces the mask to be 1bpp, which is done in software by BitmapMonochromeFilter. Which with Vulkan leads to fetching all the data from the GPU, usually only to be converted and then pushed back to the GPU. Similarly to MACOSX and iOS, just use AlphaMask, which is just better (8bit is easier to handle and in Skia's case it's also optimized to avoid fetching the data if possible). Change-Id: I5770c2b0c298c1534b7ff56cc905d2d668d3a8df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97525 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com> (cherry picked from commit 1fca8d1f7d97816ae469f2eb3079ecda9542bd44) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97686 Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
index e06a41c500a8..9c441dc0d876 100644
--- a/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
+++ b/drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx
@@ -41,6 +41,7 @@
#include <vcl/virdev.hxx>
#include <vcl/svapp.hxx>
#include <toolkit/helper/vclunohelper.hxx>
+#include <vcl/skia/SkiaHelper.hxx>
namespace drawinglayer::primitive2d
{
@@ -163,15 +164,29 @@ namespace drawinglayer::primitive2d
{
// create BitmapEx by extracting from VirtualDevices
const Bitmap aMainBitmap(maVirtualDevice->GetBitmap(Point(), maVirtualDevice->GetOutputSizePixel()));
+ bool useAlphaMask = false;
#if defined(MACOSX) || defined(IOS)
- const AlphaMask aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel()));
+ useAlphaMask = true;
#else
- const Bitmap aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel()));
+ // GetBitmap()-> AlphaMask is optimized with SkiaSalBitmap::InterpretAs8Bit(), 1bpp mask is not.
+ if( SkiaHelper::isVCLSkiaEnabled())
+ useAlphaMask = true;
#endif
+ BitmapEx bitmap;
+ if( useAlphaMask )
+ {
+ const AlphaMask aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel()));
+ bitmap = BitmapEx(aMainBitmap, aMaskBitmap);
+ }
+ else
+ {
+ const Bitmap aMaskBitmap(maVirtualDeviceMask->GetBitmap(Point(), maVirtualDeviceMask->GetOutputSizePixel()));
+ bitmap = BitmapEx(aMainBitmap, aMaskBitmap);
+ }
return Primitive2DReference(
new BitmapPrimitive2D(
- VCLUnoHelper::CreateVCLXBitmap(BitmapEx(aMainBitmap, aMaskBitmap)),
+ VCLUnoHelper::CreateVCLXBitmap(bitmap),
getTransform()));
}