vcl/skia/salbmp.cxx | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-)
New commits: commit ac867fa7541c27319ae271357f20d5d4d6bc6544 Author: Luboš Luňák <[email protected]> AuthorDate: Thu Dec 19 20:17:42 2019 +0100 Commit: Luboš Luňák <[email protected]> CommitDate: Mon Jan 6 11:12:59 2020 +0100 use Skia-based bitmap scaling for SkiaSalBitmap It should be done on GPU if Vulkan is used. Change-Id: I347169af2c3a5c78bd221e986cff9ed656ce93df Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85544 Tested-by: Jenkins Reviewed-by: Luboš Luňák <[email protected]> diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 781d6f87c9ad..9f81965de88d 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -320,15 +320,48 @@ bool SkiaSalBitmap::GetSystemData(BitmapSystemData&) return false; } -bool SkiaSalBitmap::ScalingSupported() const { return false; } +bool SkiaSalBitmap::ScalingSupported() const { return true; } -bool SkiaSalBitmap::Scale(const double&, const double&, BmpScaleFlag) +bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag) { #ifdef DBG_UTIL assert(mWriteAccessCount == 0); #endif - // TODO? - return false; + Size newSize(FRound(mSize.Width() * rScaleX), FRound(mSize.Height() * rScaleY)); + if (mSize == newSize) + return true; + + SAL_INFO("vcl.skia", "scale(" << this << "): " << mSize << "->" << newSize << ":" + << static_cast<int>(nScaleFlag)); + + SkPaint paint; + switch (nScaleFlag) + { + case BmpScaleFlag::Fast: + paint.setFilterQuality(kNone_SkFilterQuality); + break; + case BmpScaleFlag::Default: + paint.setFilterQuality(kMedium_SkFilterQuality); + break; + case BmpScaleFlag::BestQuality: + paint.setFilterQuality(kHigh_SkFilterQuality); + break; + default: + return false; + } + sk_sp<SkSurface> surface = SkiaHelper::createSkSurface(newSize); + assert(surface); + paint.setBlendMode(SkBlendMode::kSrc); // draw as is, including alpha + surface->getCanvas()->drawImageRect( + GetSkImage(), SkRect::MakeXYWH(0, 0, mSize.Width(), mSize.Height()), + SkRect::MakeXYWH(0, 0, newSize.Width(), newSize.Height()), &paint); + // This will get generated from mImage if needed. + mBitmap.reset(); + mBuffer.reset(); + ResetSkImages(); + mImage = surface->makeImageSnapshot(); + mSize = newSize; + return true; } bool SkiaSalBitmap::Replace(const Color&, const Color&, sal_uInt8) _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
