[Libreoffice-commits] core.git: Branch 'libreoffice-7-0' - vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 29 08:25:16 UTC 2020
vcl/skia/gdiimpl.cxx | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
New commits:
commit 7057d6729c865eac4831f9c286421b553a7c4ee9
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Jul 27 14:42:15 2020 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Jul 29 10:24:40 2020 +0200
tweak not caching images in Skia drawing when upscaling (tdf#132438)
The change done for tdf#134237 was meant to avoid caching of very
large images when zooming in. But it turns out that it happens
quite often that we get asked to draw something larger than
the drawing area, such as when scrolling a document with a larger
image. So tweak the check to hopefully avoid only huge images
or when upscaling a lot.
Change-Id: Ifa76e0ef2df78085afc21fd064b77d5b1c9513b5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99482
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
(cherry picked from commit 4addedabe6778e70754709290502d721cdef796d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99493
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 980f0c688651..66f3655f9c53 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1340,7 +1340,27 @@ sk_sp<SkImage> SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
// better to rely on Skia to clip and draw only the necessary, rather than prepare
// a very large image only to not use most of it.
if (targetSize.Width() > GetWidth() || targetSize.Height() > GetHeight())
- return image;
+ {
+ // This is a bit tricky. The condition above just checks that at least a part of the resulting
+ // image will not be used (it's larger then our drawing area). But this may often happen
+ // when just scrolling a document with a large image, where the caching may very well be worth it.
+ // Since the problem is mainly the cost of upscaling and then the size of the resulting bitmap,
+ // compute a ratio of how much this is going to be scaled up, how much this is larger than
+ // the drawing area, and then refuse to cache if it's too much.
+ const double upscaleRatio = 1.0 * targetSize.Width() / bitmap.GetSize().Width()
+ * targetSize.Height() / bitmap.GetSize().Height();
+ const double oversizeRatio
+ = 1.0 * targetSize.Width() / GetWidth() * targetSize.Height() / GetHeight();
+ const double ratio = upscaleRatio * oversizeRatio;
+ if (ratio > 10)
+ {
+ SAL_INFO("vcl.skia.trace", "mergecachebitmaps("
+ << this << "): not caching upscaling, ratio:" << ratio
+ << ", " << bitmap.GetSize() << "->" << targetSize
+ << " in " << Size(GetWidth(), GetHeight()));
+ return image;
+ }
+ }
OString key;
OStringBuffer keyBuf;
keyBuf.append(targetSize.Width())
More information about the Libreoffice-commits
mailing list