Chromium Code Reviews| Index: dm/DMSrcSink.cpp |
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp |
| index 929ff0556b453de2a5786595fb107e69fdc4febe..e614a1eef767956eb1e320af139bf4666b83089e 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()); |
| } |
| - SkImageInfo decodeInfo = codec->getInfo().makeColorType(canvasInfo.colorType()); |
|
scroggo
2015/04/02 19:20:30
By removing this, we no longer have a way to test
msarett
2015/04/03 18:01:31
Oh ok, I think I misunderstood this line. So if w
scroggo
2015/04/06 14:55:11
Essentially. This means to decode to the config of
|
| + // Process the decode info to prepare for the decode |
| + SkImageInfo decodeInfo = codec->getInfo(); |
| + |
| + // Construct a color table for the decode if necessary |
| + SkAutoTUnref<SkColorTable> colorTable(NULL); |
|
msarett
2015/04/02 17:26:29
I saw what you did for nanobench, but I decided to
scroggo
2015/04/02 19:20:30
This may be as good as anything. If you took my ap
|
| + 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. |