From 07e5e9f4c4318c19dd553459132efa71d456eaef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 15 Nov 2021 20:07:51 +0100 Subject: [PATCH] don't bother caching bitmaps that prefer shaders MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Ibc78371f9e2ba92470714847bb6a5b8b96d1037f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125264 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/skia/gdiimpl.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index de1e8c47cb12..b97d2f28c428 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1611,6 +1611,9 @@ sk_sp SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma return image; if (alphaBitmap && alphaBitmap->IsFullyOpaqueAsAlpha()) alphaBitmap = nullptr; // the alpha can be ignored + if (bitmap.PreferSkShader() && (!alphaBitmap || alphaBitmap->PreferSkShader())) + return image; + // Probably not much point in caching of just doing a copy. if (alphaBitmap == nullptr && targetSize == bitmap.GetSize()) return image; @@ -1730,7 +1733,8 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi = mergeCacheBitmaps(rSkiaSourceBitmap, &rSkiaAlphaBitmap, imageSize * mScaling); if (image) drawImage(imagePosAry, image, mScaling); - else if (rSkiaAlphaBitmap.IsFullyOpaqueAsAlpha()) // alpha can be ignored + else if (rSkiaAlphaBitmap.IsFullyOpaqueAsAlpha() + && !rSkiaSourceBitmap.PreferSkShader()) // alpha can be ignored drawBitmap(rPosAry, rSkiaSourceBitmap); else drawShader(rPosAry, @@ -1744,11 +1748,6 @@ bool SkiaSalGraphicsImpl::drawAlphaBitmap(const SalTwoRect& rPosAry, const SalBi void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkiaSalBitmap& bitmap, SkBlendMode blendMode) { - if (bitmap.PreferSkShader()) - { - drawShader(rPosAry, bitmap.GetSkShader(makeSamplingOptions(rPosAry, mScaling)), blendMode); - return; - } // Use mergeCacheBitmaps(), which may decide to cache the result, avoiding repeated // scaling. SalTwoRect imagePosAry(rPosAry); @@ -1766,6 +1765,8 @@ void SkiaSalGraphicsImpl::drawBitmap(const SalTwoRect& rPosAry, const SkiaSalBit sk_sp image = mergeCacheBitmaps(bitmap, nullptr, imageSize * mScaling); if (image) drawImage(imagePosAry, image, mScaling, blendMode); + else if (bitmap.PreferSkShader()) + drawShader(rPosAry, bitmap.GetSkShader(makeSamplingOptions(rPosAry, mScaling)), blendMode); else drawImage(rPosAry, bitmap.GetSkImage(), 1, blendMode); } -- 2.11.4.GIT