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) { |