drawinglayer/source/primitive2d/graphicprimitivehelper2d.cxx |   21 +++++++++--
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit b666333c6c4eb2013ff3d8d9119c660ed1e9c372
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Jun 30 15:24:48 2020 +0200
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Thu Jul 2 20:47:04 2020 +0200

    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.lu...@collabora.com>
    (cherry picked from commit 1fca8d1f7d97816ae469f2eb3079ecda9542bd44)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97686
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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()));
             }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to