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

Side by Side Diff: src/codec/SkCodec_libico.cpp

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBmpCodec.h" 8 #include "SkBmpCodec.h"
9 #include "SkCodec_libico.h" 9 #include "SkCodec_libico.h"
10 #include "SkCodec_libpng.h" 10 #include "SkCodec_libpng.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 SkCodecPrintf("Warning: could not skip to ico offset.\n"); 126 SkCodecPrintf("Warning: could not skip to ico offset.\n");
127 break; 127 break;
128 } 128 }
129 bytesRead = offset; 129 bytesRead = offset;
130 130
131 // Create a new stream for the embedded codec 131 // Create a new stream for the embedded codec
132 SkAutoTUnref<SkData> data( 132 SkAutoTUnref<SkData> data(
133 SkData::NewFromStream(inputStream.get(), size)); 133 SkData::NewFromStream(inputStream.get(), size));
134 if (nullptr == data.get()) { 134 if (nullptr == data.get()) {
135 SkCodecPrintf("Warning: could not create embedded stream.\n"); 135 SkCodecPrintf("Warning: could not create embedded stream.\n");
136 // FIXME: This is a good solution if we have already created at
137 // least one valid codec. Otherwise, we may want to try to
138 // partially decode this incomplete embedded image.
136 break; 139 break;
137 } 140 }
138 SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data.get ())); 141 SkAutoTDelete<SkMemoryStream> embeddedStream(new SkMemoryStream(data.get ()));
139 bytesRead += size; 142 bytesRead += size;
140 143
141 // Check if the embedded codec is bmp or png and create the codec 144 // Check if the embedded codec is bmp or png and create the codec
142 const bool isPng = SkPngCodec::IsPng(embeddedStream); 145 const bool isPng = SkPngCodec::IsPng(embeddedStream);
143 SkAssertResult(embeddedStream->rewind()); 146 SkAssertResult(embeddedStream->rewind());
144 SkCodec* codec = nullptr; 147 SkCodec* codec = nullptr;
145 if (isPng) { 148 if (isPng) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 285 }
283 286
284 // On success or partial success, return the result 287 // On success or partial success, return the result
285 return result; 288 return result;
286 } 289 }
287 } 290 }
288 291
289 SkCodecPrintf("Error: No matching candidate image in ico.\n"); 292 SkCodecPrintf("Error: No matching candidate image in ico.\n");
290 return result; 293 return result;
291 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698