| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/trees/layer_tree.h" | 5 #include "cc/trees/layer_tree.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "cc/animation/animation_host.h" | 9 #include "cc/animation/animation_host.h" |
| 10 #include "cc/input/page_scale_animation.h" | 10 #include "cc/input/page_scale_animation.h" |
| 11 #include "cc/layers/heads_up_display_layer.h" | 11 #include "cc/layers/heads_up_display_layer.h" |
| 12 #include "cc/layers/heads_up_display_layer_impl.h" | 12 #include "cc/layers/heads_up_display_layer_impl.h" |
| 13 #include "cc/layers/layer.h" | 13 #include "cc/layers/layer.h" |
| 14 #include "cc/layers/layer_proto_converter.h" | 14 #include "cc/layers/layer_proto_converter.h" |
| 15 #include "cc/proto/gfx_conversions.h" | 15 #include "cc/proto/gfx_conversions.h" |
| 16 #include "cc/proto/layer_tree.pb.h" | 16 #include "cc/proto/layer_tree.pb.h" |
| 17 #include "cc/trees/layer_tree_host.h" | 17 #include "cc/trees/layer_tree_host.h" |
| 18 #include "cc/trees/layer_tree_host_common.h" | 18 #include "cc/trees/layer_tree_host_common.h" |
| 19 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
| 20 #include "cc/trees/property_tree_builder.h" |
| 20 | 21 |
| 21 namespace cc { | 22 namespace cc { |
| 22 | 23 |
| 23 namespace { | 24 namespace { |
| 24 | 25 |
| 25 Layer* UpdateAndGetLayer(Layer* current_layer, | 26 Layer* UpdateAndGetLayer(Layer* current_layer, |
| 26 int layer_id, | 27 int layer_id, |
| 27 LayerTree* layer_tree) { | 28 LayerTree* layer_tree) { |
| 28 if (layer_id == Layer::INVALID_ID) { | 29 if (layer_id == Layer::INVALID_ID) { |
| 29 if (current_layer) | 30 if (current_layer) |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 needs_meta_info_recomputation_ = true; | 319 needs_meta_info_recomputation_ = true; |
| 319 | 320 |
| 320 property_trees_.needs_rebuild = true; | 321 property_trees_.needs_rebuild = true; |
| 321 SetNeedsCommit(); | 322 SetNeedsCommit(); |
| 322 } | 323 } |
| 323 | 324 |
| 324 void LayerTree::SetNeedsCommit() { | 325 void LayerTree::SetNeedsCommit() { |
| 325 layer_tree_host_->SetNeedsCommit(); | 326 layer_tree_host_->SetNeedsCommit(); |
| 326 } | 327 } |
| 327 | 328 |
| 329 const LayerTreeSettings& LayerTree::GetSettings() const { |
| 330 return layer_tree_host_->GetSettings(); |
| 331 } |
| 332 |
| 328 void LayerTree::SetPropertyTreesNeedRebuild() { | 333 void LayerTree::SetPropertyTreesNeedRebuild() { |
| 329 property_trees_.needs_rebuild = true; | 334 property_trees_.needs_rebuild = true; |
| 330 layer_tree_host_->SetNeedsUpdateLayers(); | 335 layer_tree_host_->SetNeedsUpdateLayers(); |
| 331 } | 336 } |
| 332 | 337 |
| 333 void LayerTree::PushPropertiesTo(LayerTreeImpl* tree_impl) { | 338 void LayerTree::PushPropertiesTo(LayerTreeImpl* tree_impl) { |
| 334 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_); | 339 tree_impl->set_needs_full_tree_sync(needs_full_tree_sync_); |
| 335 needs_full_tree_sync_ = false; | 340 needs_full_tree_sync_ = false; |
| 336 | 341 |
| 337 if (hud_layer_.get()) { | 342 if (hud_layer_.get()) { |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 579 } |
| 575 | 580 |
| 576 static void SetElementIdForTesting(Layer* layer) { | 581 static void SetElementIdForTesting(Layer* layer) { |
| 577 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); | 582 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); |
| 578 } | 583 } |
| 579 | 584 |
| 580 void LayerTree::SetElementIdsForTesting() { | 585 void LayerTree::SetElementIdsForTesting() { |
| 581 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting); | 586 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting); |
| 582 } | 587 } |
| 583 | 588 |
| 589 void LayerTree::BuildPropertyTreesForTesting() { |
| 590 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer()); |
| 591 gfx::Transform identity_transform; |
| 592 PropertyTreeBuilder::BuildPropertyTrees( |
| 593 root_layer(), page_scale_layer(), inner_viewport_scroll_layer(), |
| 594 outer_viewport_scroll_layer(), overscroll_elasticity_layer(), |
| 595 elastic_overscroll(), page_scale_factor(), device_scale_factor(), |
| 596 gfx::Rect(device_viewport_size()), identity_transform, property_trees()); |
| 597 } |
| 598 |
| 584 bool LayerTree::IsElementInList(ElementId element_id, | 599 bool LayerTree::IsElementInList(ElementId element_id, |
| 585 ElementListType list_type) const { | 600 ElementListType list_type) const { |
| 586 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); | 601 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); |
| 587 } | 602 } |
| 588 | 603 |
| 589 void LayerTree::SetMutatorsNeedCommit() { | 604 void LayerTree::SetMutatorsNeedCommit() { |
| 590 layer_tree_host_->SetNeedsCommit(); | 605 layer_tree_host_->SetNeedsCommit(); |
| 591 } | 606 } |
| 592 | 607 |
| 593 void LayerTree::SetMutatorsNeedRebuildPropertyTrees() { | 608 void LayerTree::SetMutatorsNeedRebuildPropertyTrees() { |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 LayerListReverseIterator<Layer> LayerTree::rend() { | 729 LayerListReverseIterator<Layer> LayerTree::rend() { |
| 715 return LayerListReverseIterator<Layer>(nullptr); | 730 return LayerListReverseIterator<Layer>(nullptr); |
| 716 } | 731 } |
| 717 | 732 |
| 718 void LayerTree::SetNeedsDisplayOnAllLayers() { | 733 void LayerTree::SetNeedsDisplayOnAllLayers() { |
| 719 for (auto* layer : *this) | 734 for (auto* layer : *this) |
| 720 layer->SetNeedsDisplay(); | 735 layer->SetNeedsDisplay(); |
| 721 } | 736 } |
| 722 | 737 |
| 723 } // namespace cc | 738 } // namespace cc |
| OLD | NEW |