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

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

Issue 2807073002: Removed local RefPtr objects created from PassRefPtr arguments. (Closed)
Patch Set: addressed review Created 3 years, 8 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_complete_;
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 PassRefPtr<SharedBuffer> pass_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 RefPtr<SharedBuffer> data = pass_data;
66
67 std::unique_ptr<ImageDecoder> actual_decoder = 65 std::unique_ptr<ImageDecoder> actual_decoder =
68 ImageDecoder::Create(data, data_complete, alpha_option, color_behavior); 66 ImageDecoder::Create(data, data_complete, alpha_option, color_behavior);
69 if (!actual_decoder) 67 if (!actual_decoder)
70 return nullptr; 68 return nullptr;
71 69
72 std::unique_ptr<DeferredImageDecoder> decoder( 70 std::unique_ptr<DeferredImageDecoder> decoder(
73 new DeferredImageDecoder(std::move(actual_decoder))); 71 new DeferredImageDecoder(std::move(actual_decoder)));
74 72
75 // Since we've just instantiated a fresh decoder, there's no need to reset its 73 // Since we've just instantiated a fresh decoder, there's no need to reset its
76 // data. 74 // data.
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 shared_buffer->Append(static_cast<const char*>(it.data()), it.size()); 137 shared_buffer->Append(static_cast<const char*>(it.data()), it.size());
140 } while (it.next()); 138 } while (it.next());
141 return shared_buffer.Release(); 139 return shared_buffer.Release();
142 } 140 }
143 141
144 void DeferredImageDecoder::SetData(PassRefPtr<SharedBuffer> data, 142 void DeferredImageDecoder::SetData(PassRefPtr<SharedBuffer> data,
145 bool all_data_received) { 143 bool all_data_received) {
146 SetDataInternal(std::move(data), all_data_received, true); 144 SetDataInternal(std::move(data), all_data_received, true);
147 } 145 }
148 146
149 void DeferredImageDecoder::SetDataInternal(PassRefPtr<SharedBuffer> pass_data, 147 void DeferredImageDecoder::SetDataInternal(RefPtr<SharedBuffer> data,
150 bool all_data_received, 148 bool all_data_received,
151 bool push_data_to_decoder) { 149 bool push_data_to_decoder) {
152 RefPtr<SharedBuffer> data = pass_data;
153 if (actual_decoder_) { 150 if (actual_decoder_) {
154 all_data_received_ = all_data_received; 151 all_data_received_ = all_data_received;
155 if (push_data_to_decoder) 152 if (push_data_to_decoder)
156 actual_decoder_->SetData(data, all_data_received); 153 actual_decoder_->SetData(data, all_data_received);
157 PrepareLazyDecodedFrames(); 154 PrepareLazyDecodedFrames();
158 } 155 }
159 156
160 if (frame_generator_) { 157 if (frame_generator_) {
161 if (!rw_buffer_) 158 if (!rw_buffer_)
162 rw_buffer_ = WTF::WrapUnique(new SkRWBuffer(data->size())); 159 rw_buffer_ = WTF::WrapUnique(new SkRWBuffer(data->size()));
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 358
362 namespace WTF { 359 namespace WTF {
363 template <> 360 template <>
364 struct VectorTraits<blink::DeferredFrameData> 361 struct VectorTraits<blink::DeferredFrameData>
365 : public SimpleClassVectorTraits<blink::DeferredFrameData> { 362 : public SimpleClassVectorTraits<blink::DeferredFrameData> {
366 STATIC_ONLY(VectorTraits); 363 STATIC_ONLY(VectorTraits);
367 static const bool kCanInitializeWithMemset = 364 static const bool kCanInitializeWithMemset =
368 false; // Not all DeferredFrameData members initialize to 0. 365 false; // Not all DeferredFrameData members initialize to 0.
369 }; 366 };
370 } 367 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698