[Libreoffice-commits] core.git: external/skia vcl/skia
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jun 30 06:04:29 UTC 2020
external/skia/extend-rgb-to-rgba.patch.0 | 14 ++++++++++----
vcl/skia/salbmp.cxx | 26 ++++++++++++++++++++++++--
2 files changed, 34 insertions(+), 6 deletions(-)
New commits:
commit 0059392fc723deb53350878f7b92474ba2d49870
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Sat Jun 27 15:15:41 2020 +0200
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Jun 30 08:03:46 2020 +0200
direct 8bit gray -> RGBA conversion in SkiaSalBitmap
Change-Id: Ic77f9b8f9244e7fdaca78f91686645eee421d18f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97288
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/external/skia/extend-rgb-to-rgba.patch.0 b/external/skia/extend-rgb-to-rgba.patch.0
index f68dbab96336..e0ce55fa2377 100644
--- a/external/skia/extend-rgb-to-rgba.patch.0
+++ b/external/skia/extend-rgb-to-rgba.patch.0
@@ -1,19 +1,21 @@
diff --git a/include/core/SkSwizzle.h b/include/core/SkSwizzle.h
-index 61e93b2da7..c19063bb91 100644
+index 61e93b2da7..9a26f0f492 100644
--- ./include/core/SkSwizzle.h
+++ ./include/core/SkSwizzle.h
-@@ -16,4 +16,6 @@
+@@ -16,4 +16,8 @@
*/
SK_API void SkSwapRB(uint32_t* dest, const uint32_t* src, int count);
+SK_API void SkExtendRGBToRGBA(uint32_t* dest, const uint8_t* src, int count);
++
++SK_API void SkExtendGrayToRGBA(uint32_t* dest, const uint8_t* src, int count);
+
#endif
diff --git a/src/core/SkSwizzle.cpp b/src/core/SkSwizzle.cpp
-index 301b0184f1..6e6dd27558 100644
+index 301b0184f1..382323695f 100644
--- ./src/core/SkSwizzle.cpp
+++ ./src/core/SkSwizzle.cpp
-@@ -12,3 +12,7 @@
+@@ -12,3 +12,11 @@
void SkSwapRB(uint32_t* dest, const uint32_t* src, int count) {
SkOpts::RGBA_to_BGRA(dest, src, count);
}
@@ -21,3 +23,7 @@ index 301b0184f1..6e6dd27558 100644
+void SkExtendRGBToRGBA(uint32_t* dest, const uint8_t* src, int count) {
+ SkOpts::RGB_to_RGB1(dest, src, count);
+}
++
++void SkExtendGrayToRGBA(uint32_t* dest, const uint8_t* src, int count) {
++ SkOpts::gray_to_RGB1(dest, src, count);
++}
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index 5a426fa6e404..91748f57552a 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -451,8 +451,29 @@ SkBitmap SkiaSalBitmap::GetAsSkBitmap() const
abort();
bitmap.setImmutable();
}
- // Skia has a format for 8bit grayscale SkBitmap, but it seems to cause a problem
- // with our PNG loader (tdf#121120), so convert it to RGBA below as well.
+ else if (mBitCount == 8 && mPalette.IsGreyPalette8Bit())
+ {
+ // Convert 8bpp gray to 32bpp RGBA/BGRA.
+ // There's also kGray_8_SkColorType, but it's probably simpler to make
+ // GetAsSkBitmap() always return 32bpp SkBitmap and then assume mImage
+ // is always 32bpp too.
+ std::unique_ptr<uint32_t[]> data(
+ new uint32_t[mPixelsSize.Height() * mPixelsSize.Width()]);
+ uint32_t* dest = data.get();
+ for (long y = 0; y < mPixelsSize.Height(); ++y)
+ {
+ const sal_uInt8* src = mBuffer.get() + mScanlineSize * y;
+ SkExtendGrayToRGBA(dest, src, mPixelsSize.Width());
+ dest += mPixelsSize.Width();
+ }
+ if (!bitmap.installPixels(
+ SkImageInfo::MakeS32(mPixelsSize.Width(), mPixelsSize.Height(),
+ kOpaque_SkAlphaType),
+ data.release(), mPixelsSize.Width() * 4,
+ [](void* addr, void*) { delete[] static_cast<sal_uInt8*>(addr); }, nullptr))
+ abort();
+ bitmap.setImmutable();
+ }
else
{
// Use a macro to hide an unreachable code warning.
@@ -634,6 +655,7 @@ void SkiaSalBitmap::EnsureBitmapData()
// Try to fill mBuffer from mImage.
if (!mImage)
return;
+ assert(mImage->colorType() == kN32_SkColorType);
SkiaZone zone;
if (!CreateBitmapData())
abort();
More information about the Libreoffice-commits
mailing list