[Libreoffice-commits] core.git: vcl/inc vcl/skia

Luboš Luňák (via logerrit) logerrit at kemper.freedesktop.org
Sat Jun 27 08:44:33 UTC 2020


 vcl/inc/skia/salbmp.hxx |    1 
 vcl/skia/salbmp.cxx     |   54 +++++++++++-------------------------------------
 2 files changed, 13 insertions(+), 42 deletions(-)

New commits:
commit e318e4cea37f6adb20cffc913655c0e6dbabe45a
Author:     Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Sat Jun 27 09:39:56 2020 +0200
Commit:     Luboš Luňák <l.lunak at collabora.com>
CommitDate: Sat Jun 27 10:43:54 2020 +0200

    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 at collabora.com>

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<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)


More information about the Libreoffice-commits mailing list