diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-06-27 09:39:56 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-07-02 12:47:05 +0200 |
commit | 0ac002ae306f67d5c26ac376caea628bcfb51bfa (patch) | |
tree | 07fb65becb1e60752ecfdb7f1540dba47bd6021d | |
parent | 98236f7265fb53ad7c59b7a4c2a580f1181de22f (diff) |
do not use VCL scaling algorithm from Skia
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 <l.lunak@collabora.com>
(cherry picked from commit 2a0c25020a145881a28a3e923b23747287b0d58b)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97294
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | vcl/inc/skia/salbmp.hxx | 1 | ||||
-rw-r--r-- | 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 0761217d4eb9..5079be08893a 100644 --- a/vcl/inc/skia/salbmp.hxx +++ b/vcl/inc/skia/salbmp.hxx @@ -124,7 +124,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 30afc7c51d58..2ea9bf60cd89 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -280,7 +280,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) { @@ -620,46 +620,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<SkiaSalBitmap> src = std::make_shared<SkiaSalBitmap>(); - 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<const SkiaSalBitmap*>(bitmap.ImplGetSalBitmap().get())); - const SkiaSalBitmap* dest - = static_cast<const SkiaSalBitmap*>(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<int>(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<int>(mScaleQuality)); + Size savedSize = mSize; + mSize = mPixelsSize; + ResetToSkImage(SkImage::MakeFromBitmap(GetAsSkBitmap())); + mSize = savedSize; } // Try to fill mBuffer from mImage. if (!mImage) |