From 360d1fce569b57aa2c487f6e171ba19b9dc8885e Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Thu, 13 Jul 2017 09:53:13 -0400 Subject: Index_8 no longer supported, upscale to N32 This should unblock the skia-roller Bug:Skia:6828 Change-Id: Id918f017ed69bea9536eb1df8c31d43eac51d680 Reviewed-on: https://pdfium-review.googlesource.com/7730 Reviewed-by: dsinclair Reviewed-by: Cary Clark Commit-Queue: Cary Clark --- core/fxge/skia/fx_skia_device.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp index ad3b85c1fb..278b6d874f 100644 --- a/core/fxge/skia/fx_skia_device.cpp +++ b/core/fxge/skia/fx_skia_device.cpp @@ -599,10 +599,27 @@ bool Upsample(const CFX_RetainPtr& pSource, break; } case 8: + // we upscale ctables to 32bit. if (pSource->GetPalette()) { - *ctPtr = - new SkColorTable(pSource->GetPalette(), pSource->GetPaletteSize()); - colorType = SkColorType::kIndex_8_SkColorType; + dst32Storage.reset(FX_Alloc2D(uint32_t, width, height)); + SkPMColor* dst32Pixels = dst32Storage.get(); + const SkPMColor* ctable = pSource->GetPalette(); + const unsigned ctableSize = pSource->GetPaletteSize(); + for (int y = 0; y < height; ++y) { + const uint8_t* srcRow = + static_cast(buffer) + y * rowBytes; + uint32_t* dstRow = dst32Pixels + y * width; + for (int x = 0; x < width; ++x) { + unsigned index = srcRow[x]; + if (index >= ctableSize) { + index = 0; + } + dstRow[x] = ctable[index]; + } + } + buffer = dst32Storage.get(); + rowBytes = width * sizeof(uint32_t); + colorType = SkColorType::kN32_SkColorType; } break; case 24: { -- cgit v1.2.3