| Index: dm/DMSrcSink.cpp
|
| diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
|
| index 18ac6b420a70a0661af55c7a2a3fb15255072ea1..67cc3edff2fb2bc2c7523d1319c29a090fec41bc 100644
|
| --- a/dm/DMSrcSink.cpp
|
| +++ b/dm/DMSrcSink.cpp
|
| @@ -434,32 +434,49 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
|
| break;
|
| }
|
| case kScanline_Mode: {
|
| - if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
|
| - colorCountPtr)) {
|
| - return "Could not start scanline decoder";
|
| - }
|
| + const bool supportsNewScanlineDecoding = fPath.endsWith("png");
|
| + if (supportsNewScanlineDecoding) {
|
| + if (SkCodec::kSuccess != codec->startIncrementalDecode(decodeInfo,
|
| + nullptr, colorPtr, colorCountPtr)) {
|
| + return "Could not start incremental decode";
|
| + }
|
| + int rowsDecoded;
|
| + if (SkCodec::kIncompleteInput == codec->incrementalDecode(
|
| + [&bitmap](int rowNum) -> void* {
|
| + return bitmap.getAddr(0, rowNum);
|
| + }, &rowsDecoded)) {
|
| + codec->fillIncompleteImage(decodeInfo, bitmap.getPixels(), bitmap.rowBytes(),
|
| + SkCodec::kNo_ZeroInitialized, decodeInfo.height(),
|
| + rowsDecoded);
|
| + }
|
|
|
| - void* dst = bitmap.getAddr(0, 0);
|
| - size_t rowBytes = bitmap.rowBytes();
|
| - uint32_t height = decodeInfo.height();
|
| - switch (codec->getScanlineOrder()) {
|
| - case SkCodec::kTopDown_SkScanlineOrder:
|
| - case SkCodec::kBottomUp_SkScanlineOrder:
|
| - case SkCodec::kNone_SkScanlineOrder:
|
| - // We do not need to check the return value. On an incomplete
|
| - // image, memory will be filled with a default value.
|
| - codec->getScanlines(dst, height, rowBytes);
|
| - break;
|
| - case SkCodec::kOutOfOrder_SkScanlineOrder: {
|
| - for (int y = 0; y < decodeInfo.height(); y++) {
|
| - int dstY = codec->outputScanline(y);
|
| - void* dstPtr = bitmap.getAddr(0, dstY);
|
| - // We complete the loop, even if this call begins to fail
|
| - // due to an incomplete image. This ensures any uninitialized
|
| - // memory will be filled with the proper value.
|
| - codec->getScanlines(dstPtr, 1, bitmap.rowBytes());
|
| + } else {
|
| + if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
|
| + colorCountPtr)) {
|
| + return "Could not start scanline decoder";
|
| + }
|
| +
|
| + void* dst = bitmap.getAddr(0, 0);
|
| + size_t rowBytes = bitmap.rowBytes();
|
| + uint32_t height = decodeInfo.height();
|
| + switch (codec->getScanlineOrder()) {
|
| + case SkCodec::kTopDown_SkScanlineOrder:
|
| + case SkCodec::kBottomUp_SkScanlineOrder:
|
| + // We do not need to check the return value. On an incomplete
|
| + // image, memory will be filled with a default value.
|
| + codec->getScanlines(dst, height, rowBytes);
|
| + break;
|
| + case SkCodec::kOutOfOrder_SkScanlineOrder: {
|
| + for (int y = 0; y < decodeInfo.height(); y++) {
|
| + int dstY = codec->outputScanline(y);
|
| + void* dstPtr = bitmap.getAddr(0, dstY);
|
| + // We complete the loop, even if this call begins to fail
|
| + // due to an incomplete image. This ensures any uninitialized
|
| + // memory will be filled with the proper value.
|
| + codec->getScanlines(dstPtr, 1, bitmap.rowBytes());
|
| + }
|
| + break;
|
| }
|
| - break;
|
| }
|
| }
|
|
|
|
|