From 1fca8d1f7d97816ae469f2eb3079ecda9542bd44 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 30 Jun 2020 15:24:48 +0200 Subject: avoid costly to-monochrome-bitmap conversion with Skia (tdf#134365) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../source/primitive2d/graphicprimitivehelper2d.cxx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'drawinglayer') 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 #include #include +#include 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())); } -- cgit v1.2.3