| Index: dm/DMSrcSink.cpp
|
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
|
| index 929ff0556b453de2a5786595fb107e69fdc4febe..0af1103c703667f2737cc01a2223f1b383888c12 100644
|
| --- a/dm/DMSrcSink.cpp
|
| +++ b/dm/DMSrcSink.cpp
|
| @@ -72,21 +72,36 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| return SkStringPrintf("Couldn't decode %s.", fPath.c_str());
|
| }
|
|
|
| + // Process the decode info to prepare for the decode
|
| SkImageInfo decodeInfo = codec->getInfo().makeColorType(canvasInfo.colorType());
|
| +
|
| + // Construct a color table for the decode if necessary
|
| + SkAutoTUnref<SkColorTable> colorTable(NULL);
|
| + SkPMColor* colorPtr = NULL;
|
| + int* colorCountPtr = NULL;
|
| + int maxColors = 256;
|
| + if (kIndex_8_SkColorType == decodeInfo.colorType()) {
|
| + SkPMColor colors[maxColors];
|
| + colorTable.reset(SkNEW_ARGS(SkColorTable, (colors, maxColors)));
|
| + colorPtr = const_cast<SkPMColor*>(colorTable->readColors());
|
| + colorCountPtr = &maxColors;
|
| + }
|
| +
|
| + // FIXME: Currently we cannot draw unpremultiplied sources.
|
| if (decodeInfo.alphaType() == kUnpremul_SkAlphaType) {
|
| - // FIXME: Currently we cannot draw unpremultiplied sources.
|
| decodeInfo = decodeInfo.makeAlphaType(kPremul_SkAlphaType);
|
| }
|
|
|
| SkBitmap bitmap;
|
| - if (!bitmap.tryAllocPixels(decodeInfo)) {
|
| + if (!bitmap.tryAllocPixels(decodeInfo, NULL, colorTable.get())) {
|
| return SkStringPrintf("Image(%s) is too large (%d x %d)\n", fPath.c_str(),
|
| decodeInfo.width(), decodeInfo.height());
|
| }
|
|
|
| switch (fMode) {
|
| case kNormal_Mode:
|
| - switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes())) {
|
| + switch (codec->getPixels(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(), NULL,
|
| + colorPtr, colorCountPtr)) {
|
| case SkImageGenerator::kSuccess:
|
| // We consider incomplete to be valid, since we should still decode what is
|
| // available.
|
|
|