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

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

Issue 1949773002: Fix ICO bug exposed by the fuzzer (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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 | src/codec/SkBmpStandardCodec.cpp » ('j') | 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 "SkBmpMaskCodec.h" 9 #include "SkBmpMaskCodec.h"
10 #include "SkBmpRLECodec.h" 10 #include "SkBmpRLECodec.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 // since we will need to apply a transparency mask. 435 // since we will need to apply a transparency mask.
436 if (inIco) { 436 if (inIco) {
437 color = SkEncodedInfo::kBGRA_Color; 437 color = SkEncodedInfo::kBGRA_Color;
438 bitsPerComponent = 8; 438 bitsPerComponent = 8;
439 } else { 439 } else {
440 color = SkEncodedInfo::kPalette_Color; 440 color = SkEncodedInfo::kPalette_Color;
441 bitsPerComponent = (uint8_t) bitsPerPixel; 441 bitsPerComponent = (uint8_t) bitsPerPixel;
442 } 442 }
443 break; 443 break;
444 case 24: 444 case 24:
445 color = SkEncodedInfo::kBGR_Color; 445 // In the case of ICO, kBGRA is actually the closest match,
446 // since we will need to apply a transparency mask.
447 color = inIco ? SkEncodedInfo::kBGRA_Color : SkEncodedInfo:: kBGR_Color;
446 bitsPerComponent = 8; 448 bitsPerComponent = 8;
447 break; 449 break;
448 case 32: 450 case 32:
449 // 32-bit BMP-in-ICOs actually use the alpha channel in plac e of a 451 // 32-bit BMP-in-ICOs actually use the alpha channel in plac e of a
450 // transparency mask. 452 // transparency mask.
451 if (inIco) { 453 if (inIco) {
452 isOpaque = false; 454 isOpaque = false;
453 alpha = SkEncodedInfo::kUnpremul_Alpha; 455 alpha = SkEncodedInfo::kUnpremul_Alpha;
454 color = SkEncodedInfo::kBGRA_Color; 456 color = SkEncodedInfo::kBGRA_Color;
455 } else { 457 } else {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 } 620 }
619 621
620 bool SkBmpCodec::skipRows(int count) { 622 bool SkBmpCodec::skipRows(int count) {
621 const size_t bytesToSkip = count * fSrcRowBytes; 623 const size_t bytesToSkip = count * fSrcRowBytes;
622 return this->stream()->skip(bytesToSkip) == bytesToSkip; 624 return this->stream()->skip(bytesToSkip) == bytesToSkip;
623 } 625 }
624 626
625 bool SkBmpCodec::onSkipScanlines(int count) { 627 bool SkBmpCodec::onSkipScanlines(int count) {
626 return this->skipRows(count); 628 return this->skipRows(count);
627 } 629 }
OLDNEW
« no previous file with comments | « no previous file | src/codec/SkBmpStandardCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698