diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-03-15 16:56:07 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-03-16 12:55:33 +0100 |
commit | 96007832dd3d800ca781c9ef12904b178adb61f1 (patch) | |
tree | c94cddbd81b580c9c2455e0ceb4796a47a8b9652 /vcl | |
parent | 98fbedf9e59ba5b6159abfbc85c05c00ceab5b90 (diff) |
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@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/skia/utils.hxx | 2 | ||||
-rw-r--r-- | vcl/skia/salbmp.cxx | 10 |
2 files changed, 12 insertions, 0 deletions
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); |