| Index: src/images/SkImageDecoder_libjpeg.cpp
|
| diff --git a/src/images/SkImageDecoder_libjpeg.cpp b/src/images/SkImageDecoder_libjpeg.cpp
|
| index 21e96be2d3049e091a48ef1728bf7554522ad684..d13c2a5c7846ce689d569693a1a99472bfdd1996 100644
|
| --- a/src/images/SkImageDecoder_libjpeg.cpp
|
| +++ b/src/images/SkImageDecoder_libjpeg.cpp
|
| @@ -492,6 +492,7 @@ static void adjust_out_color_space_and_dither(jpeg_decompress_struct* cinfo,
|
| }
|
|
|
|
|
| +#ifdef SK_DECODE_PARTIAL_IMAGES
|
| /**
|
| Sets all pixels in given bitmap to SK_ColorWHITE for all rows >= y.
|
| Used when decoding fails partway through reading scanlines to fill
|
| @@ -502,6 +503,7 @@ static void fill_below_level(int y, SkBitmap* bitmap) {
|
| canvas.clipRect(SkRect::Make(rect));
|
| canvas.drawColor(SK_ColorWHITE);
|
| }
|
| +#endif
|
|
|
| /**
|
| * Get the config and bytes per pixel of the source data. Return
|
| @@ -658,11 +660,15 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
|
| while (cinfo.output_scanline < cinfo.output_height) {
|
| int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1);
|
| if (0 == row_count) {
|
| +#ifdef SK_DECODE_PARTIAL_IMAGES
|
| // if row_count == 0, then we didn't get a scanline,
|
| // so return early. We will return a partial image.
|
| fill_below_level(cinfo.output_scanline, bm);
|
| cinfo.output_scanline = cinfo.output_height;
|
| break; // Skip to jpeg_finish_decompress()
|
| +#else
|
| + return return_false(cinfo, *bm, "read_scanlines");
|
| +#endif
|
| }
|
| if (this->shouldCancelDecode()) {
|
| return return_false(cinfo, *bm, "shouldCancelDecode");
|
| @@ -699,11 +705,15 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
|
| JSAMPLE* rowptr = (JSAMPLE*)srcRow;
|
| int row_count = jpeg_read_scanlines(&cinfo, &rowptr, 1);
|
| if (0 == row_count) {
|
| +#ifdef SK_DECODE_PARTIAL_IMAGES
|
| // if row_count == 0, then we didn't get a scanline,
|
| // so return early. We will return a partial image.
|
| fill_below_level(y, bm);
|
| cinfo.output_scanline = cinfo.output_height;
|
| break; // Skip to jpeg_finish_decompress()
|
| +#else
|
| + return return_false(cinfo, *bm, "read_scanlines");
|
| +#endif
|
| }
|
| if (this->shouldCancelDecode()) {
|
| return return_false(cinfo, *bm, "shouldCancelDecode");
|
|
|