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

Unified Diff: src/codec/SkSampledCodec.cpp

Issue 2420843003: Incremental decode: only use subset for subsetting (Closed)
Patch Set: Created 4 years, 2 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 | « src/codec/SkPngCodec.cpp ('k') | src/codec/SkSampler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkSampledCodec.cpp
diff --git a/src/codec/SkSampledCodec.cpp b/src/codec/SkSampledCodec.cpp
index 46286cff9da6f868d181e3250c6bdbe08fe7e41d..22b5cfae5aad31e3d40877fd76c08976fa55fd5e 100644
--- a/src/codec/SkSampledCodec.cpp
+++ b/src/codec/SkSampledCodec.cpp
@@ -186,7 +186,7 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
// We will need to know about subsetting in the y-dimension in order to use the
// scanline decoder.
// Update the subset to account for scaling done by this->codec().
- SkIRect* subsetPtr = options.fSubset;
+ const SkIRect* subsetPtr = options.fSubset;
// Do the divide ourselves, instead of calling get_scaled_dimension. If
// X and Y are 0, they should remain 0, rather than being upgraded to 1
@@ -210,7 +210,7 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
const int samplingOffsetY = get_start_coord(sampleY);
const int startY = samplingOffsetY + subsetY;
- int dstHeight = info.height();
+ const int dstHeight = info.height();
const SkImageInfo nativeInfo = info.makeWH(nativeSize.width(), nativeSize.height());
@@ -218,22 +218,15 @@ SkCodec::Result SkSampledCodec::sampledDecode(const SkImageInfo& info, void* pix
// Although startScanlineDecode expects the bottom and top to match the
// SkImageInfo, startIncrementalDecode uses them to determine which rows to
// decode.
- // Note: We *could* use "subsetY" and "subsetHeight" (calculated above) for
- // incrementalSubset, but this code gives us a tighter bounds on the subset,
- // meaning that we can start with the first row actually needed by the output,
- // and stop when we've decoded the last row needed by the output.
+ SkCodec::Options incrementalOptions = sampledOptions;
SkIRect incrementalSubset;
- incrementalSubset.fTop = startY;
- incrementalSubset.fBottom = startY + (dstHeight - 1) * sampleY + 1;
if (sampledOptions.fSubset) {
+ incrementalSubset.fTop = subsetY;
+ incrementalSubset.fBottom = subsetY + subsetHeight;
incrementalSubset.fLeft = sampledOptions.fSubset->fLeft;
incrementalSubset.fRight = sampledOptions.fSubset->fRight;
- } else {
- incrementalSubset.fLeft = 0;
- incrementalSubset.fRight = nativeSize.width();
+ incrementalOptions.fSubset = &incrementalSubset;
}
- SkCodec::Options incrementalOptions = sampledOptions;
- incrementalOptions.fSubset = &incrementalSubset;
const SkCodec::Result startResult = this->codec()->startIncrementalDecode(nativeInfo,
pixels, rowBytes, &incrementalOptions, options.fColorPtr, options.fColorCount);
if (SkCodec::kSuccess == startResult) {
« no previous file with comments | « src/codec/SkPngCodec.cpp ('k') | src/codec/SkSampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698