Merge SkCodec with SkScanlineDecoder
authorscroggo <scroggo@google.com>
Wed, 30 Sep 2015 15:57:13 +0000 (08:57 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 30 Sep 2015 15:57:14 +0000 (08:57 -0700)
commit46c574725676b26ada63ac15e42cda309dcd5090
treed9ee41e9f1c607ff139eca622bb03809eb9a83d3
parente2bcec38486f2e1a897973c953e5610eaef4221e
Merge SkCodec with SkScanlineDecoder

Benefits:
- This mimics other decoding APIs (including the ones SkCodec relies
on, e.g. a png_struct, which can be used to decode an entire image or
one line at a time).

- It allows a client to ask us to do what we can do efficiently - i.e.
start from encoded data and either decode the whole thing or scanlines.

- It removes the duplicate methods which appeared in both SkCodec and
SkScanlineDecoder (some of which, e.g. in SkJpegScanlineDecoder, just
call fCodec->sameMethod()).

- It simplifies moving more checks into the base class (e.g. the
examples in skbug.com/4284).

BUG=skia:4175
BUG=skia:4284

=====================================================================

SkScanlineDecoder.h/.cpp:
Removed.

SkCodec.h/.cpp:
Add methods, enums, and variables which were previously in
SkScanlineDecoder.
Default fCurrScanline to -1, as a sentinel that start has not been
called.

General changes:
Convert SkScanlineDecoders to SkCodecs.

General changes in SkCodec subclasses:
Merge SkScanlineDecoder implementation into SkCodec. Most (all?) owned
an SkCodec, so they now call this-> instead of fCodec->.

SkBmpCodec.h/.cpp:
Replace the unused rowOrder method with an override for
onGetScanlineOrder.
Make getDstRow const, since it is called by onGetY, which is const.

SkCodec_libpng.h/.cpp:
Make SkPngCodec an abstract class, with two subclasses which handle
scanline decoding separately (they share code for decoding the entire
image). Reimplement onReallyHasAlpha so that it can return the most
recent result (e.g. after a scanline decode which only decoded part
of the image) or a better answer (e.g. if the whole image is known to
be opaque).
Compute fNumberPasses early, so we know which subclass to instantiate.
Make SkPngInterlaceScanlineDecoder use the base class' fCurrScanline
rather than a separate variable.

CodexTest.cpp:
Add tests for the state changes in SkCodec (need to call start before
decoding scanlines; calling getPixels means that start will need to
be called again before decoding more scanlines).
Add a test which decodes in stripes, currently only used for an
interlaced PNG.

TODO: Add tests for onReallyHasAlpha.

Review URL: https://codereview.chromium.org/1365313002
34 files changed:
bench/nanobench.cpp
bench/subset/SubsetSingleBench.cpp
bench/subset/SubsetTranslateBench.cpp
bench/subset/SubsetZoomBench.cpp
dm/DM.cpp
dm/DMSrcSink.cpp
gyp/codec.gyp
include/codec/SkCodec.h
include/codec/SkScaledCodec.h
include/codec/SkScanlineDecoder.h [deleted file]
resources/plane_interlaced.png [new file with mode: 0644]
src/codec/SkBmpCodec.cpp
src/codec/SkBmpCodec.h
src/codec/SkBmpMaskCodec.cpp
src/codec/SkBmpMaskCodec.h
src/codec/SkBmpRLECodec.cpp
src/codec/SkBmpRLECodec.h
src/codec/SkBmpStandardCodec.cpp
src/codec/SkBmpStandardCodec.h
src/codec/SkCodec.cpp
src/codec/SkCodec_libgif.cpp
src/codec/SkCodec_libgif.h
src/codec/SkCodec_libpng.cpp
src/codec/SkCodec_libpng.h
src/codec/SkCodec_wbmp.cpp
src/codec/SkCodec_wbmp.h
src/codec/SkJpegCodec.cpp
src/codec/SkJpegCodec.h
src/codec/SkScaledCodec.cpp
src/codec/SkScanlineDecoder.cpp [deleted file]
tests/CodexTest.cpp
tools/SkBitmapRegionCanvas.cpp
tools/SkBitmapRegionCanvas.h
tools/SkBitmapRegionDecoderInterface.cpp