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

Unified Diff: src/codec/SkJpegCodec.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 | « gyp/libjpeg-turbo.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 7db772da6386ad9a3b0002d5334598a625fd6fa2..ff6bce2b96039eb8254e23a447a5e9c8607a5f53 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -387,9 +387,35 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo,
return kInvalidInput;
}
- // We will need a swizzler if we are performing a subset decode or
- // converting from CMYK.
- if (options.fSubset || JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) {
+ Options subsetOptions = options;
scroggo 2015/12/16 18:17:01 I almost suggested "partialOptions", but it is act
+ SkIRect subsetRect = *options.fSubset;
+ if (options.fSubset) {
+ uint32_t startX = options.fSubset->x();
+ uint32_t width = options.fSubset->width();
+ // libjpeg-turbo may need to align startX to a multiple of the IDCT
scroggo 2015/12/16 18:17:01 nit: blank line before comments
+ // block size. If this is the case, it will decrease the value of
+ // startX to the appropriate alignment and also increase the value
+ // of width so that the right edge of the requested subset remains
+ // the same.
+ jpeg_set_partial_scanline(fDecoderMgr->dinfo(), &startX, &width);
scroggo 2015/12/16 18:17:01 Should we have a fallback if jpeg_set_partial_scan
+
+ // We will need a swizzler if libjpeg-turbo cannot provide the exact subset
+ // that we request. Or if we are converting from CMYK.
+ if (startX != (uint32_t) options.fSubset->x() ||
+ width != (uint32_t) options.fSubset->width() ||
+ JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) {
scroggo 2015/12/16 18:17:01 I don't understand why we need to check for this h
+ SkASSERT(startX <= (uint32_t) options.fSubset->x());
+ SkASSERT(width >= (uint32_t) options.fSubset->width());
+ SkASSERT(startX + width >= (uint32_t) options.fSubset->right());
scroggo 2015/12/16 18:17:01 nit: blank line between asserts and code
+ subsetRect.fLeft = options.fSubset->x() - startX;
scroggo 2015/12/16 18:17:00 IIUC, this means that the subset is now the subset
+ subsetRect.fRight = subsetRect.fLeft + options.fSubset->width();
+ subsetOptions.fSubset = &subsetRect;
+ this->initializeSwizzler(dstInfo, subsetOptions);
+ }
+ }
+
+ // Make sure we have a swizzler if we are converting from CMYK.
+ if (!fSwizzler && JCS_CMYK == fDecoderMgr->dinfo()->out_color_space) {
this->initializeSwizzler(dstInfo, options);
}
« no previous file with comments | « gyp/libjpeg-turbo.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698