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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 1437413002: cc: Remove ScopedPtrVector and cc::remove_if. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/numerics/safe_conversions.h" 8 #include "base/numerics/safe_conversions.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 child->SetParent(this); 128 child->SetParent(this);
129 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl()); 129 DCHECK_EQ(layer_tree_impl(), child->layer_tree_impl());
130 children_.push_back(child.Pass()); 130 children_.push_back(child.Pass());
131 layer_tree_impl()->set_needs_update_draw_properties(); 131 layer_tree_impl()->set_needs_update_draw_properties();
132 } 132 }
133 133
134 scoped_ptr<LayerImpl> LayerImpl::RemoveChild(LayerImpl* child) { 134 scoped_ptr<LayerImpl> LayerImpl::RemoveChild(LayerImpl* child) {
135 for (OwnedLayerImplList::iterator it = children_.begin(); 135 for (OwnedLayerImplList::iterator it = children_.begin();
136 it != children_.end(); 136 it != children_.end();
137 ++it) { 137 ++it) {
138 if (*it == child) { 138 if (it->get() == child) {
139 scoped_ptr<LayerImpl> ret = children_.take(it); 139 scoped_ptr<LayerImpl> ret = it->Pass();
140 children_.erase(it); 140 children_.erase(it);
141 layer_tree_impl()->set_needs_update_draw_properties(); 141 layer_tree_impl()->set_needs_update_draw_properties();
142 return ret.Pass(); 142 return ret;
143 } 143 }
144 } 144 }
145 return nullptr; 145 return nullptr;
146 } 146 }
147 147
148 void LayerImpl::SetParent(LayerImpl* parent) { 148 void LayerImpl::SetParent(LayerImpl* parent) {
149 if (parent_should_know_need_push_properties()) { 149 if (parent_should_know_need_push_properties()) {
150 if (parent_) 150 if (parent_)
151 parent_->RemoveDependentNeedsPushProperties(); 151 parent_->RemoveDependentNeedsPushProperties();
152 if (parent) 152 if (parent)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 void LayerImpl::SetClipTreeIndex(int index) { 253 void LayerImpl::SetClipTreeIndex(int index) {
254 clip_tree_index_ = index; 254 clip_tree_index_ = index;
255 SetNeedsPushProperties(); 255 SetNeedsPushProperties();
256 } 256 }
257 257
258 void LayerImpl::SetEffectTreeIndex(int index) { 258 void LayerImpl::SetEffectTreeIndex(int index) {
259 effect_tree_index_ = index; 259 effect_tree_index_ = index;
260 SetNeedsPushProperties(); 260 SetNeedsPushProperties();
261 } 261 }
262 262
263 void LayerImpl::PassCopyRequests(ScopedPtrVector<CopyOutputRequest>* requests) { 263 void LayerImpl::PassCopyRequests(
264 std::vector<scoped_ptr<CopyOutputRequest>>* requests) {
264 // In the case that a layer still has a copy request, this means that there's 265 // In the case that a layer still has a copy request, this means that there's
265 // a commit to the active tree without a draw. This only happens in some 266 // a commit to the active tree without a draw. This only happens in some
266 // edge cases during lost context or visibility changes, so don't try to 267 // edge cases during lost context or visibility changes, so don't try to
267 // handle preserving these output requests (and their surface). 268 // handle preserving these output requests (and their surface).
268 if (!copy_requests_.empty()) { 269 if (!copy_requests_.empty()) {
269 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); 270 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
270 // Destroying these will abort them. 271 // Destroying these will abort them.
271 copy_requests_.clear(); 272 copy_requests_.clear();
272 } 273 }
273 274
274 if (requests->empty()) 275 if (requests->empty())
275 return; 276 return;
276 277
277 DCHECK(render_surface()); 278 DCHECK(render_surface());
278 bool was_empty = copy_requests_.empty(); 279 bool was_empty = copy_requests_.empty();
279 copy_requests_.insert_and_take(copy_requests_.end(), requests); 280 for (auto& request : *requests)
281 copy_requests_.push_back(std::move(request));
280 requests->clear(); 282 requests->clear();
281 283
282 if (was_empty && layer_tree_impl()->IsActiveTree()) 284 if (was_empty && layer_tree_impl()->IsActiveTree())
283 layer_tree_impl()->AddLayerWithCopyOutputRequest(this); 285 layer_tree_impl()->AddLayerWithCopyOutputRequest(this);
284 NoteLayerPropertyChangedForSubtree(); 286 NoteLayerPropertyChangedForSubtree();
285 } 287 }
286 288
287 void LayerImpl::TakeCopyRequestsAndTransformToTarget( 289 void LayerImpl::TakeCopyRequestsAndTransformToTarget(
288 ScopedPtrVector<CopyOutputRequest>* requests) { 290 std::vector<scoped_ptr<CopyOutputRequest>>* requests) {
289 DCHECK(!copy_requests_.empty()); 291 DCHECK(!copy_requests_.empty());
290 DCHECK(layer_tree_impl()->IsActiveTree()); 292 DCHECK(layer_tree_impl()->IsActiveTree());
291 DCHECK_EQ(render_target(), this); 293 DCHECK_EQ(render_target(), this);
292 294
293 size_t first_inserted_request = requests->size(); 295 size_t first_inserted_request = requests->size();
294 requests->insert_and_take(requests->end(), &copy_requests_); 296 for (auto& request : copy_requests_)
297 requests->push_back(std::move(request));
295 copy_requests_.clear(); 298 copy_requests_.clear();
296 299
297 for (size_t i = first_inserted_request; i < requests->size(); ++i) { 300 for (size_t i = first_inserted_request; i < requests->size(); ++i) {
298 CopyOutputRequest* request = requests->at(i); 301 CopyOutputRequest* request = (*requests)[i].get();
299 if (!request->has_area()) 302 if (!request->has_area())
300 continue; 303 continue;
301 304
302 gfx::Rect request_in_layer_space = request->area(); 305 gfx::Rect request_in_layer_space = request->area();
303 request_in_layer_space.Intersect(gfx::Rect(bounds())); 306 request_in_layer_space.Intersect(gfx::Rect(bounds()));
304 request->set_area(MathUtil::MapEnclosingClippedRect( 307 request->set_area(MathUtil::MapEnclosingClippedRect(
305 draw_properties_.target_space_transform, request_in_layer_space)); 308 draw_properties_.target_space_transform, request_in_layer_space));
306 } 309 }
307 310
308 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this); 311 layer_tree_impl()->RemoveLayerWithCopyOutputRequest(this);
(...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 } 1801 }
1799 1802
1800 // TODO(enne): the transform needs to come from property trees instead of 1803 // TODO(enne): the transform needs to come from property trees instead of
1801 // draw properties. 1804 // draw properties.
1802 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents( 1805 gfx::Vector2dF transform_scales = MathUtil::ComputeTransform2dScaleComponents(
1803 draw_properties().target_space_transform, default_scale); 1806 draw_properties().target_space_transform, default_scale);
1804 return std::max(transform_scales.x(), transform_scales.y()); 1807 return std::max(transform_scales.x(), transform_scales.y());
1805 } 1808 }
1806 1809
1807 } // namespace cc 1810 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/layer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698