diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2019-12-19 12:54:39 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-01-06 11:12:37 +0100 |
commit | 7702efe9ec6bbc428d89e83d957677cd3d323803 (patch) | |
tree | d19f05674c63ac1636d42165466cecaaeae7c9b3 /vcl/inc | |
parent | aab9dafdae868b9e55c143cdc08598895f19f63d (diff) |
use copy-on-write for SkiaSalBitmap data
E.g. scaling works by first making a copy using Create() and then
Scale() is called for the copy. This means there was a needless
data copy for mBuffer in Create(). Also make sure SkBitmap is properly
unshared if needed, as it seems copies of it always share the pixels.
Change-Id: I30a758c84e7218e9afe516477aa8429364ef8607
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85543
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/skia/salbmp.hxx | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index a0fa2d900c78..78b864104a2c 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -74,6 +74,9 @@ private: // if necessary). void EnsureBitmapData(); void EnsureBitmapData() const { return const_cast<SkiaSalBitmap*>(this)->EnsureBitmapData(); } + // Like EnsureBitmapData(), but will also make any shared data unique. + // Call before changing the data. + void EnsureBitmapUniqueData(); // Allocate mBitmap or mBuffer (with uninitialized contents). bool CreateBitmapData(); SkBitmap GetAsSkBitmap() const; @@ -90,7 +93,7 @@ private: // B - has SkBitmap, D - has data buffer, I/i - has SkImage (on GPU/CPU), // A/a - has alpha SkImage (on GPU/CPU) return stream << static_cast<const void*>(bitmap) << " " << bitmap->GetSize() << "/" - << bitmap->mBitCount << (!bitmap->mBitmap.drawsNothing() ? "B" : "") + << bitmap->mBitCount << (!bitmap->mBitmap.isNull() ? "B" : "") << (bitmap->mBuffer.get() ? "D" : "") << (bitmap->mImage ? (bitmap->mImage->isTextureBacked() ? "I" : "i") : "") << (bitmap->mAlphaImage ? (bitmap->mAlphaImage->isTextureBacked() ? "A" : "a") @@ -111,7 +114,7 @@ private: // mBitmap/mBuffer must be filled from it on demand if necessary by EnsureBitmapData(). SkBitmap mBitmap; sk_sp<SkImage> mImage; // possibly GPU-backed - std::unique_ptr<sal_uInt8[]> mBuffer; + std::shared_ptr<sal_uInt8[]> mBuffer; int mScanlineSize; // size of one row in mBuffer sk_sp<SkImage> mAlphaImage; // cached contents as alpha image, possibly GPU-backed #ifdef DBG_UTIL |