| Index: src/codec/SkJpegCodec.cpp
|
| diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
|
| index b4c794c90623111d3835b0673d5ec88eb5c42d32..aff54bbd4d6e49f19d3041ef8f4f81ca7610928b 100644
|
| --- a/src/codec/SkJpegCodec.cpp
|
| +++ b/src/codec/SkJpegCodec.cpp
|
| @@ -302,7 +302,8 @@ bool SkJpegCodec::nativelyScaleToDimensions(uint32_t dstWidth, uint32_t dstHeigh
|
| */
|
| SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| void* dst, size_t dstRowBytes,
|
| - const Options& options, SkPMColor*, int*) {
|
| + const Options& options, SkPMColor*, int*,
|
| + int* rowsDecoded) {
|
| if (options.fSubset) {
|
| // Subsets are not supported.
|
| return kUnimplemented;
|
| @@ -340,20 +341,11 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo,
|
| JSAMPLE* dstRow = (JSAMPLE*) dst;
|
| for (uint32_t y = 0; y < dstHeight; y++) {
|
| // Read rows of the image
|
| - uint32_t rowsDecoded = jpeg_read_scanlines(dinfo, &dstRow, 1);
|
| + uint32_t lines = jpeg_read_scanlines(dinfo, &dstRow, 1);
|
|
|
| // 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);
|
| + if (lines != 1) {
|
| + *rowsDecoded = y;
|
|
|
| // Prevent libjpeg from failing on incomplete decode
|
| dinfo->output_scanline = dstHeight;
|
| @@ -461,7 +453,7 @@ SkJpegCodec::~SkJpegCodec() {
|
| jpeg_finish_decompress(fDecoderMgr->dinfo());
|
| }
|
|
|
| -SkCodec::Result SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
|
| +uint32_t SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowBytes) {
|
| // Set the jump location for libjpeg errors
|
| if (setjmp(fDecoderMgr->getJmpBuf())) {
|
| return fDecoderMgr->returnFailure("setjmp", kInvalidInput);
|
| @@ -480,10 +472,8 @@ SkCodec::Result SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowByte
|
| // Read row of the image
|
| uint32_t rowsDecoded = jpeg_read_scanlines(fDecoderMgr->dinfo(), &dstRow, 1);
|
| if (rowsDecoded != 1) {
|
| - SkSwizzler::Fill(dstRow, this->dstInfo(), rowBytes, count - y,
|
| - SK_ColorBLACK, nullptr, this->options().fZeroInitialized);
|
| fDecoderMgr->dinfo()->output_scanline = this->dstInfo().height();
|
| - return kIncompleteInput;
|
| + return y;
|
| }
|
|
|
| // Convert to RGBA if necessary
|
| @@ -499,7 +489,7 @@ SkCodec::Result SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowByte
|
| dstRow = SkTAddOffset<JSAMPLE>(dstRow, rowBytes);
|
| }
|
| }
|
| - return kSuccess;
|
| + return count;
|
| }
|
|
|
| #ifndef TURBO_HAS_SKIP
|
| @@ -513,14 +503,11 @@ SkCodec::Result SkJpegCodec::onGetScanlines(void* dst, int count, size_t rowByte
|
| }
|
| #endif
|
|
|
| -SkCodec::Result SkJpegCodec::onSkipScanlines(int count) {
|
| +bool SkJpegCodec::onSkipScanlines(int count) {
|
| // Set the jump location for libjpeg errors
|
| if (setjmp(fDecoderMgr->getJmpBuf())) {
|
| return fDecoderMgr->returnFailure("setjmp", kInvalidInput);
|
| }
|
|
|
| - jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
|
| -
|
| - return kSuccess;
|
| + return count == jpeg_skip_scanlines(fDecoderMgr->dinfo(), count);
|
| }
|
| -
|
|
|