diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-05-04 17:50:13 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-05-05 10:00:21 +0200 |
commit | ef425f4e315d7afa79023d356cd05cc517d1f6b6 (patch) | |
tree | 42b22d9c89a08847e20c0dceb8c05f92be948d37 | |
parent | 017f90788c330d2e35a9c05a56b564d0ab4aafaf (diff) |
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@collabora.com>
-rw-r--r-- | vcl/skia/salbmp.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
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()) |