vcl/skia/gdiimpl.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-)
New commits: commit 4addedabe6778e70754709290502d721cdef796d Author: Luboš Luňák <l.lu...@collabora.com> AuthorDate: Mon Jul 27 14:42:15 2020 +0200 Commit: Luboš Luňák <l.lu...@collabora.com> CommitDate: Mon Jul 27 15:57:33 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.lu...@collabora.com> diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx index a5d2a484ce6a..066311e97c2b 100644 --- a/vcl/skia/gdiimpl.cxx +++ b/vcl/skia/gdiimpl.cxx @@ -1363,7 +1363,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()) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits