OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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_impl.h" | 5 #include "cc/trees/layer_tree_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 | 610 |
611 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { | 611 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { |
612 // TODO(enne): This should get replaced by pulling out scrolling and | 612 // TODO(enne): This should get replaced by pulling out scrolling and |
613 // animations into their own trees. Then scrolls and animations would have | 613 // animations into their own trees. Then scrolls and animations would have |
614 // their own ways of synchronizing across commits. This occurs to push | 614 // their own ways of synchronizing across commits. This occurs to push |
615 // updates from scrolling deltas on the compositor thread that have occurred | 615 // updates from scrolling deltas on the compositor thread that have occurred |
616 // after begin frame and updates from animations that have ticked since begin | 616 // after begin frame and updates from animations that have ticked since begin |
617 // frame to a newly-committed property tree. | 617 // frame to a newly-committed property tree. |
618 if (layer_list_.empty()) | 618 if (layer_list_.empty()) |
619 return; | 619 return; |
| 620 std::vector<int> layer_ids_to_remove; |
620 for (auto& layer_id_to_opacity : opacity_animations_map_) { | 621 for (auto& layer_id_to_opacity : opacity_animations_map_) { |
621 const int id = layer_id_to_opacity.first; | 622 const int id = layer_id_to_opacity.first; |
622 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) { | 623 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) { |
623 EffectNode* node = property_trees_.effect_tree.Node( | 624 EffectNode* node = property_trees_.effect_tree.Node( |
624 property_trees_.effect_id_to_index_map[id]); | 625 property_trees_.effect_id_to_index_map[id]); |
625 if (!node->is_currently_animating_opacity || | 626 if (!node->is_currently_animating_opacity || |
626 node->opacity == layer_id_to_opacity.second) | 627 node->opacity == layer_id_to_opacity.second) { |
| 628 layer_ids_to_remove.push_back(id); |
627 continue; | 629 continue; |
| 630 } |
628 node->opacity = layer_id_to_opacity.second; | 631 node->opacity = layer_id_to_opacity.second; |
629 property_trees_.effect_tree.set_needs_update(true); | 632 property_trees_.effect_tree.set_needs_update(true); |
630 } | 633 } |
631 } | 634 } |
632 opacity_animations_map_.clear(); | 635 for (auto id : layer_ids_to_remove) |
| 636 opacity_animations_map_.erase(id); |
| 637 layer_ids_to_remove.clear(); |
633 | 638 |
634 for (auto& layer_id_to_transform : transform_animations_map_) { | 639 for (auto& layer_id_to_transform : transform_animations_map_) { |
635 const int id = layer_id_to_transform.first; | 640 const int id = layer_id_to_transform.first; |
636 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | 641 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, |
637 id)) { | 642 id)) { |
638 TransformNode* node = property_trees_.transform_tree.Node( | 643 TransformNode* node = property_trees_.transform_tree.Node( |
639 property_trees_.transform_id_to_index_map[id]); | 644 property_trees_.transform_id_to_index_map[id]); |
640 if (!node->is_currently_animating || | 645 if (!node->is_currently_animating || |
641 node->local == layer_id_to_transform.second) | 646 node->local == layer_id_to_transform.second) { |
| 647 layer_ids_to_remove.push_back(id); |
642 continue; | 648 continue; |
| 649 } |
643 node->local = layer_id_to_transform.second; | 650 node->local = layer_id_to_transform.second; |
644 node->needs_local_transform_update = true; | 651 node->needs_local_transform_update = true; |
645 property_trees_.transform_tree.set_needs_update(true); | 652 property_trees_.transform_tree.set_needs_update(true); |
646 } | 653 } |
647 } | 654 } |
648 transform_animations_map_.clear(); | 655 for (auto id : layer_ids_to_remove) |
| 656 transform_animations_map_.erase(id); |
649 | 657 |
650 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { | 658 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { |
651 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); | 659 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); |
652 }); | 660 }); |
653 } | 661 } |
654 | 662 |
655 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { | 663 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { |
656 DCHECK(IsActiveTree()); | 664 DCHECK(IsActiveTree()); |
657 if (page_scale_factor()->SetCurrent( | 665 if (page_scale_factor()->SetCurrent( |
658 ClampPageScaleFactorToLimits(active_page_scale))) { | 666 ClampPageScaleFactorToLimits(active_page_scale))) { |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1126 layers_that_should_push_properties_.end(); | 1134 layers_that_should_push_properties_.end(); |
1127 } | 1135 } |
1128 | 1136 |
1129 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { | 1137 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { |
1130 DCHECK(!LayerById(layer->id())); | 1138 DCHECK(!LayerById(layer->id())); |
1131 layer_id_map_[layer->id()] = layer; | 1139 layer_id_map_[layer->id()] = layer; |
1132 } | 1140 } |
1133 | 1141 |
1134 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { | 1142 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { |
1135 DCHECK(LayerById(layer->id())); | 1143 DCHECK(LayerById(layer->id())); |
| 1144 layers_that_should_push_properties_.erase(layer); |
| 1145 transform_animations_map_.erase(layer->id()); |
| 1146 opacity_animations_map_.erase(layer->id()); |
1136 layer_id_map_.erase(layer->id()); | 1147 layer_id_map_.erase(layer->id()); |
1137 } | 1148 } |
1138 | 1149 |
1139 // These manage ownership of the LayerImpl. | 1150 // These manage ownership of the LayerImpl. |
1140 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { | 1151 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { |
1141 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); | 1152 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); |
1142 layers_->push_back(std::move(layer)); | 1153 layers_->push_back(std::move(layer)); |
1143 set_needs_update_draw_properties(); | 1154 set_needs_update_draw_properties(); |
1144 } | 1155 } |
1145 | 1156 |
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2015 | 2026 |
2016 void LayerTreeImpl::ResetAllChangeTracking() { | 2027 void LayerTreeImpl::ResetAllChangeTracking() { |
2017 layers_that_should_push_properties_.clear(); | 2028 layers_that_should_push_properties_.clear(); |
2018 // Iterate over all layers, including masks and replicas. | 2029 // Iterate over all layers, including masks and replicas. |
2019 for (auto& layer : *layers_) | 2030 for (auto& layer : *layers_) |
2020 layer->ResetChangeTracking(); | 2031 layer->ResetChangeTracking(); |
2021 property_trees_.ResetAllChangeTracking(); | 2032 property_trees_.ResetAllChangeTracking(); |
2022 } | 2033 } |
2023 | 2034 |
2024 } // namespace cc | 2035 } // namespace cc |
OLD | NEW |