vcl/skia/salbmp.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
New commits: commit eb85e5bd28b9101c7c475c8e7a86ea61af85806f Author: Luboš Luňák <[email protected]> AuthorDate: Tue Jul 7 12:15:20 2020 +0000 Commit: Adolfo Jayme Barrientos <[email protected]> CommitDate: Wed Jul 8 22:16:35 2020 +0200 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 <[email protected]> (cherry picked from commit 3769d01791e54be0fbfc6d706596283213700ad0) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98330 Reviewed-by: Adolfo Jayme Barrientos <[email protected]> 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); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
