diff options
author | Luboš Luňák <l.lunak@centrum.cz> | 2020-07-07 12:15:20 +0000 |
---|---|---|
committer | Adolfo Jayme Barrientos <fitojb@ubuntu.com> | 2020-07-08 22:16:35 +0200 |
commit | eb85e5bd28b9101c7c475c8e7a86ea61af85806f (patch) | |
tree | 47d26dfb2f85f75fec9b9fcd72992656bd15ce55 /vcl | |
parent | a7cf0151eb8068d0aa418171a6acdaddfe8722e2 (diff) |
prevent SkiaSalBitmap::Scale() from breaking indexed bitmaps (tdf#134574)
Since the actual scaling is done later at some unknown time,
the palette mustn't change, but scaling can change colors.
Change-Id: Ie254c8b31993d9d509c32a730dd8c8b5d3cb2256
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98258
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
(cherry picked from commit 3769d01791e54be0fbfc6d706596283213700ad0)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98330
Reviewed-by: Adolfo Jayme Barrientos <fitojb@ubuntu.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/skia/salbmp.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx index 439baca41b6f..9b4e0b3324b4 100644 --- a/vcl/skia/salbmp.cxx +++ b/vcl/skia/salbmp.cxx @@ -293,8 +293,8 @@ bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScale if (mSize == newSize) return true; - SAL_INFO("vcl.skia.trace", "scale(" << this << "): " << mSize << "->" << newSize << ":" - << static_cast<int>(nScaleFlag)); + SAL_INFO("vcl.skia.trace", "scale(" << this << "): " << mSize << "/" << mBitCount << "->" + << newSize << ":" << static_cast<int>(nScaleFlag)); // The idea here is that the actual scaling will be delayed until the result // is actually needed. Usually the scaled bitmap will be drawn somewhere, @@ -316,8 +316,18 @@ bool SkiaSalBitmap::Scale(const double& rScaleX, const double& rScaleY, BmpScale currentQuality = kHigh_SkFilterQuality; break; default: + SAL_INFO("vcl.skia.trace", "scale(" << this << "): unsupported scale algorithm"); return false; } + if (mBitCount < 24 && !mPalette.IsGreyPalette8Bit()) + { + // Scaling can introduce additional colors not present in the original + // bitmap (e.g. when smoothing). If the bitmap is indexed (has non-trivial palette), + // this would break the bitmap, because the actual scaling is done only somewhen later. + // Linear 8bit palette (grey) is ok, since there we use directly the values as colors. + SAL_INFO("vcl.skia.trace", "scale(" << this << "): indexed bitmap"); + return false; + } // if there is already one scale() pending, use the lowest quality of all requested static_assert(kMedium_SkFilterQuality < kHigh_SkFilterQuality); mScaleQuality = std::min(mScaleQuality, currentQuality); |