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/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 use_parent_backface_visibility_(false), | 56 use_parent_backface_visibility_(false), |
57 draw_checkerboard_for_missing_tiles_(false), | 57 draw_checkerboard_for_missing_tiles_(false), |
58 draws_content_(false), | 58 draws_content_(false), |
59 hide_layer_and_subtree_(false), | 59 hide_layer_and_subtree_(false), |
60 force_render_surface_(false), | 60 force_render_surface_(false), |
61 transform_is_invertible_(true), | 61 transform_is_invertible_(true), |
62 is_container_for_fixed_position_layers_(false), | 62 is_container_for_fixed_position_layers_(false), |
63 background_color_(0), | 63 background_color_(0), |
64 opacity_(1.0), | 64 opacity_(1.0), |
65 blend_mode_(SkXfermode::kSrcOver_Mode), | 65 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 66 num_descendants_that_draw_content_(0), |
66 draw_depth_(0.f), | 67 draw_depth_(0.f), |
67 needs_push_properties_(false), | 68 needs_push_properties_(false), |
68 num_dependents_need_push_properties_(0), | 69 num_dependents_need_push_properties_(0), |
69 sorting_context_id_(0), | 70 sorting_context_id_(0), |
70 current_draw_mode_(DRAW_MODE_NONE) { | 71 current_draw_mode_(DRAW_MODE_NONE) { |
71 DCHECK_GT(layer_id_, 0); | 72 DCHECK_GT(layer_id_, 0); |
72 DCHECK(layer_tree_impl_); | 73 DCHECK(layer_tree_impl_); |
73 layer_tree_impl_->RegisterLayer(this); | 74 layer_tree_impl_->RegisterLayer(this); |
74 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); | 75 AnimationRegistrar* registrar = layer_tree_impl_->animationRegistrar(); |
75 layer_animation_controller_ = | 76 layer_animation_controller_ = |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 SetNeedsPushProperties(); | 169 SetNeedsPushProperties(); |
169 } | 170 } |
170 | 171 |
171 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { | 172 void LayerImpl::SetScrollChildren(std::set<LayerImpl*>* children) { |
172 if (scroll_children_.get() == children) | 173 if (scroll_children_.get() == children) |
173 return; | 174 return; |
174 scroll_children_.reset(children); | 175 scroll_children_.reset(children); |
175 SetNeedsPushProperties(); | 176 SetNeedsPushProperties(); |
176 } | 177 } |
177 | 178 |
| 179 void LayerImpl::SetNumDescendantsThatDrawContent(int num_descendants) { |
| 180 if (num_descendants_that_draw_content_ == num_descendants) |
| 181 return; |
| 182 num_descendants_that_draw_content_ = num_descendants; |
| 183 SetNeedsPushProperties(); |
| 184 } |
| 185 |
178 void LayerImpl::SetClipParent(LayerImpl* ancestor) { | 186 void LayerImpl::SetClipParent(LayerImpl* ancestor) { |
179 if (clip_parent_ == ancestor) | 187 if (clip_parent_ == ancestor) |
180 return; | 188 return; |
181 | 189 |
182 clip_parent_ = ancestor; | 190 clip_parent_ = ancestor; |
183 SetNeedsPushProperties(); | 191 SetNeedsPushProperties(); |
184 } | 192 } |
185 | 193 |
186 void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) { | 194 void LayerImpl::SetClipChildren(std::set<LayerImpl*>* children) { |
187 if (clip_children_.get() == children) | 195 if (clip_children_.get() == children) |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 532 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
525 | 533 |
526 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() | 534 layer->SetScrollClipLayer(scroll_clip_layer_ ? scroll_clip_layer_->id() |
527 : Layer::INVALID_ID); | 535 : Layer::INVALID_ID); |
528 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 536 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
529 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 537 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
530 layer->SetScrollOffsetAndDelta( | 538 layer->SetScrollOffsetAndDelta( |
531 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | 539 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); |
532 layer->SetSentScrollDelta(gfx::Vector2d()); | 540 layer->SetSentScrollDelta(gfx::Vector2d()); |
533 layer->Set3dSortingContextId(sorting_context_id_); | 541 layer->Set3dSortingContextId(sorting_context_id_); |
| 542 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
534 | 543 |
535 LayerImpl* scroll_parent = NULL; | 544 LayerImpl* scroll_parent = NULL; |
536 if (scroll_parent_) { | 545 if (scroll_parent_) { |
537 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 546 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
538 DCHECK(scroll_parent); | 547 DCHECK(scroll_parent); |
539 } | 548 } |
540 | 549 |
541 layer->SetScrollParent(scroll_parent); | 550 layer->SetScrollParent(scroll_parent); |
542 if (scroll_children_) { | 551 if (scroll_children_) { |
543 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 552 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1488 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1497 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
1489 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1498 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
1490 AsValueInto(state.get()); | 1499 AsValueInto(state.get()); |
1491 return state.PassAs<base::Value>(); | 1500 return state.PassAs<base::Value>(); |
1492 } | 1501 } |
1493 | 1502 |
1494 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { | 1503 void LayerImpl::RunMicroBenchmark(MicroBenchmarkImpl* benchmark) { |
1495 benchmark->RunOnLayer(this); | 1504 benchmark->RunOnLayer(this); |
1496 } | 1505 } |
1497 | 1506 |
| 1507 int LayerImpl::NumDescendantsThatDrawContent() const { |
| 1508 return num_descendants_that_draw_content_; |
| 1509 } |
| 1510 |
1498 void LayerImpl::NotifyAnimationFinished( | 1511 void LayerImpl::NotifyAnimationFinished( |
1499 base::TimeTicks monotonic_time, | 1512 base::TimeTicks monotonic_time, |
1500 Animation::TargetProperty target_property) { | 1513 Animation::TargetProperty target_property) { |
1501 if (target_property == Animation::ScrollOffset) | 1514 if (target_property == Animation::ScrollOffset) |
1502 layer_tree_impl_->InputScrollAnimationFinished(); | 1515 layer_tree_impl_->InputScrollAnimationFinished(); |
1503 } | 1516 } |
1504 | 1517 |
1505 } // namespace cc | 1518 } // namespace cc |
OLD | NEW |