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

Unified Diff: third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.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/gif/GIFImageDecoder.cpp
diff --git a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
index b954a982e6fbc2decfe0c22117ab6573de011dc8..767f132341f36b4cdf99117e4836bde489b8d19e 100644
--- a/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
+++ b/third_party/WebKit/Source/platform/image-decoders/gif/GIFImageDecoder.cpp
@@ -159,7 +159,6 @@ bool GIFImageDecoder::HaveDecodedRow(size_t frame_index,
*current_address = color_table_iter[source_value];
} else {
*current_address = 0;
- current_buffer_saw_alpha_ = true;
}
}
} else {
@@ -168,8 +167,6 @@ bool GIFImageDecoder::HaveDecodedRow(size_t frame_index,
if ((source_value != transparent_pixel) &&
(source_value < color_table.size()))
*current_address = color_table_iter[source_value];
- else
- current_buffer_saw_alpha_ = true;
}
}
@@ -191,10 +188,17 @@ bool GIFImageDecoder::FrameComplete(size_t frame_index) {
if (!InitFrameBuffer(frame_index))
return SetFailed();
- if (!current_buffer_saw_alpha_)
- CorrectAlphaWhenFrameBufferSawNoAlpha(frame_index);
+ ImageFrame& buffer = frame_buffer_cache_[frame_index];
+
+ const GIFFrameContext* frame_context = reader_->FrameContext(frame_index);
+ const size_t transparent_pixel = frame_context->TransparentPixel();
+ const GIFColorMap::Table& color_table =
+ frame_context->LocalColorMap().IsDefined()
+ ? frame_context->LocalColorMap().GetTable()
+ : reader_->GlobalColorMap().GetTable();
+ buffer.SetHasAlpha(transparent_pixel <= color_table.size());
- frame_buffer_cache_[frame_index].SetStatus(ImageFrame::kFrameComplete);
+ buffer.SetStatus(ImageFrame::kFrameComplete);
return true;
}
@@ -269,10 +273,6 @@ void GIFImageDecoder::Parse(GIFParseQuery query) {
SetFailed();
}
-void GIFImageDecoder::OnInitFrameBuffer(size_t frame_index) {
- current_buffer_saw_alpha_ = false;
-}
-
bool GIFImageDecoder::CanReusePreviousFrameBuffer(size_t frame_index) const {
DCHECK(frame_index < frame_buffer_cache_.size());
return frame_buffer_cache_[frame_index].GetDisposalMethod() !=

Powered by Google App Engine
This is Rietveld 408576698