[Libreoffice-commits] core.git: vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 27 08:16:42 UTC 2020


 vcl/skia/gdiimpl.cxx |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

New commits:
commit 172b9142194699d0e847703b0e0cfcabcb1de1ef
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Sat Jun 27 08:09:52 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Sat Jun 27 10:16:08 2020 +0200

    cache raster scaling also in Skia's drawAlphaBitmap()
    
    Change-Id: I52849097267326cb362b113241179a766d286a6b
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97273
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 9304246e439e..b00b74d24647 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1329,11 +1329,23 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi
     assert(dynamic_cast<const SkiaSalBitmap*>(&rAlphaBitmap));
     // In raster mode use mergeCacheBitmaps(), which will cache the result, avoiding repeated
     // alpha blending or scaling. In GPU mode it is simpler to just use SkShader.
-    sk_sp<SkImage> image = mergeCacheBitmaps(static_cast<const SkiaSalBitmap&>(rSourceBitmap),
-                                             static_cast<const SkiaSalBitmap*>(&rAlphaBitmap),
-                                             rSourceBitmap.GetSize());
+    SalTwoRect imagePosAry(rPosAry);
+    Size imageSize = rSourceBitmap.GetSize();
+    // If the bitmap will be scaled, prefer to do it in mergeCacheBitmaps(), if possible.
+    if ((rPosAry.mnSrcWidth != rPosAry.mnDestWidth || rPosAry.mnSrcHeight != rPosAry.mnDestHeight)
+        && rPosAry.mnSrcX == 0 && rPosAry.mnSrcY == 0
+        && rPosAry.mnSrcWidth == rSourceBitmap.GetSize().Width()
+        && rPosAry.mnSrcHeight == rSourceBitmap.GetSize().Height())
+    {
+        imagePosAry.mnSrcWidth = imagePosAry.mnDestWidth;
+        imagePosAry.mnSrcHeight = imagePosAry.mnDestHeight;
+        imageSize = Size(imagePosAry.mnSrcWidth, imagePosAry.mnSrcHeight);
+    }
+    sk_sp<SkImage> image
+        = mergeCacheBitmaps(static_cast<const SkiaSalBitmap&>(rSourceBitmap),
+                            static_cast<const SkiaSalBitmap*>(&rAlphaBitmap), imageSize);
     if (image)
-        drawImage(rPosAry, image);
+        drawImage(imagePosAry, image);
     else
         drawShader(
             rPosAry,


More information about the Libreoffice-commits mailing list