Fill incomplete images in SkCodec parent class
Rather than implementing some sort of "fill" in every
SkCodec subclass for incomplete images, let's make the
parent class handle this situation.
This includes an API change to SkCodec.h
SkCodec::getScanlines() now returns the number of lines it
read successfully, rather than an SkCodec::Result enum.
getScanlines() most often fails on an incomplete input, in
which case it is useful to know how many lines were
successfully decoded - this provides more information than
kIncomplete vs kSuccess. We do lose information when the
API is used improperly, as we are no longer able to return
kInvalidParameter or kScanlineNotStarted.
Known Issues:
Does not work for incomplete fFrameIsSubset gifs.
Does not work for incomplete icos.
BUG=skia:
Review URL: https://codereview.chromium.org/1332053002
diff --git a/src/codec/SkJpegCodec.h b/src/codec/SkJpegCodec.h
index 6377c9d..67680d6 100644
--- a/src/codec/SkJpegCodec.h
+++ b/src/codec/SkJpegCodec.h
@@ -50,7 +50,7 @@
* Initiates the jpeg decode
*/
Result onGetPixels(const SkImageInfo& dstInfo, void* dst, size_t dstRowBytes, const Options&,
- SkPMColor*, int*) override;
+ SkPMColor*, int*, int*) override;
SkEncodedFormat onGetEncodedFormat() const override {
return kJPEG_SkEncodedFormat;
@@ -103,11 +103,11 @@
bool setOutputColorSpace(const SkImageInfo& dst);
// scanline decoding
- SkSampler* getSampler() override;
+ SkSampler* getSampler(bool createIfNecessary) override;
Result onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options,
SkPMColor ctable[], int* ctableCount) override;
- Result onGetScanlines(void* dst, int count, size_t rowBytes) override;
- Result onSkipScanlines(int count) override;
+ int onGetScanlines(void* dst, int count, size_t rowBytes) override;
+ bool onSkipScanlines(int count) override;
SkAutoTDelete<JpegDecoderMgr> fDecoderMgr;
// We will save the state of the decompress struct after reading the header.