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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/webp/WEBPImageDecoder.cpp

Issue 2878363003: Revert of Fix ImageAnimation constant names after Blink renaming (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 WEBPImageDecoder::WEBPImageDecoder(AlphaOption alpha_option, 119 WEBPImageDecoder::WEBPImageDecoder(AlphaOption alpha_option,
120 const ColorBehavior& color_behavior, 120 const ColorBehavior& color_behavior,
121 size_t max_decoded_bytes) 121 size_t max_decoded_bytes)
122 : ImageDecoder(alpha_option, color_behavior, max_decoded_bytes), 122 : ImageDecoder(alpha_option, color_behavior, max_decoded_bytes),
123 decoder_(0), 123 decoder_(0),
124 format_flags_(0), 124 format_flags_(0),
125 frame_background_has_alpha_(false), 125 frame_background_has_alpha_(false),
126 demux_(0), 126 demux_(0),
127 demux_state_(WEBP_DEMUX_PARSING_HEADER), 127 demux_state_(WEBP_DEMUX_PARSING_HEADER),
128 have_already_parsed_this_data_(false), 128 have_already_parsed_this_data_(false),
129 repetition_count_(kAnimationLoopOnce), 129 repetition_count_(kCAnimationLoopOnce),
130 decoded_height_(0) { 130 decoded_height_(0) {
131 blend_function_ = (alpha_option == kAlphaPremultiplied) 131 blend_function_ = (alpha_option == kAlphaPremultiplied)
132 ? alphaBlendPremultiplied 132 ? alphaBlendPremultiplied
133 : alphaBlendNonPremultiplied; 133 : alphaBlendNonPremultiplied;
134 } 134 }
135 135
136 WEBPImageDecoder::~WEBPImageDecoder() { 136 WEBPImageDecoder::~WEBPImageDecoder() {
137 Clear(); 137 Clear();
138 } 138 }
139 139
140 void WEBPImageDecoder::Clear() { 140 void WEBPImageDecoder::Clear() {
141 WebPDemuxDelete(demux_); 141 WebPDemuxDelete(demux_);
142 demux_ = 0; 142 demux_ = 0;
143 consolidated_data_.reset(); 143 consolidated_data_.reset();
144 ClearDecoder(); 144 ClearDecoder();
145 } 145 }
146 146
147 void WEBPImageDecoder::ClearDecoder() { 147 void WEBPImageDecoder::ClearDecoder() {
148 WebPIDelete(decoder_); 148 WebPIDelete(decoder_);
149 decoder_ = 0; 149 decoder_ = 0;
150 decoded_height_ = 0; 150 decoded_height_ = 0;
151 frame_background_has_alpha_ = false; 151 frame_background_has_alpha_ = false;
152 } 152 }
153 153
154 void WEBPImageDecoder::OnSetData(SegmentReader*) { 154 void WEBPImageDecoder::OnSetData(SegmentReader*) {
155 have_already_parsed_this_data_ = false; 155 have_already_parsed_this_data_ = false;
156 } 156 }
157 157
158 int WEBPImageDecoder::RepetitionCount() const { 158 int WEBPImageDecoder::RepetitionCount() const {
159 return Failed() ? kAnimationLoopOnce : repetition_count_; 159 return Failed() ? kCAnimationLoopOnce : repetition_count_;
160 } 160 }
161 161
162 bool WEBPImageDecoder::FrameIsCompleteAtIndex(size_t index) const { 162 bool WEBPImageDecoder::FrameIsCompleteAtIndex(size_t index) const {
163 if (!demux_ || demux_state_ <= WEBP_DEMUX_PARSING_HEADER) 163 if (!demux_ || demux_state_ <= WEBP_DEMUX_PARSING_HEADER)
164 return false; 164 return false;
165 if (!(format_flags_ & ANIMATION_FLAG)) 165 if (!(format_flags_ & ANIMATION_FLAG))
166 return ImageDecoder::FrameIsCompleteAtIndex(index); 166 return ImageDecoder::FrameIsCompleteAtIndex(index);
167 bool frame_is_received_at_index = index < frame_buffer_cache_.size(); 167 bool frame_is_received_at_index = index < frame_buffer_cache_.size();
168 return frame_is_received_at_index; 168 return frame_is_received_at_index;
169 } 169 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 return false; // Wait until the encoded image frame data arrives. 204 return false; // Wait until the encoded image frame data arrives.
205 205
206 if (!IsDecodedSizeAvailable()) { 206 if (!IsDecodedSizeAvailable()) {
207 int width = WebPDemuxGetI(demux_, WEBP_FF_CANVAS_WIDTH); 207 int width = WebPDemuxGetI(demux_, WEBP_FF_CANVAS_WIDTH);
208 int height = WebPDemuxGetI(demux_, WEBP_FF_CANVAS_HEIGHT); 208 int height = WebPDemuxGetI(demux_, WEBP_FF_CANVAS_HEIGHT);
209 if (!SetSize(width, height)) 209 if (!SetSize(width, height))
210 return SetFailed(); 210 return SetFailed();
211 211
212 format_flags_ = WebPDemuxGetI(demux_, WEBP_FF_FORMAT_FLAGS); 212 format_flags_ = WebPDemuxGetI(demux_, WEBP_FF_FORMAT_FLAGS);
213 if (!(format_flags_ & ANIMATION_FLAG)) { 213 if (!(format_flags_ & ANIMATION_FLAG)) {
214 repetition_count_ = kAnimationNone; 214 repetition_count_ = kCAnimationNone;
215 } else { 215 } else {
216 // Since we have parsed at least one frame, even if partially, 216 // Since we have parsed at least one frame, even if partially,
217 // the global animation (ANIM) properties have been read since 217 // the global animation (ANIM) properties have been read since
218 // an ANIM chunk must precede the ANMF frame chunks. 218 // an ANIM chunk must precede the ANMF frame chunks.
219 repetition_count_ = WebPDemuxGetI(demux_, WEBP_FF_LOOP_COUNT); 219 repetition_count_ = WebPDemuxGetI(demux_, WEBP_FF_LOOP_COUNT);
220 // Repetition count is always <= 16 bits. 220 // Repetition count is always <= 16 bits.
221 DCHECK_EQ(repetition_count_, repetition_count_ & 0xffff); 221 DCHECK_EQ(repetition_count_, repetition_count_ & 0xffff);
222 if (!repetition_count_) 222 if (!repetition_count_)
223 repetition_count_ = kAnimationLoopInfinite; 223 repetition_count_ = kCAnimationLoopInfinite;
224 // FIXME: Implement ICC profile support for animated images. 224 // FIXME: Implement ICC profile support for animated images.
225 format_flags_ &= ~ICCP_FLAG; 225 format_flags_ &= ~ICCP_FLAG;
226 } 226 }
227 227
228 if ((format_flags_ & ICCP_FLAG) && !IgnoresColorSpace()) 228 if ((format_flags_ & ICCP_FLAG) && !IgnoresColorSpace())
229 ReadColorProfile(); 229 ReadColorProfile();
230 } 230 }
231 231
232 DCHECK(IsDecodedSizeAvailable()); 232 DCHECK(IsDecodedSizeAvailable());
233 233
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 return false; 516 return false;
517 } 517 }
518 // FALLTHROUGH 518 // FALLTHROUGH
519 default: 519 default:
520 Clear(); 520 Clear();
521 return SetFailed(); 521 return SetFailed();
522 } 522 }
523 } 523 }
524 524
525 } // namespace blink 525 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698