summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--external/skia/UnpackedTarball_skia.mk1
-rw-r--r--external/skia/extend-rgb-to-rgba.patch.023
-rw-r--r--vcl/skia/salbmp.cxx29
3 files changed, 43 insertions, 10 deletions
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk
index 99344871cb9d..da0a2a7a0547 100644
--- a/external/skia/UnpackedTarball_skia.mk
+++ b/external/skia/UnpackedTarball_skia.mk
@@ -32,6 +32,7 @@ skia_patches := \
windows-force-unicode-api.patch.0 \
operator-eq-bool.patch.0 \
fix-without-gl.patch.0 \
+ extend-rgb-to-rgba.patch.0 \
$(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1))
diff --git a/external/skia/extend-rgb-to-rgba.patch.0 b/external/skia/extend-rgb-to-rgba.patch.0
new file mode 100644
index 000000000000..f68dbab96336
--- /dev/null
+++ b/external/skia/extend-rgb-to-rgba.patch.0
@@ -0,0 +1,23 @@
+diff --git a/include/core/SkSwizzle.h b/include/core/SkSwizzle.h
+index 61e93b2da7..c19063bb91 100644
+--- ./include/core/SkSwizzle.h
++++ ./include/core/SkSwizzle.h
+@@ -16,4 +16,6 @@
+ */
+ 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);
++
+ #endif
+diff --git a/src/core/SkSwizzle.cpp b/src/core/SkSwizzle.cpp
+index 301b0184f1..6e6dd27558 100644
+--- ./src/core/SkSwizzle.cpp
++++ ./src/core/SkSwizzle.cpp
+@@ -12,3 +12,7 @@
+ void SkSwapRB(uint32_t* dest, const uint32_t* src, int count) {
+ SkOpts::RGBA_to_BGRA(dest, src, count);
+ }
++
++void SkExtendRGBToRGBA(uint32_t* dest, const uint8_t* src, int count) {
++ SkOpts::RGB_to_RGB1(dest, src, count);
++}
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index f0bffb500194..c000b391eaa2 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -32,6 +32,7 @@
#include <SkImage.h>
#include <SkPixelRef.h>
#include <SkSurface.h>
+#include <SkSwizzle.h>
#include <skia/utils.hxx>
#include <skia/zone.hxx>
@@ -387,19 +388,16 @@ SkBitmap SkiaSalBitmap::GetAsSkBitmap() const
else if (mBitCount == 24)
{
// Convert 24bpp RGB/BGR to 32bpp RGBA/BGRA.
- std::unique_ptr<sal_uInt8[]> data(
- new sal_uInt8[mPixelsSize.Height() * mPixelsSize.Width() * 4]);
- sal_uInt8* dest = data.get();
+ 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;
- for (long x = 0; x < mPixelsSize.Width(); ++x)
- {
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = *src++;
- *dest++ = 0xff;
- }
+ // This also works as BGR to BGRA (the function extends 3 bytes to 4
+ // by adding 0xFF alpha, so position of B and R doesn't matter).
+ SkExtendRGBToRGBA(dest, src, mPixelsSize.Width());
+ dest += mPixelsSize.Width();
}
if (!bitmap.installPixels(
SkImageInfo::MakeS32(mPixelsSize.Width(), mPixelsSize.Height(),
@@ -647,6 +645,17 @@ void SkiaSalBitmap::EnsureBitmapData()
}
}
}
+ else if (mBitCount == 8 && mPalette.IsGreyPalette())
+ {
+ for (long y = 0; y < mSize.Height(); ++y)
+ {
+ const uint8_t* src = static_cast<uint8_t*>(mBitmap.getAddr(0, y));
+ sal_uInt8* dest = mBuffer.get() + mScanlineSize * y;
+ // no actual data conversion, use one color channel as the gray value
+ for (long x = 0; x < mSize.Width(); ++x)
+ dest[x] = src[x * 4];
+ }
+ }
else
{
std::unique_ptr<vcl::ScanlineWriter> pWriter