[Libreoffice-commits] core.git: vcl/inc vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Mar 16 11:56:16 UTC 2021
vcl/inc/skia/utils.hxx | 2 ++
vcl/skia/salbmp.cxx | 10 ++++++++++
2 files changed, 12 insertions(+)
New commits:
commit 96007832dd3d800ca781c9ef12904b178adb61f1
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon Mar 15 16:56:07 2021 +0100
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Mar 16 12:55:33 2021 +0100
don't repeatedly create (alpha)SkImage on mEraseColorSet
Change-Id: Iac42ead2bfd5a2b7f245cc44634f675a559d86ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112543
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/vcl/inc/skia/utils.hxx b/vcl/inc/skia/utils.hxx
index 3baa749adb8b..716bd3e2471c 100644
--- a/vcl/inc/skia/utils.hxx
+++ b/vcl/inc/skia/utils.hxx
@@ -67,6 +67,8 @@ VCL_DLLPUBLIC sk_sp<SkImage> makeCheckedImageSnapshot(sk_sp<SkSurface> surface);
VCL_DLLPUBLIC sk_sp<SkImage> makeCheckedImageSnapshot(sk_sp<SkSurface> surface,
const SkIRect& bounds);
+inline Size imageSize(const sk_sp<SkImage>& image) { return Size(image->width(), image->height()); }
+
// Must be called in any VCL backend before any Skia functionality is used.
// If not set, Skia will be disabled.
VCL_DLLPUBLIC void
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 0fa95deb39db..83dd16950eaa 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -730,6 +730,11 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetSkImage() const
#endif
if (mEraseColorSet)
{
+ if (mImage)
+ {
+ assert(imageSize(mImage) == mSize);
+ return mImage;
+ }
SkiaZone zone;
sk_sp<SkSurface> surface = createSkSurface(
mSize, mEraseColor.IsTransparent() ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
@@ -801,6 +806,11 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetAlphaSkImage() const
#endif
if (mEraseColorSet)
{
+ if (mAlphaImage)
+ {
+ assert(imageSize(mAlphaImage) == mSize);
+ return mAlphaImage;
+ }
SkiaZone zone;
sk_sp<SkSurface> surface = createSkSurface(mSize, kAlpha_8_SkColorType);
assert(surface);
More information about the Libreoffice-commits
mailing list