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

Unified Diff: src/images/SkImageDecoder_libjpeg.cpp

Issue 1010983004: Lazy SKP image decoding in DM. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 9 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 | « dm/DMSrcSink.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 d32e2a21c91bea0fe06e472a5e6cce22518f41c5..caa1300124443a5f81aba764ea0d0d4e4d963fe0 100644
--- a/src/images/SkImageDecoder_libjpeg.cpp
+++ b/src/images/SkImageDecoder_libjpeg.cpp
@@ -768,14 +768,25 @@ static SkISize compute_yuv_size(const jpeg_decompress_struct& info, int componen
info.cur_comp_info[component]->downsampled_height);
}
-static void update_components_sizes(const jpeg_decompress_struct& cinfo, SkISize componentSizes[3],
+static bool contains_three_planes(const jpeg_decompress_struct& cinfo) {
hal.canary 2015/03/17 21:32:48 // Either explain why this is needed or note that
+ return cinfo.cur_comp_info[0] && cinfo.cur_comp_info[1] && cinfo.cur_comp_info[2];
+}
+
+static bool update_components_sizes(const jpeg_decompress_struct& cinfo, SkISize componentSizes[3],
SizeType sizeType) {
+ if (!contains_three_planes(cinfo)) {
+ return false;
+ }
for (int i = 0; i < 3; ++i) {
componentSizes[i] = compute_yuv_size(cinfo, i, sizeType);
}
+ return true;
}
static bool output_raw_data(jpeg_decompress_struct& cinfo, void* planes[3], size_t rowBytes[3]) {
+ if (!contains_three_planes(cinfo)) {
+ return false;
+ }
// U size and V size have to be the same if we're calling output_raw_data()
SkISize uvSize = compute_yuv_size(cinfo, 1, kSizeForMemoryAllocation_SizeType);
SkASSERT(uvSize == compute_yuv_size(cinfo, 2, kSizeForMemoryAllocation_SizeType));
@@ -897,8 +908,7 @@ bool SkJPEGImageDecoder::onDecodeYUV8Planes(SkStream* stream, SkISize componentS
cinfo.raw_data_out = TRUE;
if (!planes || !planes[0] || !rowBytes || !rowBytes[0]) { // Compute size only
- update_components_sizes(cinfo, componentSizes, kSizeForMemoryAllocation_SizeType);
- return true;
+ return update_components_sizes(cinfo, componentSizes, kSizeForMemoryAllocation_SizeType);
}
set_dct_method(*this, &cinfo);
@@ -924,7 +934,9 @@ bool SkJPEGImageDecoder::onDecodeYUV8Planes(SkStream* stream, SkISize componentS
return return_false(cinfo, "output_raw_data");
}
- update_components_sizes(cinfo, componentSizes, kActualSize_SizeType);
+ if (!update_components_sizes(cinfo, componentSizes, kActualSize_SizeType)) {
+ return false;
+ }
jpeg_finish_decompress(&cinfo);
if (NULL != colorSpace) {
« no previous file with comments | « dm/DMSrcSink.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698