Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2965)

Unified Diff: core/fxge/skia/fx_skia_device.cpp

Issue 2011153002: skia: add bitmap color table support (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fxge/skia/fx_skia_device.cpp
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 6646eedd0fb7328cc4b2f6bd5c2eca366b2dc3ab..9f8f6c902158e545554c47d07f3ce58f33b829ae 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698