summaryrefslogtreecommitdiff
path: root/vcl/skia
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-27 08:09:52 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-06-27 10:16:08 +0200
commit172b9142194699d0e847703b0e0cfcabcb1de1ef (patch)
tree88b1739bb8b1f91f7ba67bac31b69b682a0c1e48 /vcl/skia
parent92de6c794e6033ced0c6273f70b7d425a4c4e495 (diff)
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@collabora.com>
Diffstat (limited to 'vcl/skia')
-rw-r--r--vcl/skia/gdiimpl.cxx20
1 files changed, 16 insertions, 4 deletions
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,