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

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

Issue 1321913003: Fix bug in ico decodes (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 // We return invalid scale if there is no candidate image with matching 249 // We return invalid scale if there is no candidate image with matching
250 // dimensions. 250 // dimensions.
251 Result result = kInvalidScale; 251 Result result = kInvalidScale;
252 for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) { 252 for (int32_t i = 0; i < fEmbeddedCodecs->count(); i++) {
253 SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](i); 253 SkCodec* embeddedCodec = fEmbeddedCodecs->operator[](i);
254 // If the dimensions match, try to decode 254 // If the dimensions match, try to decode
255 if (dstInfo.dimensions() == embeddedCodec->getInfo().dimensions()) { 255 if (dstInfo.dimensions() == embeddedCodec->getInfo().dimensions()) {
256 256
257 // Perform the decode 257 // Perform the decode
258 // FIXME: (msarett): ICO is considered non-opaque, even if the embed ded BMP 258 // FIXME (msarett): ICO is considered non-opaque, even if the embedd ed BMP
259 // incorrectly claims it has no alpha. 259 // incorrectly claims it has no alpha.
260 SkImageInfo info = dstInfo.makeAlphaType(embeddedCodec->getInfo().al phaType()); 260 SkAlphaType embeddedAlpha = embeddedCodec->getInfo().alphaType();
261 result = embeddedCodec->getPixels(info, dst, dstRowBytes, &opts, ct, ptr); 261 switch (embeddedAlpha) {
262 case kPremul_SkAlphaType:
263 case kUnpremul_SkAlphaType:
264 // Use the requested alpha type if the embedded codec suppor ts alpha.
265 embeddedAlpha = dstInfo.alphaType();
scroggo 2015/09/02 21:50:54 I suppose this is safe because dstInfo.alphaType()
msarett 2015/09/02 21:56:36 Yes - we always guess that ICOs have alpha (and th
266 break;
267 case kOpaque_SkAlphaType:
268 // If the embedded codec claims it is opaque, decode as if i t is opaque.
269 break;
270 default:
271 SkASSERT(false);
272 break;
273 }
274 SkImageInfo info = dstInfo.makeAlphaType(embeddedAlpha);
275 result = embeddedCodec->getPixels(dstInfo, dst, dstRowBytes, &opts, ct, ptr);
262 276
263 // On a fatal error, keep trying to find an image to decode 277 // On a fatal error, keep trying to find an image to decode
264 if (kInvalidConversion == result || kInvalidInput == result || 278 if (kInvalidConversion == result || kInvalidInput == result ||
265 kInvalidScale == result) { 279 kInvalidScale == result) {
266 SkCodecPrintf("Warning: Attempt to decode candidate ico failed.\ n"); 280 SkCodecPrintf("Warning: Attempt to decode candidate ico failed.\ n");
267 continue; 281 continue;
268 } 282 }
269 283
270 // On success or partial success, return the result 284 // On success or partial success, return the result
271 return result; 285 return result;
272 } 286 }
273 } 287 }
274 288
275 SkCodecPrintf("Error: No matching candidate image in ico.\n"); 289 SkCodecPrintf("Error: No matching candidate image in ico.\n");
276 return result; 290 return result;
277 } 291 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698