From e318e4cea37f6adb20cffc913655c0e6dbabe45a Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Sat, 27 Jun 2020 09:39:56 +0200 Subject: do not use VCL scaling algorithm from Skia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The only threaded one is "Super" (i.e. the default one), and Skia at a comparable quality seems to perform better. And the code is simpler too. Change-Id: I366197fe1a033c1f7a5f5c7f9fdcc00bff74dc11 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97278 Tested-by: Jenkins Reviewed-by: Luboš Luňák --- vcl/inc/skia/salbmp.hxx | 1 - vcl/skia/salbmp.cxx | 54 ++++++++++++------------------------------------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx index 2bd729683bde..d5491e367700 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -126,7 +126,6 @@ private: // data in mBuffer, if it differs from mSize, then there is a scaling operation pending. Size mPixelsSize; SkFilterQuality mScaleQuality = kHigh_SkFilterQuality; // quality for on-demand scaling - bool mDisableScale = false; // used to block our scale() #ifdef DBG_UTIL int mWriteAccessCount = 0; // number of write AcquireAccess() that have not been released #endif diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 428592f44808..2ac221fdba19 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -279,7 +279,7 @@ bool SkiaSalBitmap::GetSystemData(BitmapSystemData&) return false; } -bool SkiaSalBitmap::ScalingSupported() const { return !mDisableScale; } +bool SkiaSalBitmap::ScalingSupported() const { return true; } bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag) { @@ -618,46 +618,18 @@ void SkiaSalBitmap::EnsureBitmapData() { if (mBuffer) { - if (mSize != mPixelsSize) // pending scaling? - { - // This will be pixel->pixel scaling, use VCL algorithm, it should be faster than Skia - // (no need to possibly convert bpp, it's multithreaded,...). - std::shared_ptr src = std::make_shared(); - if (!src->Create(*this)) - abort(); - // force 'src' to use VCL's scaling - src->mDisableScale = true; - src->mSize = src->mPixelsSize; - Bitmap bitmap(src); - BmpScaleFlag scaleFlag; - switch (mScaleQuality) - { - case kNone_SkFilterQuality: - scaleFlag = BmpScaleFlag::Fast; - break; - case kMedium_SkFilterQuality: - scaleFlag = BmpScaleFlag::Default; - break; - case kHigh_SkFilterQuality: - scaleFlag = BmpScaleFlag::BestQuality; - break; - default: - abort(); - } - bitmap.Scale(mSize, scaleFlag); - assert(dynamic_cast(bitmap.ImplGetSalBitmap().get())); - const SkiaSalBitmap* dest - = static_cast(bitmap.ImplGetSalBitmap().get()); - assert(dest->mSize == dest->mPixelsSize); - assert(dest->mSize == mSize); - SAL_INFO("vcl.skia.trace", "ensurebitmapdata(" << this << "): pixels scaled " - << mPixelsSize << "->" << mSize << ":" - << static_cast(mScaleQuality)); - Destroy(); - Create(*dest); - mDisableScale = false; - } - return; + if (mSize == mPixelsSize) + return; + // Pending scaling. Create raster SkImage from the bitmap data + // at the pixel size and then the code below will scale at the correct + // bpp from the image. + SAL_INFO("vcl.skia.trace", "ensurebitmapdata(" << this << "): pixels to be scaled " + << mPixelsSize << "->" << mSize << ":" + << static_cast(mScaleQuality)); + Size savedSize = mSize; + mSize = mPixelsSize; + ResetToSkImage(SkImage::MakeFromBitmap(GetAsSkBitmap())); + mSize = savedSize; } // Try to fill mBuffer from mImage. if (!mImage) -- cgit v1.2.3