diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-05-13 13:08:00 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-05-14 11:57:30 +0200 |
commit | fc0bff85f3338cb4fe8f4d42421cb69801cb3abb (patch) | |
tree | 331faaa9f3c83bab09c3a353900a0ad21b27c725 /vcl/inc/skia/utils.hxx | |
parent | 13a834c26d28f3cc08f106bf5ec1b71d4bc1f418 (diff) |
cache results of Skia's drawTransformedBitmap() (tdf#132438)
E.g. scrolling in Writer with a huge image inserted requires scaling
down on every paint, so cache the result if it's expensive.
Change-Id: I9db040eab47e0e9d7fd416ad064caf0301d346fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94118
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc/skia/utils.hxx')
-rw-r--r-- | vcl/inc/skia/utils.hxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx index 942b5c3b88ef..e0fcf70c30e7 100644 --- a/vcl/inc/skia/utils.hxx +++ b/vcl/inc/skia/utils.hxx @@ -52,6 +52,11 @@ VCL_DLLPUBLIC sk_sp<SkImage> createSkImage(const SkBitmap& bitmap); VCL_DLLPUBLIC void prepareSkia(std::unique_ptr<sk_app::WindowContext> (*createVulkanWindowContext)(bool)); +// Shared cache of images. +void addCachedImage(const OString& key, sk_sp<SkImage> image); +sk_sp<SkImage> findCachedImage(const OString& key); +void removeCachedImage(sk_sp<SkImage> image); + #ifdef DBG_UTIL void prefillSurface(sk_sp<SkSurface>& surface); VCL_DLLPUBLIC void dump(const SkBitmap& bitmap, const char* file); @@ -104,6 +109,22 @@ inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, t return stream; } +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const SkImage& image) +{ + // G - on GPU + return stream << static_cast<const void*>(&image) << " " << Size(image.width(), image.height()) + << "/" << (SkColorTypeBytesPerPixel(image.imageInfo().colorType()) * 8) + << (image.isTextureBacked() ? "G" : ""); +} +template <typename charT, typename traits> +inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& stream, + const sk_sp<SkImage>& image) +{ + return stream << *image; +} + #endif // INCLUDED_VCL_INC_SKIA_UTILS_H /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |