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

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: Response to comments and further testing 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/DMSrcSink.h ('k') | gyp/codec.gyp » ('j') | no next file with comments »
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..efffc8f06bef6306e702857e39c4848f37fc3cae 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -372,54 +372,39 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
canvas->drawBitmap(bitmap, 0, 0);
break;
}
- case kStripe_Mode: {
+ case kTile_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.
- const int stripeHeight = 37;
- const int numStripes = (height + stripeHeight - 1) / stripeHeight;
+ const int tileSize = 37;
+ const int tileWidth = (width + tileSize - 1) / tileSize;
+ const int tileHeight = (height + tileSize - 1) / tileSize;
- // Decode odd stripes
- if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, NULL, colorPtr,
- colorCountPtr)
- || SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
- // This mode was designed to test the new skip scanlines API in libjpeg-turbo.
- // Jpegs have kTopDown_SkScanlineOrder, and at this time, it is not interesting
- // to run this test for image types that do not have this scanline ordering.
- return Error::Nonfatal("Could not start top-down scanline decoder");
- }
-
- for (int i = 0; i < numStripes; i += 2) {
- // Skip a stripe
- const int linesToSkip = SkTMin(stripeHeight, height - i * stripeHeight);
- codec->skipScanlines(linesToSkip);
+ SkCodec::Options opts;
+ SkIRect subset;
+ for (int tileX = 0; tileX < tileWidth; tileX++) {
+ const int startX = tileX * tileSize;
+ subset = SkIRect::MakeXYWH(startX, 0, SkTMin(tileSize, width - startX), height);
+ opts.fSubset = &subset;
+ for (int tileY = 0; tileY < tileHeight; tileY++) {
+ if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opts,
+ colorPtr, colorCountPtr) ||
+ SkCodec::kTopDown_SkScanlineOrder != codec->getScanlineOrder()) {
+ if (0 == tileY && 0 == tileX) {
+ return Error::Nonfatal("Could not start top-down scanline decoder");
+ }
+ return "Could not restart scanline decoder.";
+ }
- // Read a stripe
- const int startY = (i + 1) * stripeHeight;
- const int linesToRead = SkTMin(stripeHeight, height - startY);
- if (linesToRead > 0) {
- codec->getScanlines(bitmap.getAddr(0, startY), linesToRead, bitmap.rowBytes());
+ const int startY = tileY * tileSize;
+ codec->skipScanlines(startY);
+ const int linesToGet = SkTMin(tileSize, height - startY);
+ codec->getScanlines(bitmap.getAddr(startX, startY), linesToGet,
+ bitmap.rowBytes());
}
}
- // Decode even stripes
- const SkCodec::Result startResult = codec->startScanlineDecode(decodeInfo, nullptr,
- 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(0, 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/DMSrcSink.h ('k') | gyp/codec.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698