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

Unified Diff: src/codec/SkPngCodec.cpp

Issue 2407543002: Simplify rowsDecoded returned by incrementalDecode (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 | « no previous file | src/codec/SkSampledCodec.cpp » ('j') | src/codec/SkSampledCodec.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkPngCodec.cpp
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index 0d343da594d335f9b6759ee8114e8e74c8e32ade..22fef4db0c1959c3c8086ae76e6695961bc1748c 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -515,6 +515,7 @@ public:
SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, int bitDepth)
: INHERITED(info, imageInfo, stream, reader, png_ptr, info_ptr, bitDepth)
, fLinesDecoded(0)
+ , fRowsWrittenToOutput(0)
, fDst(nullptr)
, fRowBytes(0)
, fFirstRow(0)
@@ -536,7 +537,13 @@ public:
#endif
private:
- int fLinesDecoded; // FIXME: Move to baseclass?
+ // This represents the number of lines reported by libpng, minus any we skipped at the
+ // beginning. Only used when we are skipping lines (i.e. not in decodeAllRows).
+ int fLinesDecoded;
+ // While fLinesDecoded include lines that we skipped, this only includes lines written to the
+ // output so we can report it to the caller for filling.
+ // FIXME: Can we remove fLinesDecoded and just rely on fRowsWrittenToOutput?
msarett 2016/10/10 17:19:58 I think this would be good. IMO using this to cou
scroggo_chromium 2016/10/10 18:15:04 Agreed. I don't think it's terribly hard, but it's
+ int fRowsWrittenToOutput;
void* fDst;
size_t fRowBytes;
@@ -560,16 +567,16 @@ private:
fDst = dst;
fRowBytes = rowBytes;
- fLinesDecoded = 0;
+ fRowsWrittenToOutput = 0;
this->processData();
- if (fLinesDecoded == height) {
+ if (fRowsWrittenToOutput == height) {
return SkCodec::kSuccess;
}
if (rowsDecoded) {
- *rowsDecoded = fLinesDecoded;
+ *rowsDecoded = fRowsWrittenToOutput;
}
return SkCodec::kIncompleteInput;
@@ -593,6 +600,7 @@ private:
fDst = dst;
fRowBytes = rowBytes;
fLinesDecoded = 0;
+ fRowsWrittenToOutput = 0;
}
SkCodec::Result decode(int* rowsDecoded) override {
@@ -603,7 +611,7 @@ private:
}
if (rowsDecoded) {
- *rowsDecoded = fLinesDecoded;
+ *rowsDecoded = fRowsWrittenToOutput;
}
return SkCodec::kIncompleteInput;
@@ -621,6 +629,7 @@ private:
if (!this->swizzler() || this->swizzler()->rowNeeded(fLinesDecoded)) {
this->applyXformRow(fDst, row);
fDst = SkTAddOffset<void>(fDst, fRowBytes);
+ fRowsWrittenToOutput++;
}
fLinesDecoded++;
@@ -770,6 +779,8 @@ private:
const int lastRow = fLinesDecoded + fFirstRow - 1;
SkASSERT(lastRow <= fLastRow);
+ int rowsWrittenToOutput = 0;
+
// FIXME: For resuming interlace, we may swizzle a row that hasn't changed. But it
// may be too tricky/expensive to handle that correctly.
png_bytep srcRow = fInterlaceBuffer.get();
@@ -779,6 +790,7 @@ private:
this->applyXformRow(dst, srcRow);
dst = SkTAddOffset<void>(dst, fRowBytes);
srcRow = SkTAddOffset<png_byte>(srcRow, fPng_rowbytes * sampleY);
+ rowsWrittenToOutput++;
}
if (fInterlacedComplete) {
@@ -786,7 +798,7 @@ private:
}
if (rowsDecoded) {
- *rowsDecoded = fLinesDecoded;
+ *rowsDecoded = rowsWrittenToOutput;
}
return SkCodec::kIncompleteInput;
}
« no previous file with comments | « no previous file | src/codec/SkSampledCodec.cpp » ('j') | src/codec/SkSampledCodec.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698