summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@collabora.com>2019-12-09 17:15:25 +0100
committerLuboš Luňák <l.lunak@collabora.com>2019-12-11 15:16:53 +0100
commit852bba5478f38edc68bec8d38fba7262474e82ea (patch)
treebdbfd71739cdeff7b73a68a982ca540485bdec2a /vcl
parent954bb75be3e78290fc944bd49015e047476df2d5 (diff)
do not store 8bpp bitmaps as Skia's SkBitmap (tdf#129077)
Skia does not support paletted images, so it only supports grayscale 8bpp. But whether a bitmap is grayscale depends on the palette, and that can change merely by assigning a different one. Change-Id: If55d31e46e79ef32f08ecd196ba7a6091d05a13f Reviewed-on: https://gerrit.libreoffice.org/84770 Tested-by: Jenkins Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/skia/salbmp.hxx4
-rw-r--r--vcl/skia/salbmp.cxx9
2 files changed, 5 insertions, 8 deletions
diff --git a/vcl/inc/skia/salbmp.hxx b/vcl/inc/skia/salbmp.hxx
index ea25d477c985..95eb338114cb 100644
--- a/vcl/inc/skia/salbmp.hxx
+++ b/vcl/inc/skia/salbmp.hxx
@@ -79,7 +79,7 @@ private:
template <typename charT, typename traits>
friend inline std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& stream, const SkiaSalBitmap* bitmap)
- { // TODO GPU-based, once it's done
+ {
// B - has SkBitmap, D - has data buffer, I/i - has SkImage (on GPU/CPU),
// A/a - has alpha SkImage (on GPU/CPU)
return stream << static_cast<const void*>(bitmap) << " " << bitmap->GetSize() << "/"
@@ -95,8 +95,6 @@ private:
BitmapPalette mPalette;
int mBitCount; // bpp
Size mSize;
- // Skia does not natively support 1bpp and 4bpp, so such bitmaps are stored
- // in a buffer (and converted to 32bpp SkBitmap on-demand using GetSkBitmap()).
std::unique_ptr<sal_uInt8[]> mBuffer;
int mScanlineSize; // size of one row in mBuffer
sk_sp<SkImage> mImage; // cached contents, possibly GPU-backed
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index d7fc3f6905c6..00dd47c85cbb 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -69,15 +69,14 @@ bool SkiaSalBitmap::Create(const Size& rSize, sal_uInt16 nBitCount, const Bitmap
return false;
// Skia only supports 8bit gray, 16bit and 32bit formats (e.g. 24bpp is actually stored as 32bpp).
// But some of our code accessing the bitmap assumes that when it asked for 24bpp, the format
- // really will be 24bpp (e.g. the png loader).
+ // really will be 24bpp (e.g. the png loader), so we cannot use SkBitmap to store the data.
+ // And even 8bpp is problematic, since Skia does not support palettes and a VCL bitmap can change
+ // its grayscale status simply by changing the palette.
+ // So basically use Skia only for 32bpp bitmaps.
// TODO what is the performance impact of handling 24bpp ourselves instead of in Skia?
SkColorType colorType = kUnknown_SkColorType;
switch (nBitCount)
{
- case 8:
- if (rPal.IsGreyPalette()) // see GetAlphaSkBitmap()
- colorType = kGray_8_SkColorType;
- break;
case 32:
colorType = kN32_SkColorType;
break;