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 "SkCodec_libbmp.h" | 8 #include "SkCodec_libbmp.h" |
9 #include "SkCodec_libico.h" | 9 #include "SkCodec_libico.h" |
10 #include "SkCodec_libpng.h" | 10 #include "SkCodec_libpng.h" |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 return fEmbeddedCodecs->operator[](minIndex)->getInfo().dimensions(); | 222 return fEmbeddedCodecs->operator[](minIndex)->getInfo().dimensions(); |
223 } | 223 } |
224 | 224 |
225 /* | 225 /* |
226 * Initiates the Ico decode | 226 * Initiates the Ico decode |
227 */ | 227 */ |
228 SkCodec::Result SkIcoCodec::onGetPixels(const SkImageInfo& dstInfo, | 228 SkCodec::Result SkIcoCodec::onGetPixels(const SkImageInfo& dstInfo, |
229 void* dst, size_t dstRowBytes, | 229 void* dst, size_t dstRowBytes, |
230 const Options& opts, SkPMColor* ct, | 230 const Options& opts, SkPMColor* ct, |
231 int* ptr) { | 231 int* ptr) { |
| 232 if (opts.fSubset) { |
| 233 // Subsets are not supported. |
| 234 return kUnimplemented; |
| 235 } |
232 // We return invalid scale if there is no candidate image with matching | 236 // We return invalid scale if there is no candidate image with matching |
233 // dimensions. | 237 // dimensions. |
234 Result result = kInvalidScale; | 238 Result result = kInvalidScale; |
235 for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) { | 239 for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) { |
236 // If the dimensions match, try to decode | 240 // If the dimensions match, try to decode |
237 if (dstInfo.dimensions() == | 241 if (dstInfo.dimensions() == |
238 fEmbeddedCodecs->operator[](i)->getInfo().dimensions()) { | 242 fEmbeddedCodecs->operator[](i)->getInfo().dimensions()) { |
239 | 243 |
240 // Perform the decode | 244 // Perform the decode |
241 result = fEmbeddedCodecs->operator[](i)->getPixels(dstInfo, | 245 result = fEmbeddedCodecs->operator[](i)->getPixels(dstInfo, |
242 dst, dstRowBytes, &opts, ct, ptr); | 246 dst, dstRowBytes, &opts, ct, ptr); |
243 | 247 |
244 // On a fatal error, keep trying to find an image to decode | 248 // On a fatal error, keep trying to find an image to decode |
245 if (kInvalidConversion == result || kInvalidInput == result || | 249 if (kInvalidConversion == result || kInvalidInput == result || |
246 kInvalidScale == result) { | 250 kInvalidScale == result) { |
247 SkCodecPrintf("Warning: Attempt to decode candidate ico failed.\
n"); | 251 SkCodecPrintf("Warning: Attempt to decode candidate ico failed.\
n"); |
248 continue; | 252 continue; |
249 } | 253 } |
250 | 254 |
251 // On success or partial success, return the result | 255 // On success or partial success, return the result |
252 return result; | 256 return result; |
253 } | 257 } |
254 } | 258 } |
255 | 259 |
256 SkCodecPrintf("Error: No matching candidate image in ico.\n"); | 260 SkCodecPrintf("Error: No matching candidate image in ico.\n"); |
257 return result; | 261 return result; |
258 } | 262 } |
OLD | NEW |