summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2020-06-27 09:39:56 +0200
committerLuboš Luňák <l.lunak@collabora.com>2020-06-27 10:43:54 +0200
commite318e4cea37f6adb20cffc913655c0e6dbabe45a (patch)
treee00082025b26717369b1f63108c6e849018a154d
parent0a890e9cbd2289475455db52c2481c5a50204f28 (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>
-rw-r--r--vcl/inc/skia/salbmp.hxx1
-rw-r--r--vcl/skia/salbmp.cxx54
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<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)