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

Unified Diff: dm/DMSrcSink.cpp

Issue 1530933003: Use possible read_partial_scanlines() API in SkJpegCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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 | « dm/DM.cpp ('k') | gyp/libjpeg-turbo.gyp » ('j') | src/codec/SkJpegCodec.cpp » ('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 e27628ad043aeedc9676dfd1a00187c843ad2fa8..1ee838e6c753fb29b4effbfbf4dab45a28750458 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -373,6 +373,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
break;
}
case kStripe_Mode: {
+ const int width = decodeInfo.width();
const int height = decodeInfo.height();
// This value is chosen arbitrarily. We exercise more cases by choosing a value that
// does not align with image blocks.
@@ -380,7 +381,10 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
const int numStripes = (height + stripeHeight - 1) / stripeHeight;
// Decode odd stripes
- if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
+ SkCodec::Options opts;
+ SkIRect subset = SkIRect::MakeXYWH(0, 0, width / 2, height);
+ opts.fSubset = ⊂
+ if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opts, colorPtr,
colorCountPtr)
|| SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
// This mode was designed to test the new skip scanlines API in libjpeg-turbo.
@@ -403,7 +407,7 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
}
// Decode even stripes
- const SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo, nullptr,
+ SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo, &opts,
colorPtr, colorCountPtr);
if (SkCodec::kSuccess != startResult) {
return "Failed to restart scanline decoder with same parameters.";
@@ -420,6 +424,48 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
codec->skipScanlines(linesToSkip);
}
}
+
+ // Begin duplicated code
+ SkIRect nextSubset = SkIRect::MakeXYWH(width / 2, 0, width / 2 + width % 2, height);
+ opts.fSubset = &nextSubset;
+ startResult = codec->startScanlineDecode(decodeInfo, &opts, colorPtr, colorCountPtr);
+ if (SkCodec::kSuccess != startResult) {
+ return "Failed to restart scanline decoder with same parameters.";
+ }
+
+ for (int i = 0; i < numStripes; i += 2) {
+ // Skip a stripe
+ const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
+ codec->skipScanlines(linesToSkip);
+
+ // Read a stripe
+ const int startY = (i + 1) * stripeHeight;
+ const int linesToRead = SkTMin(stripeHeight, height - startY);
+ if (linesToRead > 0) {
+ codec->getScanlines(bitmap.getAddr(width / 2, startY), linesToRead,
+ bitmap.rowBytes());
+ }
+ }
+
+ // Decode even stripes
+ startResult = codec->startScanlineDecode(decodeInfo, &opts, colorPtr, colorCountPtr);
+ if (SkCodec::kSuccess != startResult) {
+ return "Failed to restart scanline decoder with same parameters.";
+ }
+ for (int i = 0; i < numStripes; i += 2) {
+ // Read a stripe
+ const int startY = i * stripeHeight;
+ const int linesToRead = SkTMin(stripeHeight, height - startY);
+ codec->getScanlines(bitmap.getAddr(width / 2, startY), linesToRead, bitmap.rowBytes());
+
+ // Skip a stripe
+ const int linesToSkip = SkTMin(stripeHeight, height - (i + 1) * stripeHeight);
+ if (linesToSkip > 0) {
+ codec->skipScanlines(linesToSkip);
+ }
+ }
+
+
canvas->drawBitmap(bitmap, 0, 0);
break;
}
« no previous file with comments | « dm/DM.cpp ('k') | gyp/libjpeg-turbo.gyp » ('j') | src/codec/SkJpegCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698