[Libreoffice-commits] core.git: vcl/inc vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Mon Sep 7 13:20:39 UTC 2020


 vcl/inc/skia/utils.hxx  |    1 +
 vcl/skia/SkiaHelper.cxx |    5 ++---
 vcl/skia/gdiimpl.cxx    |    3 +++
 3 files changed, 6 insertions(+), 3 deletions(-)

New commits:
commit a8a7df6de6b48a03589ac9b66b490875eab19b75
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Sat Sep 5 09:10:40 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Mon Sep 7 15:19:55 2020 +0200

    increase Skia image cache size to 64MiB (tdf#136244)
    
    16MiB was enough to hold just one 2000x2000 image, which is almost
    the usual screen size.
    
    Change-Id: I8fd02101cd2a18ddb89500d555d5c2f051fdb81f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102069
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lunak at collabora.com>

diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index 8a104e066090..fc2567ac4e32 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -56,6 +56,7 @@ VCL_DLLPUBLIC void
 void addCachedImage(const OString& key, sk_sp<SkImage> image);
 sk_sp<SkImage> findCachedImage(const OString& key);
 void removeCachedImage(sk_sp<SkImage> image);
+constexpr int MAX_CACHE_SIZE = 4 * 2000 * 2000 * 4; // 4x 2000px 32bpp images, 64MiB
 
 #ifdef DBG_UTIL
 void prefillSurface(sk_sp<SkSurface>& surface);
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index de0fd94be79c..8ba1e06f2463 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -472,13 +472,12 @@ void addCachedImage(const OString& key, sk_sp<SkImage> image)
     imageCache->push_front({ key, image, size });
     imageCacheSize += size;
     SAL_INFO("vcl.skia.trace", "addcachedimage " << image << " :" << size << "/" << imageCacheSize);
-    const int MAX_CACHE_SIZE = 4 * 1000 * 1000 * 4; // 4x 1000px 32bpp images, 16MiB
     while (imageCacheSize > MAX_CACHE_SIZE)
     {
         assert(!imageCache->empty());
         imageCacheSize -= imageCache->back().size;
-        SAL_INFO("vcl.skia.trace",
-                 "least used removal " << image << ":" << imageCache->back().size);
+        SAL_INFO("vcl.skia.trace", "least used removal " << imageCache->back().image << ":"
+                                                         << imageCache->back().size);
         imageCache->pop_back();
     }
 }
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index 652fea88f38e..f5374b773028 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1436,6 +1436,9 @@ sk_sp<SkImage> SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
             return image;
         }
     }
+    // Do not cache the result if it would take most of the cache and thus get evicted soon.
+    if (targetSize.Width() * targetSize.Height() * 4 > SkiaHelper::MAX_CACHE_SIZE * 0.7)
+        return image;
     OString key;
     OStringBuffer keyBuf;
     keyBuf.append(targetSize.Width())


More information about the Libreoffice-commits mailing list