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

Unified Diff: dm/DMSrcSink.cpp

Issue 1997703003: Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Line length and fix comment 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 | fuzz/fuzz.cpp » ('j') | include/codec/SkCodec.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dm/DMSrcSink.cpp
diff --git a/dm/DMSrcSink.cpp b/dm/DMSrcSink.cpp
index 18ac6b420a70a0661af55c7a2a3fb15255072ea1..91b4990528f4c10939f35fb029994b02994167c1 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -434,32 +434,46 @@ 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,
+ bitmap.getPixels(), bitmap.rowBytes(), nullptr, colorPtr, colorCountPtr)) {
+ return "Could not start incremental decode";
+ }
+ int rowsDecoded;
+ if (SkCodec::kIncompleteInput == codec->incrementalDecode(&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;
}
}
« no previous file with comments | « no previous file | fuzz/fuzz.cpp » ('j') | include/codec/SkCodec.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698