From: msarett Date: Thu, 3 Dec 2015 20:23:43 +0000 (-0800) Subject: Add currScanline() getter to SkCodec API X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~184^2~490 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb0d5c940a881ee38f0f95e240b31a9052a4e440;p=platform%2Fupstream%2FlibSkiaSharp.git Add currScanline() getter to SkCodec API This is more correct than using nextScanline() for the SkGifCodec scanline decoder (since we will get a strange result in the interlaced case) and is necessary if we want to add scanline decoding to SkIcoCodec. This does not actually fix bugs or change behavior. BUG=skia: Review URL: https://codereview.chromium.org/1489163002 --- diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h index 9f28af0..075f976 100644 --- a/include/codec/SkCodec.h +++ b/include/codec/SkCodec.h @@ -415,9 +415,9 @@ public: int nextScanline() const { return this->outputScanline(fCurrScanline); } /** - * Returns the output y-coordinate of the row that corresponds to an input - * y-coordinate. The input y-coordinate represents where the scanline - * is located in the encoded data. + * Returns the output y-coordinate of the row that corresponds to an input + * y-coordinate. The input y-coordinate represents where the scanline + * is located in the encoded data. * * This will equal inputScanline, except in the case of strangely * encoded image types (bottom-up bmps, interlaced gifs). @@ -529,14 +529,22 @@ protected: virtual SkScanlineOrder onGetScanlineOrder() const { return kTopDown_SkScanlineOrder; } /** - * Update the next scanline. Used by interlaced png. + * Update the current scanline. Used by interlaced png. */ - void updateNextScanline(int newY) { fCurrScanline = newY; } + void updateCurrScanline(int newY) { fCurrScanline = newY; } const SkImageInfo& dstInfo() const { return fDstInfo; } const SkCodec::Options& options() const { return fOptions; } + /** + * Returns the number of scanlines that have been decoded so far. + * This is unaffected by the SkScanlineOrder. + * + * Returns -1 if we have not started a scanline decode. + */ + int currScanline() const { return fCurrScanline; } + virtual int onOutputScanline(int inputScanline) const; private: diff --git a/src/codec/SkCodec_libgif.cpp b/src/codec/SkCodec_libgif.cpp index 8021af9..e6a4016 100644 --- a/src/codec/SkCodec_libgif.cpp +++ b/src/codec/SkCodec_libgif.cpp @@ -508,7 +508,7 @@ SkCodec::Result SkGifCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, void SkGifCodec::handleScanlineFrame(int count, int* rowsBeforeFrame, int* rowsInFrame) { if (fFrameIsSubset) { - const int currRow = this->INHERITED::nextScanline(); + const int currRow = this->currScanline(); // The number of rows that remain to be skipped before reaching rows that we // actually must decode into. diff --git a/src/codec/SkCodec_libpng.cpp b/src/codec/SkCodec_libpng.cpp index 355d493..a611705 100644 --- a/src/codec/SkCodec_libpng.cpp +++ b/src/codec/SkCodec_libpng.cpp @@ -768,7 +768,7 @@ public: if (!this->rewindIfNeeded()) { return kCouldNotRewind; } - this->updateNextScanline(currScanline); + this->updateCurrScanline(currScanline); } if (setjmp(png_jmpbuf(this->png_ptr()))) {