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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/DeferredImageDecoder.cpp

Issue 2982083002: FrameIsCompleteAtIndex to FrameIsReceivedAtIndex (Closed)
Patch Set: Update upstack from ImageDecoder Created 3 years, 5 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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 28 matching lines...) Expand all
39 namespace blink { 39 namespace blink {
40 40
41 struct DeferredFrameData { 41 struct DeferredFrameData {
42 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 42 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
43 WTF_MAKE_NONCOPYABLE(DeferredFrameData); 43 WTF_MAKE_NONCOPYABLE(DeferredFrameData);
44 44
45 public: 45 public:
46 DeferredFrameData() 46 DeferredFrameData()
47 : orientation_(kDefaultImageOrientation), 47 : orientation_(kDefaultImageOrientation),
48 duration_(0), 48 duration_(0),
49 is_complete_(false), 49 is_received_(false),
50 frame_bytes_(0), 50 frame_bytes_(0),
51 unique_id_(DecodingImageGenerator::kNeedNewImageUniqueID) {} 51 unique_id_(DecodingImageGenerator::kNeedNewImageUniqueID) {}
52 52
53 ImageOrientation orientation_; 53 ImageOrientation orientation_;
54 float duration_; 54 float duration_;
55 bool is_complete_; 55 bool is_received_;
56 size_t frame_bytes_; 56 size_t frame_bytes_;
57 uint32_t unique_id_; 57 uint32_t unique_id_;
58 }; 58 };
59 59
60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::Create( 60 std::unique_ptr<DeferredImageDecoder> DeferredImageDecoder::Create(
61 RefPtr<SharedBuffer> data, 61 RefPtr<SharedBuffer> data,
62 bool data_complete, 62 bool data_complete,
63 ImageDecoder::AlphaOption alpha_option, 63 ImageDecoder::AlphaOption alpha_option,
64 const ColorBehavior& color_behavior) { 64 const ColorBehavior& color_behavior) {
65 std::unique_ptr<ImageDecoder> actual_decoder = 65 std::unique_ptr<ImageDecoder> actual_decoder =
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 bool DeferredImageDecoder::FrameHasAlphaAtIndex(size_t index) const { 214 bool DeferredImageDecoder::FrameHasAlphaAtIndex(size_t index) const {
215 if (actual_decoder_) 215 if (actual_decoder_)
216 return actual_decoder_->FrameHasAlphaAtIndex(index); 216 return actual_decoder_->FrameHasAlphaAtIndex(index);
217 if (!frame_generator_->IsMultiFrame()) 217 if (!frame_generator_->IsMultiFrame())
218 return frame_generator_->HasAlpha(index); 218 return frame_generator_->HasAlpha(index);
219 return true; 219 return true;
220 } 220 }
221 221
222 bool DeferredImageDecoder::FrameIsCompleteAtIndex(size_t index) const { 222 bool DeferredImageDecoder::FrameIsReceivedAtIndex(size_t index) const {
223 if (actual_decoder_) 223 if (actual_decoder_)
224 return actual_decoder_->FrameIsCompleteAtIndex(index); 224 return actual_decoder_->FrameIsReceivedAtIndex(index);
225 if (index < frame_data_.size()) 225 if (index < frame_data_.size())
226 return frame_data_[index].is_complete_; 226 return frame_data_[index].is_received_;
227 return false; 227 return false;
228 } 228 }
229 229
230 float DeferredImageDecoder::FrameDurationAtIndex(size_t index) const { 230 float DeferredImageDecoder::FrameDurationAtIndex(size_t index) const {
231 if (actual_decoder_) 231 if (actual_decoder_)
232 return actual_decoder_->FrameDurationAtIndex(index); 232 return actual_decoder_->FrameDurationAtIndex(index);
233 if (index < frame_data_.size()) 233 if (index < frame_data_.size())
234 return frame_data_[index].duration_; 234 return frame_data_[index].duration_;
235 return 0; 235 return 0;
236 } 236 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 const size_t previous_size = frame_data_.size(); 284 const size_t previous_size = frame_data_.size();
285 frame_data_.resize(actual_decoder_->FrameCount()); 285 frame_data_.resize(actual_decoder_->FrameCount());
286 286
287 // We have encountered a broken image file. Simply bail. 287 // We have encountered a broken image file. Simply bail.
288 if (frame_data_.size() < previous_size) 288 if (frame_data_.size() < previous_size)
289 return; 289 return;
290 290
291 for (size_t i = previous_size; i < frame_data_.size(); ++i) { 291 for (size_t i = previous_size; i < frame_data_.size(); ++i) {
292 frame_data_[i].duration_ = actual_decoder_->FrameDurationAtIndex(i); 292 frame_data_[i].duration_ = actual_decoder_->FrameDurationAtIndex(i);
293 frame_data_[i].orientation_ = actual_decoder_->Orientation(); 293 frame_data_[i].orientation_ = actual_decoder_->Orientation();
294 frame_data_[i].is_complete_ = actual_decoder_->FrameIsCompleteAtIndex(i); 294 frame_data_[i].is_received_ = actual_decoder_->FrameIsReceivedAtIndex(i);
295 } 295 }
296 296
297 // The last lazy decoded frame created from previous call might be 297 // The last lazy decoded frame created from previous call might be
298 // incomplete so update its state. 298 // incomplete so update its state.
299 if (previous_size) { 299 if (previous_size) {
300 const size_t last_frame = previous_size - 1; 300 const size_t last_frame = previous_size - 1;
301 frame_data_[last_frame].is_complete_ = 301 frame_data_[last_frame].is_received_ =
302 actual_decoder_->FrameIsCompleteAtIndex(last_frame); 302 actual_decoder_->FrameIsReceivedAtIndex(last_frame);
303 } 303 }
304 304
305 if (all_data_received_) { 305 if (all_data_received_) {
306 repetition_count_ = actual_decoder_->RepetitionCount(); 306 repetition_count_ = actual_decoder_->RepetitionCount();
307 actual_decoder_.reset(); 307 actual_decoder_.reset();
308 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex. 308 // Hold on to m_rwBuffer, which is still needed by createFrameAtIndex.
309 } 309 }
310 } 310 }
311 311
312 sk_sp<SkImage> DeferredImageDecoder::CreateFrameImageAtIndex( 312 sk_sp<SkImage> DeferredImageDecoder::CreateFrameImageAtIndex(
(...skipping 16 matching lines...) Expand all
329 frame_generator_, info, std::move(segment_reader), all_data_received_, 329 frame_generator_, info, std::move(segment_reader), all_data_received_,
330 index, frame_data_[index].unique_id_); 330 index, frame_data_[index].unique_id_);
331 generator->SetCanYUVDecode(can_yuv_decode_); 331 generator->SetCanYUVDecode(can_yuv_decode_);
332 sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(generator)); 332 sk_sp<SkImage> image = SkImage::MakeFromGenerator(std::move(generator));
333 if (!image) 333 if (!image)
334 return nullptr; 334 return nullptr;
335 335
336 // We can consider decoded bitmap constant and reuse uniqueID only after all 336 // We can consider decoded bitmap constant and reuse uniqueID only after all
337 // data is received. We reuse it also for multiframe images when image data 337 // data is received. We reuse it also for multiframe images when image data
338 // is partially received but the frame data is fully received. 338 // is partially received but the frame data is fully received.
339 if (all_data_received_ || frame_data_[index].is_complete_) { 339 if (all_data_received_ || frame_data_[index].is_received_) {
340 DCHECK(frame_data_[index].unique_id_ == 340 DCHECK(frame_data_[index].unique_id_ ==
341 DecodingImageGenerator::kNeedNewImageUniqueID || 341 DecodingImageGenerator::kNeedNewImageUniqueID ||
342 frame_data_[index].unique_id_ == image->uniqueID()); 342 frame_data_[index].unique_id_ == image->uniqueID());
343 frame_data_[index].unique_id_ = image->uniqueID(); 343 frame_data_[index].unique_id_ = image->uniqueID();
344 } 344 }
345 345
346 return image; 346 return image;
347 } 347 }
348 348
349 bool DeferredImageDecoder::HotSpot(IntPoint& hot_spot) const { 349 bool DeferredImageDecoder::HotSpot(IntPoint& hot_spot) const {
350 if (actual_decoder_) 350 if (actual_decoder_)
351 return actual_decoder_->HotSpot(hot_spot); 351 return actual_decoder_->HotSpot(hot_spot);
352 if (has_hot_spot_) 352 if (has_hot_spot_)
353 hot_spot = hot_spot_; 353 hot_spot = hot_spot_;
354 return has_hot_spot_; 354 return has_hot_spot_;
355 } 355 }
356 356
357 } // namespace blink 357 } // namespace blink
358 358
359 namespace WTF { 359 namespace WTF {
360 template <> 360 template <>
361 struct VectorTraits<blink::DeferredFrameData> 361 struct VectorTraits<blink::DeferredFrameData>
362 : public SimpleClassVectorTraits<blink::DeferredFrameData> { 362 : public SimpleClassVectorTraits<blink::DeferredFrameData> {
363 STATIC_ONLY(VectorTraits); 363 STATIC_ONLY(VectorTraits);
364 static const bool kCanInitializeWithMemset = 364 static const bool kCanInitializeWithMemset =
365 false; // Not all DeferredFrameData members initialize to 0. 365 false; // Not all DeferredFrameData members initialize to 0.
366 }; 366 };
367 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698