From 96007832dd3d800ca781c9ef12904b178adb61f1 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Mon, 15 Mar 2021 16:56:07 +0100 Subject: don't repeatedly create (alpha)SkImage on mEraseColorSet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Iac42ead2bfd5a2b7f245cc44634f675a559d86ee Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112543 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/inc/skia/utils.hxx | 2 ++ vcl/skia/salbmp.cxx | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'vcl') 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 makeCheckedImageSnapshot(sk_sp surface); VCL_DLLPUBLIC sk_sp makeCheckedImageSnapshot(sk_sp surface, const SkIRect& bounds); +inline Size imageSize(const sk_sp& 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& SkiaSalBitmap::GetSkImage() const #endif if (mEraseColorSet) { + if (mImage) + { + assert(imageSize(mImage) == mSize); + return mImage; + } SkiaZone zone; sk_sp surface = createSkSurface( mSize, mEraseColor.IsTransparent() ? kPremul_SkAlphaType : kOpaque_SkAlphaType); @@ -801,6 +806,11 @@ const sk_sp& SkiaSalBitmap::GetAlphaSkImage() const #endif if (mEraseColorSet) { + if (mAlphaImage) + { + assert(imageSize(mAlphaImage) == mSize); + return mAlphaImage; + } SkiaZone zone; sk_sp surface = createSkSurface(mSize, kAlpha_8_SkColorType); assert(surface); -- cgit