OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |