[Libreoffice-commits] core.git: vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 5 08:00:59 UTC 2020
vcl/skia/salbmp.cxx | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
New commits:
commit ef425f4e315d7afa79023d356cd05cc517d1f6b6
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Mon May 4 17:50:13 2020 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue May 5 10:00:21 2020 +0200
avoid Skia CPU-based scaling if an image is wanted in the end
Change-Id: Ia08bc3824c9040e9601f4e4c3296e02b53ad5221
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93433
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 52808b38939e..fa88cac5ac87 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -488,6 +488,23 @@ const sk_sp<SkImage>& SkiaSalBitmap::GetSkImage() const
#ifdef DBG_UTIL
assert(mWriteAccessCount == 0);
#endif
+ if (mPixelsSize != mSize && !mImage
+ && SkiaHelper::renderMethodToUse() != SkiaHelper::RenderRaster)
+ {
+ // The bitmap has a pending scaling, but no image. This function would below call GetSkBitmap(),
+ // which would do CPU-based pixel scaling, and then it would get converted to an image.
+ // Be more efficient, first convert to an image and then the block below will scale on the GPU.
+ SAL_INFO("vcl.skia.trace", "getskimage(" << this << "): shortcut image scaling "
+ << mPixelsSize << "->" << mSize);
+ SkiaSalBitmap* thisPtr = const_cast<SkiaSalBitmap*>(this);
+ Size savedSize = mSize;
+ thisPtr->mSize = mPixelsSize; // block scaling
+ SkiaZone zone;
+ sk_sp<SkImage> image = SkiaHelper::createSkImage(GetAsSkBitmap());
+ assert(image);
+ thisPtr->mSize = savedSize;
+ thisPtr->ResetToSkImage(image);
+ }
if (mImage)
{
if (mImage->width() != mSize.Width() || mImage->height() != mSize.Height())
More information about the Libreoffice-commits
mailing list