diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-06-30 15:24:48 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-07-01 07:38:10 +0200 |
commit | 1fca8d1f7d97816ae469f2eb3079ecda9542bd44 (patch) | |
tree | 4b1884965f9def4264817b296745ce90588c0821 /drawinglayer | |
parent | d1fcc9053f98cc4afb52498b40a836884bb5ec6f (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>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx | 21 |
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())); } |