| Index: src/codec/SkJpegCodec.cpp
|
| diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
|
| index 2baf51a00925db4055e53158d040324f565f062f..05550ec8dc145df09a77a3c842a20d7376c38671 100644
|
| --- a/src/codec/SkJpegCodec.cpp
|
| +++ b/src/codec/SkJpegCodec.cpp
|
| @@ -346,16 +346,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
|
|
|
| // If we cannot read enough rows, assume the input is incomplete
|
| if (rowsDecoded != 1) {
|
| - // Fill the remainder of the image with black. This error handling
|
| - // behavior is unspecified but SkCodec consistently uses black as
|
| - // the fill color for opaque images. If the destination is kGray,
|
| - // the low 8 bits of SK_ColorBLACK will be used. Conveniently,
|
| - // these are zeros, which is the representation for black in kGray.
|
| - // If the destination is kRGB_565, the low 16 bits of SK_ColorBLACK
|
| - // will be used. Conveniently, these are zeros, which is the
|
| - // representation for black in kRGB_565.
|
| - SkSwizzler::Fill(dstRow, dstInfo, dstRowBytes, dstHeight - y,
|
| - SK_ColorBLACK, nullptr, options.fZeroInitialized);
|
| + this->setIncompleteScanlines(dstHeight - y);
|
|
|
| // Prevent libjpeg from failing on incomplete decode
|
| dinfo->output_scanline = dstHeight;
|
| @@ -383,8 +374,8 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| */
|
| class SkJpegScanlineDecoder : public SkScanlineDecoder {
|
| public:
|
| - SkJpegScanlineDecoder(const SkImageInfo& srcInfo, SkJpegCodec* codec)
|
| - : INHERITED(srcInfo)
|
| + SkJpegScanlineDecoder(SkJpegCodec* codec)
|
| + : INHERITED(codec, codec->getInfo())
|
| , fCodec(codec)
|
| , fOpts()
|
| {}
|
| @@ -421,8 +412,8 @@ public:
|
| SkASSERT(false);
|
| }
|
|
|
| - fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, info, options.fZeroInitialized,
|
| - this->getInfo()));
|
| + fSwizzler.reset(SkSwizzler::CreateSwizzler(srcConfig, nullptr, info,
|
| + options.fZeroInitialized, this->getInfo()));
|
| if (!fSwizzler) {
|
| // FIXME: CreateSwizzler could fail for another reason.
|
| return SkCodec::kUnimplemented;
|
| @@ -492,7 +483,7 @@ public:
|
| jpeg_finish_decompress(fCodec->fDecoderMgr->dinfo());
|
| }
|
|
|
| - SkCodec::Result onGetScanlines(void* dst, int count, size_t rowBytes) override {
|
| + uint32_t onGetScanlines(void* dst, int count, size_t rowBytes) override {
|
| // Set the jump location for libjpeg errors
|
| if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
|
| return fCodec->fDecoderMgr->returnFailure("setjmp", SkCodec::kInvalidInput);
|
| @@ -511,10 +502,8 @@ public:
|
| // Read row of the image
|
| uint32_t rowsDecoded = jpeg_read_scanlines(fCodec->fDecoderMgr->dinfo(), &dstRow, 1);
|
| if (rowsDecoded != 1) {
|
| - SkSwizzler::Fill(dstRow, this->dstInfo(), rowBytes, count - y,
|
| - SK_ColorBLACK, nullptr, fOpts.fZeroInitialized);
|
| fCodec->fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height();
|
| - return SkCodec::kIncompleteInput;
|
| + return y;
|
| }
|
|
|
| // Convert to RGBA if necessary
|
| @@ -530,7 +519,7 @@ public:
|
| dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes);
|
| }
|
| }
|
| - return SkCodec::kSuccess;
|
| + return count;
|
| }
|
|
|
| #ifndef TURBO_HAS_SKIP
|
| @@ -544,15 +533,13 @@ public:
|
| }
|
| #endif
|
|
|
| - SkCodec::Result onSkipScanlines(int count) override {
|
| + uint32_t onSkipScanlines(int count) override {
|
| // Set the jump location for libjpeg errors
|
| if (setjmp(fCodec->fDecoderMgr->getJmpBuf())) {
|
| return fCodec->fDecoderMgr->returnFailure("setjmp", SkCodec::kInvalidInput);
|
| }
|
|
|
| - jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count);
|
| -
|
| - return SkCodec::kSuccess;
|
| + return jpeg_skip_scanlines(fCodec->fDecoderMgr->dinfo(), count);
|
| }
|
|
|
| SkEncodedFormat onGetEncodedFormat() const override {
|
| @@ -560,7 +547,7 @@ public:
|
| }
|
|
|
| private:
|
| - SkAutoTDelete<SkJpegCodec> fCodec;
|
| + SkJpegCodec* fCodec; // Owned by parent class
|
| SkAutoMalloc fStorage; // Only used if sampling is needed
|
| uint8_t* fSrcRow; // Only used if sampling is needed
|
| SkCodec::Options fOpts;
|
| @@ -575,8 +562,6 @@ SkScanlineDecoder* SkJpegCodec::NewSDFromStream(SkStream* stream) {
|
| return nullptr;
|
| }
|
|
|
| - const SkImageInfo& srcInfo = codec->getInfo();
|
| -
|
| // Return the new scanline decoder
|
| - return new SkJpegScanlineDecoder(srcInfo, codec.detach());
|
| + return new SkJpegScanlineDecoder(codec.detach());
|
| }
|
|
|