[Libreoffice-commits] core.git: vcl/inc vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 24 14:07:20 UTC 2020
vcl/inc/skia/salbmp.hxx | 2 ++
vcl/skia/salbmp.cxx | 20 ++++++++++++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
New commits:
commit 31b00fe0f469c1bda8e523441e20f6e36bc17fd1
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Fri Apr 24 12:26:10 2020 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Fri Apr 24 16:06:45 2020 +0200
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 at collabora.com>
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
More information about the Libreoffice-commits
mailing list