summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-04-24 12:26:10 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-04-24 16:06:45 +0200
commit31b00fe0f469c1bda8e523441e20f6e36bc17fd1 (patch)
tree785b898a016c589a9dbbdd7287130f1b2803d1e5 /vcl
parente0da00d655ecca5986eea3812a8a670c6adbc40f (diff)
make SkiaSalBitmap discard cached data of incorrect size (tdf#132367)
Performing the delayed scaling for the bitmap data could keep around cached mImage with a different size. Which theoretically could be kept around and resized later, but the bitmap data scaling finishes the delayed scaling by discarding all the data about it (scaling quality), so the later resizing wouldn't know how. Change-Id: I6a817d87becd44214f0f4db0755731b6e4ae1409 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92846 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.cxx20
2 files changed, 20 insertions, 2 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index cfdb9d3d2347..d13e765d63cd 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -76,6 +76,8 @@ private:
void ResetCachedData();
// Sets the data only as SkImage (will be converted as needed).
void ResetToSkImage(sk_sp<SkImage> image);
+ // Resets all data that does not match mSize.
+ void ResetCachedDataBySize();
// 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 1f91b5d90a86..52808b38939e 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -679,6 +679,9 @@ void SkiaSalBitmap::EnsureBitmapData()
<< static_cast<int>(mScaleQuality));
mPixelsSize = mSize;
mScaleQuality = kNone_SkFilterQuality;
+ // Information about the pending scaling has been discarded, so make sure we do not
+ // keep around any cached images would still need scaling.
+ ResetCachedDataBySize();
}
else
canvas.drawImage(mImage, 0, 0, &paint);
@@ -767,8 +770,8 @@ void SkiaSalBitmap::ResetCachedData()
// mBuffer from it if needed, in that case ResetToSkImage() should be used.
assert(mBuffer.get() || !mImage);
mBitmap.reset();
- mAlphaImage.reset();
mImage.reset();
+ mAlphaImage.reset();
}
void SkiaSalBitmap::ResetToSkImage(sk_sp<SkImage> image)
@@ -776,8 +779,21 @@ void SkiaSalBitmap::ResetToSkImage(sk_sp<SkImage> image)
SkiaZone zone;
mBuffer.reset();
mBitmap.reset();
- mAlphaImage.reset();
mImage = image;
+ mAlphaImage.reset();
+}
+
+void SkiaSalBitmap::ResetCachedDataBySize()
+{
+ SkiaZone zone;
+ assert(!mBitmap.isNull());
+ assert(mBitmap.width() == mSize.getWidth() && mBitmap.height() == mSize.getHeight());
+ assert(mSize == mPixelsSize);
+ if (mImage && (mImage->width() != mSize.getWidth() || mImage->height() != mSize.getHeight()))
+ mImage.reset();
+ if (mAlphaImage
+ && (mAlphaImage->width() != mSize.getWidth() || mAlphaImage->height() != mSize.getHeight()))
+ mAlphaImage.reset();
}
#ifdef DBG_UTIL