summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Common.xcs14
-rw-r--r--vcl/inc/skia/utils.hxx2
-rw-r--r--vcl/skia/SkiaHelper.cxx17
-rw-r--r--vcl/skia/gdiimpl.cxx2
4 files changed, 28 insertions, 7 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 2f961f0532a2..de96a9477b37 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -1589,6 +1589,20 @@
<value>10</value>
</prop>
</group>
+ <group oor:name="Skia">
+ <info>
+ <desc>Specifies a group of cache options related to Skia-based drawing.</desc>
+ </info>
+ <prop oor:name="ImageCacheSize" oor:type="xs:long" oor:nillable="false">
+ <info>
+ <desc>Specifies the maximum cache size in bytes for all images used by Skia-based
+ drawing code. Larger size may improve drawing performance when using
+ many large images in software rendering mode.</desc>
+ <label>Image Cache Size</label>
+ </info>
+ <value>64000000</value>
+ </prop>
+ </group>
</group>
<group oor:name="Path">
<!--OldLocation: soffice.ini -->
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index 03e01d2e5d8b..7da858ab1fff 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -73,7 +73,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
+tools::Long maxImageCacheSize();
// SkSurfaceProps to be used by all Skia surfaces.
VCL_DLLPUBLIC const SkSurfaceProps* surfaceProps();
diff --git a/vcl/skia/SkiaHelper.cxx b/vcl/skia/SkiaHelper.cxx
index b3aa5a1d1cbc..d545cc670bb5 100644
--- a/vcl/skia/SkiaHelper.cxx
+++ b/vcl/skia/SkiaHelper.cxx
@@ -485,7 +485,7 @@ struct ImageCacheItem
{
OString key;
sk_sp<SkImage> image;
- int size; // cost of the item
+ tools::Long size; // cost of the item
};
} //namespace
@@ -493,7 +493,7 @@ struct ImageCacheItem
// to require a hash/map. Using o3tl::lru_cache would be simpler, but it doesn't support
// calculating cost of each item.
static std::list<ImageCacheItem>* imageCache = nullptr;
-static int imageCacheSize = 0; // sum of all ImageCacheItem.size
+static tools::Long imageCacheSize = 0; // sum of all ImageCacheItem.size
void addCachedImage(const OString& key, sk_sp<SkImage> image)
{
@@ -502,12 +502,13 @@ void addCachedImage(const OString& key, sk_sp<SkImage> image)
return;
if (imageCache == nullptr)
imageCache = new std::list<ImageCacheItem>;
- int size = image->width() * image->height()
- * SkColorTypeBytesPerPixel(image->imageInfo().colorType());
+ tools::Long size = static_cast<tools::Long>(image->width()) * image->height()
+ * SkColorTypeBytesPerPixel(image->imageInfo().colorType());
imageCache->push_front({ key, image, size });
imageCacheSize += size;
SAL_INFO("vcl.skia.trace", "addcachedimage " << image << " :" << size << "/" << imageCacheSize);
- while (imageCacheSize > MAX_CACHE_SIZE)
+ const tools::Long maxSize = maxImageCacheSize();
+ while (imageCacheSize > maxSize)
{
assert(!imageCache->empty());
imageCacheSize -= imageCache->back().size;
@@ -554,6 +555,12 @@ void removeCachedImage(sk_sp<SkImage> image)
}
}
+tools::Long maxImageCacheSize()
+{
+ // Defaults to 4x 2000px 32bpp images, 64MiB.
+ return officecfg::Office::Common::Cache::Skia::ImageCacheSize::get();
+}
+
void cleanup()
{
delete sharedGrDirectContext;
diff --git a/vcl/skia/gdiimpl.cxx b/vcl/skia/gdiimpl.cxx
index ee2e72889152..773bdd2be1bf 100644
--- a/vcl/skia/gdiimpl.cxx
+++ b/vcl/skia/gdiimpl.cxx
@@ -1574,7 +1574,7 @@ sk_sp<SkImage> SkiaSalGraphicsImpl::mergeCacheBitmaps(const SkiaSalBitmap& bitma
}
}
// 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)
+ if (targetSize.Width() * targetSize.Height() * 4 > SkiaHelper::maxImageCacheSize() * 0.7)
return image;
OString key;
OStringBuffer keyBuf;