Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(970)

Unified Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 658343003: Fixes for partial images. (Closed) Base URL: https://skia.googlesource.com/skia.git/+/master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder_libgif.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « src/images/SkImageDecoder_libgif.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698