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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/bmp/BMPImageReader.cpp

Issue 2756463003: Remove opaque alpha channel special case (Closed)
Patch Set: Checking if JPEGImageDecoder::OutputScanlines()'s SetHasAlpha(true) is under test Created 3 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 side-by-side diff with in-line comments
Download patch
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),

Powered by Google App Engine
This is Rietveld 408576698