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

Unified Diff: dm/DMSrcSink.cpp

Issue 1719073002: Use new jpeg_crop_scanlines() API to optimize jpeg subset decodes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add to assert Created 4 years, 10 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 | « 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 7ccaf223fc3a32b8e2baa867dcd575454332b6ec..bd881e8381739a1c723f8014ed0859fa0a747473 100644
--- a/dm/DMSrcSink.cpp
+++ b/dm/DMSrcSink.cpp
@@ -522,6 +522,31 @@ Error CodecSrc::draw(SkCanvas* canvas) const {
canvas->drawBitmap(bitmap, 0, 0);
break;
}
+ case kCroppedScanline_Mode: {
+ const int width = decodeInfo.width();
+ const int height = decodeInfo.height();
+ // This value is chosen because, as we move across the image, it will sometimes
+ // align with the jpeg block sizes and it will sometimes not. This allows us
+ // to test interestingly different code paths in the implementation.
+ const int tileSize = 36;
+
+ SkCodec::Options opts;
+ SkIRect subset;
+ for (int x = 0; x < width; x += tileSize) {
+ subset = SkIRect::MakeXYWH(x, 0, SkTMin(tileSize, width - x), height);
+ opts.fSubset = &subset;
+ if (SkCodec::kSuccess != codec->startScanlineDecode(decodeInfo, &opts,
+ colorPtr, colorCountPtr)) {
+ return "Could not start scanline decoder.";
+ }
+
+ codec->getScanlines(bitmap.getAddr(x, 0), height, bitmap.rowBytes());
+ }
+
+ premultiply_if_necessary(bitmap);
+ canvas->drawBitmap(bitmap, 0, 0);
+ break;
+ }
case kSubset_Mode: {
// Arbitrarily choose a divisor.
int divisor = 2;
« 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