summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-09-24 12:56:46 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-09-25 09:51:16 +0200
commitb5e023a7ef21c2ce546035b99ead7caf4e9b5343 (patch)
tree0ca5465b80769b3043441834e546ccad169bdddd /vcl
parent0ddcdaf289aa2e3d986811b6289b11880284602e (diff)
simplify clearing all data in SkiaSalBitmap
Change-Id: I5e53b70bca651493a5bf449ca41a568e2a72b683 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103304 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/skia/salbmp.hxx2
-rw-r--r--vcl/skia/salbmp.cxx19
2 files changed, 14 insertions, 7 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index 6e325b9c6a62..0f1a8b235164 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -93,6 +93,8 @@ private:
void ResetToSkImage(sk_sp<SkImage> image);
// Resets all data that does not match mSize.
void ResetCachedDataBySize();
+ // Resets all data (buffer and images).
+ void ResetAllData();
// Call to ensure mBuffer has data (will convert from mImage if necessary).
void EnsureBitmapData();
void EnsureBitmapData() const { return const_cast<SkiaSalBitmap*>(this)->EnsureBitmapData(); }
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 379f53bb032d..2128511247bc 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -62,8 +62,7 @@ static bool isValidBitCount(sal_uInt16 nBitCount)
SkiaSalBitmap::SkiaSalBitmap(const sk_sp<SkImage>& image)
{
- ResetCachedData();
- mBuffer.reset();
+ ResetAllData();
mImage = image;
mPalette = BitmapPalette();
mBitCount = 32;
@@ -77,7 +76,7 @@ SkiaSalBitmap::SkiaSalBitmap(const sk_sp<SkImage>& image)
bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal)
{
- ResetCachedData();
+ ResetAllData();
mBuffer.reset();
if (!isValidBitCount(nBitCount))
return false;
@@ -190,8 +189,7 @@ void SkiaSalBitmap::Destroy()
#ifdef DBG_UTIL
assert(mWriteAccessCount == 0);
#endif
- ResetCachedData();
- mBuffer.reset();
+ ResetAllData();
}
Size SkiaSalBitmap::GetSize() const { return mSize; }
@@ -441,8 +439,7 @@ bool SkiaSalBitmap::Erase(const Color& color)
// Optimized variant, just remember the color and apply it when needed,
// which may save having to do format conversions (e.g. GetSkImage()
// may directly erase the SkImage).
- ResetCachedData();
- mBuffer.reset();
+ ResetAllData();
mEraseColorSet = true;
mEraseColor = color;
return true;
@@ -1069,6 +1066,14 @@ void SkiaSalBitmap::ResetToSkImage(sk_sp<SkImage> image)
mAlphaImage.reset();
}
+void SkiaSalBitmap::ResetAllData()
+{
+ SkiaZone zone;
+ mBuffer.reset();
+ mImage.reset();
+ mAlphaImage.reset();
+}
+
void SkiaSalBitmap::ResetCachedDataBySize()
{
SkiaZone zone;