Index: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp |
diff --git a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp |
index 4426dfd7af5dff491a2e3b93404f2ee0c944a1eb..07bbe6d8f78f1fafdcf11b0ab844d88026d1bb3c 100644 |
--- a/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp |
+++ b/third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp |
@@ -146,7 +146,7 @@ bool BMPImageReader::DecodeBMP(bool only_size) { |
// If the image has an AND mask and there was no alpha data, process the |
// mask. |
if (is_in_ico_ && !decoding_and_mask_ && |
- ((info_header_.bi_bit_count < 16) || !bit_masks_[3] || |
+ ((info_header_.bi_bit_count < 16) || !IsAlphaSupported() || |
!seen_non_zero_alpha_pixel_)) { |
// Reset decoding coordinates to start of image. |
coord_.SetX(0); |
@@ -817,20 +817,21 @@ BMPImageReader::ProcessingResult BMPImageReader::ProcessNonRLEData( |
// until we actually see a non-zero alpha value; at that point, |
// reset any previously-decoded pixels to fully transparent and |
// continue decoding based on the real alpha channel values. |
- // As an optimization, avoid calling SetHasAlpha(true) for |
- // images where all alpha values are 255; opaque images are |
- // faster to draw. |
- int alpha = GetAlpha(pixel); |
- if (!seen_non_zero_alpha_pixel_ && !alpha) { |
- seen_zero_alpha_pixel_ = true; |
- alpha = 255; |
- } else { |
- seen_non_zero_alpha_pixel_ = true; |
- if (seen_zero_alpha_pixel_) { |
- buffer_->ZeroFillPixelData(); |
- seen_zero_alpha_pixel_ = false; |
- } else if (alpha != 255) |
- buffer_->SetHasAlpha(true); |
+ int alpha = 255; |
+ if (IsAlphaSupported()) { |
+ alpha = GetAlpha(pixel); |
+ if (!seen_non_zero_alpha_pixel_ && !alpha) { |
+ seen_zero_alpha_pixel_ = true; |
+ alpha = 255; |
+ } else { |
+ seen_non_zero_alpha_pixel_ = true; |
+ if (seen_zero_alpha_pixel_) { |
+ buffer_->ZeroFillPixelData(); |
+ seen_zero_alpha_pixel_ = false; |
+ } else if (alpha != 255) { |
+ buffer_->SetHasAlpha(true); |
+ } |
+ } |
} |
SetRGBA(GetComponent(pixel, 0), GetComponent(pixel, 1), |