summaryrefslogtreecommitdiff
path: root/core/fxge/skia
diff options
context:
space:
mode:
authorcaryclark <caryclark@google.com>2016-05-26 14:17:39 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-26 14:17:39 -0700
commit6a9b494553a0e5547ad1f59f54ec6147a1c0fa79 (patch)
tree6082f20b8757fd4f0c6c43aa91606a18aef79668 /core/fxge/skia
parent5c4dd35a1ea2ba25839c8dabb4388a5dfc811165 (diff)
downloadpdfium-6a9b494553a0e5547ad1f59f54ec6147a1c0fa79.tar.xz
skia: add bitmap color table support
Fix 2/4/8 bits per pixel bitmaps that PDFium transposes into 8 bpp indexed. R=tsepez@chromium.org,dsinclair@chromium.org,reed@google.com Review-Url: https://codereview.chromium.org/2011153002
Diffstat (limited to 'core/fxge/skia')
-rw-r--r--core/fxge/skia/fx_skia_device.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index c4ca6f9223..e64dfd0a73 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -994,7 +994,10 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
int alpha_flag,
void* pIccTransform,
int blend_type) {
- SkColorType colorType;
+ SkColorType colorType = pSource->IsAlphaMask()
+ ? SkColorType::kAlpha_8_SkColorType
+ : SkColorType::kGray_8_SkColorType;
+ SkColorTable* ct = nullptr;
void* buffer = pSource->GetBuffer();
std::unique_ptr<uint8_t, FxFreeDeleter> dst8Storage;
std::unique_ptr<uint32_t, FxFreeDeleter> dst32Storage;
@@ -1014,11 +1017,12 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
}
buffer = dst8Storage.get();
rowBytes = width;
- colorType = pSource->IsAlphaMask() ? SkColorType::kAlpha_8_SkColorType
- : SkColorType::kGray_8_SkColorType;
} break;
case 8:
- colorType = SkColorType::kGray_8_SkColorType;
+ if (pSource->GetPalette()) {
+ ct = new SkColorTable(pSource->GetPalette(), pSource->GetPaletteSize());
+ colorType = SkColorType::kIndex_8_SkColorType;
+ }
break;
case 24: {
dst32Storage.reset(FX_Alloc2D(uint32_t, width, height));
@@ -1045,9 +1049,7 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
width, height, colorType,
pSource->IsAlphaMask() ? kPremul_SkAlphaType : kOpaque_SkAlphaType);
SkBitmap skBitmap;
- skBitmap.installPixels(imageInfo, buffer, rowBytes,
- nullptr, /* TODO(caryclark) : set color table */
- nullptr, nullptr);
+ skBitmap.installPixels(imageInfo, buffer, rowBytes, ct, nullptr, nullptr);
m_pCanvas->save();
SkMatrix skMatrix;
const CFX_Matrix& m = *pMatrix;
@@ -1065,6 +1067,8 @@ FX_BOOL CFX_SkiaDeviceDriver::StartDIBits(const CFX_DIBSource* pSource,
paint.setAlpha(bitmap_alpha);
m_pCanvas->drawBitmap(skBitmap, 0, 0, &paint);
m_pCanvas->restore();
+ if (ct)
+ ct->unref();
return TRUE;
}