OLD | NEW |
---|---|
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 == 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.Pass(); |
danakj
2015/11/17 01:12:17
oops, shame on me
vmpstr
2015/11/17 23:26:24
Done.
| |
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 Loading... | |
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 it = requests->begin(); it != requests->end(); ++it) |
ericrk
2015/11/16 21:59:49
not sure if we can use it, but a more C++11-y way
danakj
2015/11/17 01:12:17
Cool! Someone should propose it to cxx@ now that m
vmpstr
2015/11/17 23:26:23
I could do it as
std::move(requests->begin(), re
vmpstr
2015/11/17 23:26:24
Done.
| |
281 copy_requests_.push_back(it->Pass()); | |
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(), ©_requests_); | 296 for (auto it = copy_requests_.begin(); it != copy_requests_.end(); ++it) |
ericrk
2015/11/16 21:59:49
same here.
| |
297 requests->push_back(it->Pass()); | |
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 Loading... | |
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 |
OLD | NEW |