summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-09-05 09:13:31 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-09-07 15:20:15 +0200
commit93a7f074d3bdcb293fe2e6410c0401056f6c860f (patch)
tree3182b7c32f8b2d0514c1ab79fd220927c76a0afd
parenta8a7df6de6b48a03589ac9b66b490875eab19b75 (diff)
tweak not caching overly large Skia images (tdf#136244)
If the image is way too oversized, it doesn't matter it's being scaled down. Change-Id: I148cd6b95953abb9fcbb5ea8dd19cadaa513e573 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102070 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
-rw-r--r--vcl/skia/gdiimpl.cxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index f5374b773028..cb0f9b47ecf8 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1422,17 +1422,18 @@ sk_sp<SkImage> SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
// 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 upscaleRatio
+ = std::max(1.0, 1.0 * targetSize.Width() / bitmap.GetSize().Width()
+ * targetSize.Height() / bitmap.GetSize().Height());
const double oversizeRatio = 1.0 * targetSize.Width() / drawAreaSize.Width()
* targetSize.Height() / drawAreaSize.Height();
const double ratio = upscaleRatio * oversizeRatio;
- if (ratio > 10)
+ if (ratio > 4)
{
SAL_INFO("vcl.skia.trace", "mergecachebitmaps("
- << this << "): not caching upscaling, ratio:" << ratio
- << ", " << bitmap.GetSize() << "->" << targetSize
- << " in " << drawAreaSize);
+ << this << "): not caching, ratio:" << ratio << ", "
+ << bitmap.GetSize() << "->" << targetSize << " in "
+ << drawAreaSize);
return image;
}
}