diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-12-09 14:30:15 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-12-10 11:59:39 +0100 |
commit | 2c86b79e87bc8579f5213708954d5c85fe231407 (patch) | |
tree | 43c8f90345b09430eae88d7cce139138d3221e59 /vcl/inc/skia | |
parent | 110d3504c1f738a1d7f740cc212064dafa4fb224 (diff) |
cache Skia drawing based on checksum of bitmap content (tdf#146095)
Previously the caching was based on SkImage's uniqueID(), which
detects whether it's the same image. For caching to work based on
this it is required that the underlying image does not change,
which generally means using the same Bitmap(Ex) for repeated drawing.
But e.g. in tdf#146096 canvas (AFAICT) tries to cache bitmaps
by copying them around, which generates so many bitmaps that they all
do not fit in the cache (helped by the fact that the edit window
still animates them too, and bitmap caching in canvas being broken).
It feels kinda lame and unnecessary to checksum pixels of many bitmaps
to be drawn just to find out whether their drawing can be sped up,
and it really should be fixed higher up wherever it's broken, but
I've already failed several times trying to fix this in canvas,
so let's just roll with this.
This is done only for raster-based images, because GPU-backed drawing
is fast enough to deal even with expensive drawing (and fetching
GPU-backend pixels would be expensive).
On my machine this changes showing the slide from not being able
to quite keep up to about 20% CPU usage.
Change-Id: I25a362a02dc61e99b391cb305e2fdcd2feb67879
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126613
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc/skia')
-rw-r--r-- | vcl/inc/skia/utils.hxx | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx index 35180c016e24..d2d4c81c3f94 100644 --- a/vcl/inc/skia/utils.hxx +++ b/vcl/inc/skia/utils.hxx @@ -119,6 +119,10 @@ sk_sp<SkImage> findCachedImage(const OString& key); void removeCachedImage(sk_sp<SkImage> image); tools::Long maxImageCacheSize(); +// Get checksum of the image content, only for raster images. Is cached, +// but may still be somewhat expensive. +uint32_t getSkImageChecksum(sk_sp<SkImage> image); + // SkSurfaceProps to be used by all Skia surfaces. VCL_DLLPUBLIC const SkSurfaceProps* surfaceProps(); // Set pixel geometry to be used by SkSurfaceProps. |