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/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "cc/trees/proxy.h" | 28 #include "cc/trees/proxy.h" |
29 #include "ui/gfx/box_f.h" | 29 #include "ui/gfx/box_f.h" |
30 #include "ui/gfx/geometry/vector2d_conversions.h" | 30 #include "ui/gfx/geometry/vector2d_conversions.h" |
31 #include "ui/gfx/point_conversions.h" | 31 #include "ui/gfx/point_conversions.h" |
32 #include "ui/gfx/quad_f.h" | 32 #include "ui/gfx/quad_f.h" |
33 #include "ui/gfx/rect_conversions.h" | 33 #include "ui/gfx/rect_conversions.h" |
34 #include "ui/gfx/size_conversions.h" | 34 #include "ui/gfx/size_conversions.h" |
35 | 35 |
36 namespace cc { | 36 namespace cc { |
37 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) | 37 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) |
38 : parent_(NULL), | 38 : parent_(nullptr), |
39 scroll_parent_(NULL), | 39 scroll_parent_(nullptr), |
40 clip_parent_(NULL), | 40 clip_parent_(nullptr), |
41 mask_layer_id_(-1), | 41 mask_layer_id_(-1), |
42 replica_layer_id_(-1), | 42 replica_layer_id_(-1), |
43 layer_id_(id), | 43 layer_id_(id), |
44 layer_tree_impl_(tree_impl), | 44 layer_tree_impl_(tree_impl), |
45 scroll_offset_delegate_(NULL), | 45 scroll_offset_delegate_(nullptr), |
46 scroll_clip_layer_(NULL), | 46 scroll_clip_layer_(nullptr), |
47 should_scroll_on_main_thread_(false), | 47 should_scroll_on_main_thread_(false), |
48 have_wheel_event_handlers_(false), | 48 have_wheel_event_handlers_(false), |
49 have_scroll_event_handlers_(false), | 49 have_scroll_event_handlers_(false), |
50 user_scrollable_horizontal_(true), | 50 user_scrollable_horizontal_(true), |
51 user_scrollable_vertical_(true), | 51 user_scrollable_vertical_(true), |
52 stacking_order_changed_(false), | 52 stacking_order_changed_(false), |
53 double_sided_(true), | 53 double_sided_(true), |
54 should_flatten_transform_(true), | 54 should_flatten_transform_(true), |
55 layer_property_changed_(false), | 55 layer_property_changed_(false), |
56 masks_to_bounds_(false), | 56 masks_to_bounds_(false), |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 : Layer::INVALID_ID); | 537 : Layer::INVALID_ID); |
538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 538 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 539 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
540 layer->SetScrollOffsetAndDelta( | 540 layer->SetScrollOffsetAndDelta( |
541 scroll_offset_, | 541 scroll_offset_, |
542 layer->ScrollDelta() - layer->sent_scroll_delta()); | 542 layer->ScrollDelta() - layer->sent_scroll_delta()); |
543 layer->SetSentScrollDelta(gfx::Vector2dF()); | 543 layer->SetSentScrollDelta(gfx::Vector2dF()); |
544 layer->Set3dSortingContextId(sorting_context_id_); | 544 layer->Set3dSortingContextId(sorting_context_id_); |
545 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 545 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
546 | 546 |
547 LayerImpl* scroll_parent = NULL; | 547 LayerImpl* scroll_parent = nullptr; |
548 if (scroll_parent_) { | 548 if (scroll_parent_) { |
549 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 549 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
550 DCHECK(scroll_parent); | 550 DCHECK(scroll_parent); |
551 } | 551 } |
552 | 552 |
553 layer->SetScrollParent(scroll_parent); | 553 layer->SetScrollParent(scroll_parent); |
554 if (scroll_children_) { | 554 if (scroll_children_) { |
555 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 555 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
556 for (std::set<LayerImpl*>::iterator it = scroll_children_->begin(); | 556 for (std::set<LayerImpl*>::iterator it = scroll_children_->begin(); |
557 it != scroll_children_->end(); | 557 it != scroll_children_->end(); |
558 ++it) { | 558 ++it) { |
559 DCHECK_EQ((*it)->scroll_parent(), this); | 559 DCHECK_EQ((*it)->scroll_parent(), this); |
560 LayerImpl* scroll_child = | 560 LayerImpl* scroll_child = |
561 layer->layer_tree_impl()->LayerById((*it)->id()); | 561 layer->layer_tree_impl()->LayerById((*it)->id()); |
562 DCHECK(scroll_child); | 562 DCHECK(scroll_child); |
563 scroll_children->insert(scroll_child); | 563 scroll_children->insert(scroll_child); |
564 } | 564 } |
565 layer->SetScrollChildren(scroll_children); | 565 layer->SetScrollChildren(scroll_children); |
566 } else { | 566 } else { |
567 layer->SetScrollChildren(NULL); | 567 layer->SetScrollChildren(nullptr); |
568 } | 568 } |
569 | 569 |
570 LayerImpl* clip_parent = NULL; | 570 LayerImpl* clip_parent = nullptr; |
571 if (clip_parent_) { | 571 if (clip_parent_) { |
572 clip_parent = layer->layer_tree_impl()->LayerById( | 572 clip_parent = layer->layer_tree_impl()->LayerById( |
573 clip_parent_->id()); | 573 clip_parent_->id()); |
574 DCHECK(clip_parent); | 574 DCHECK(clip_parent); |
575 } | 575 } |
576 | 576 |
577 layer->SetClipParent(clip_parent); | 577 layer->SetClipParent(clip_parent); |
578 if (clip_children_) { | 578 if (clip_children_) { |
579 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>; | 579 std::set<LayerImpl*>* clip_children = new std::set<LayerImpl*>; |
580 for (std::set<LayerImpl*>::iterator it = clip_children_->begin(); | 580 for (std::set<LayerImpl*>::iterator it = clip_children_->begin(); |
581 it != clip_children_->end(); ++it) | 581 it != clip_children_->end(); ++it) |
582 clip_children->insert(layer->layer_tree_impl()->LayerById((*it)->id())); | 582 clip_children->insert(layer->layer_tree_impl()->LayerById((*it)->id())); |
583 layer->SetClipChildren(clip_children); | 583 layer->SetClipChildren(clip_children); |
584 } else { | 584 } else { |
585 layer->SetClipChildren(NULL); | 585 layer->SetClipChildren(nullptr); |
586 } | 586 } |
587 | 587 |
588 layer->PassCopyRequests(©_requests_); | 588 layer->PassCopyRequests(©_requests_); |
589 | 589 |
590 // If the main thread commits multiple times before the impl thread actually | 590 // If the main thread commits multiple times before the impl thread actually |
591 // draws, then damage tracking will become incorrect if we simply clobber the | 591 // draws, then damage tracking will become incorrect if we simply clobber the |
592 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. | 592 // update_rect here. The LayerImpl's update_rect needs to accumulate (i.e. |
593 // union) any update changes that have occurred on the main thread. | 593 // union) any update changes that have occurred on the main thread. |
594 update_rect_.Union(layer->update_rect()); | 594 update_rect_.Union(layer->update_rect()); |
595 layer->SetUpdateRect(update_rect_); | 595 layer->SetUpdateRect(update_rect_); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 replica_layer_->SetParent(this); | 841 replica_layer_->SetParent(this); |
842 NoteLayerPropertyChangedForSubtree(); | 842 NoteLayerPropertyChangedForSubtree(); |
843 } | 843 } |
844 | 844 |
845 scoped_ptr<LayerImpl> LayerImpl::TakeReplicaLayer() { | 845 scoped_ptr<LayerImpl> LayerImpl::TakeReplicaLayer() { |
846 replica_layer_id_ = -1; | 846 replica_layer_id_ = -1; |
847 return replica_layer_.Pass(); | 847 return replica_layer_.Pass(); |
848 } | 848 } |
849 | 849 |
850 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { | 850 ScrollbarLayerImplBase* LayerImpl::ToScrollbarLayer() { |
851 return NULL; | 851 return nullptr; |
852 } | 852 } |
853 | 853 |
854 void LayerImpl::SetDrawsContent(bool draws_content) { | 854 void LayerImpl::SetDrawsContent(bool draws_content) { |
855 if (draws_content_ == draws_content) | 855 if (draws_content_ == draws_content) |
856 return; | 856 return; |
857 | 857 |
858 draws_content_ = draws_content; | 858 draws_content_ = draws_content; |
859 NoteLayerPropertyChanged(); | 859 NoteLayerPropertyChanged(); |
860 } | 860 } |
861 | 861 |
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 return; | 1336 return; |
1337 | 1337 |
1338 scrollbar_animation_controller_ = | 1338 scrollbar_animation_controller_ = |
1339 layer_tree_impl_->CreateScrollbarAnimationController(this); | 1339 layer_tree_impl_->CreateScrollbarAnimationController(this); |
1340 } | 1340 } |
1341 | 1341 |
1342 void LayerImpl::ClearScrollbars() { | 1342 void LayerImpl::ClearScrollbars() { |
1343 if (!scrollbars_) | 1343 if (!scrollbars_) |
1344 return; | 1344 return; |
1345 | 1345 |
1346 scrollbars_.reset(NULL); | 1346 scrollbars_.reset(nullptr); |
1347 } | 1347 } |
1348 | 1348 |
1349 void LayerImpl::AddScrollbar(ScrollbarLayerImplBase* layer) { | 1349 void LayerImpl::AddScrollbar(ScrollbarLayerImplBase* layer) { |
1350 DCHECK(layer); | 1350 DCHECK(layer); |
1351 DCHECK(!scrollbars_ || scrollbars_->find(layer) == scrollbars_->end()); | 1351 DCHECK(!scrollbars_ || scrollbars_->find(layer) == scrollbars_->end()); |
1352 if (!scrollbars_) | 1352 if (!scrollbars_) |
1353 scrollbars_.reset(new ScrollbarSet()); | 1353 scrollbars_.reset(new ScrollbarSet()); |
1354 | 1354 |
1355 scrollbars_->insert(layer); | 1355 scrollbars_->insert(layer); |
1356 } | 1356 } |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1519 state->EndArray(); | 1519 state->EndArray(); |
1520 } | 1520 } |
1521 | 1521 |
1522 if (debug_info_.get()) { | 1522 if (debug_info_.get()) { |
1523 std::string str; | 1523 std::string str; |
1524 debug_info_->AppendAsTraceFormat(&str); | 1524 debug_info_->AppendAsTraceFormat(&str); |
1525 base::JSONReader json_reader; | 1525 base::JSONReader json_reader; |
1526 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); | 1526 scoped_ptr<base::Value> debug_info_value(json_reader.ReadToValue(str)); |
1527 | 1527 |
1528 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { | 1528 if (debug_info_value->IsType(base::Value::TYPE_DICTIONARY)) { |
1529 base::DictionaryValue* dictionary_value = NULL; | 1529 base::DictionaryValue* dictionary_value = nullptr; |
1530 bool converted_to_dictionary = | 1530 bool converted_to_dictionary = |
1531 debug_info_value->GetAsDictionary(&dictionary_value); | 1531 debug_info_value->GetAsDictionary(&dictionary_value); |
1532 DCHECK(converted_to_dictionary); | 1532 DCHECK(converted_to_dictionary); |
1533 for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd(); | 1533 for (base::DictionaryValue::Iterator it(*dictionary_value); !it.IsAtEnd(); |
1534 it.Advance()) { | 1534 it.Advance()) { |
1535 state->SetValue(it.key().data(), it.value().DeepCopy()); | 1535 state->SetValue(it.key().data(), it.value().DeepCopy()); |
1536 } | 1536 } |
1537 } else { | 1537 } else { |
1538 NOTREACHED(); | 1538 NOTREACHED(); |
1539 } | 1539 } |
(...skipping 16 matching lines...) Expand all Loading... |
1556 } | 1556 } |
1557 | 1557 |
1558 void LayerImpl::NotifyAnimationFinished( | 1558 void LayerImpl::NotifyAnimationFinished( |
1559 base::TimeTicks monotonic_time, | 1559 base::TimeTicks monotonic_time, |
1560 Animation::TargetProperty target_property) { | 1560 Animation::TargetProperty target_property) { |
1561 if (target_property == Animation::ScrollOffset) | 1561 if (target_property == Animation::ScrollOffset) |
1562 layer_tree_impl_->InputScrollAnimationFinished(); | 1562 layer_tree_impl_->InputScrollAnimationFinished(); |
1563 } | 1563 } |
1564 | 1564 |
1565 } // namespace cc | 1565 } // namespace cc |
OLD | NEW |