Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 2173483002: cc: Clear entries from animations maps only when main thread wins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 589 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 600
601 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() { 601 void LayerTreeImpl::UpdatePropertyTreeScrollingAndAnimationFromMainThread() {
602 // TODO(enne): This should get replaced by pulling out scrolling and 602 // TODO(enne): This should get replaced by pulling out scrolling and
603 // animations into their own trees. Then scrolls and animations would have 603 // animations into their own trees. Then scrolls and animations would have
604 // their own ways of synchronizing across commits. This occurs to push 604 // their own ways of synchronizing across commits. This occurs to push
605 // updates from scrolling deltas on the compositor thread that have occurred 605 // updates from scrolling deltas on the compositor thread that have occurred
606 // after begin frame and updates from animations that have ticked since begin 606 // after begin frame and updates from animations that have ticked since begin
607 // frame to a newly-committed property tree. 607 // frame to a newly-committed property tree.
608 if (layer_list_.empty()) 608 if (layer_list_.empty())
609 return; 609 return;
610 std::vector<int> layer_ids_to_remove;
610 for (auto& layer_id_to_opacity : opacity_animations_map_) { 611 for (auto& layer_id_to_opacity : opacity_animations_map_) {
611 const int id = layer_id_to_opacity.first; 612 const int id = layer_id_to_opacity.first;
612 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) { 613 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, id)) {
613 EffectNode* node = property_trees_.effect_tree.Node( 614 EffectNode* node = property_trees_.effect_tree.Node(
614 property_trees_.effect_id_to_index_map[id]); 615 property_trees_.effect_id_to_index_map[id]);
615 if (!node->data.is_currently_animating_opacity || 616 if (!node->data.is_currently_animating_opacity ||
616 node->data.opacity == layer_id_to_opacity.second) 617 node->data.opacity == layer_id_to_opacity.second) {
618 layer_ids_to_remove.push_back(id);
617 continue; 619 continue;
620 }
618 node->data.opacity = layer_id_to_opacity.second; 621 node->data.opacity = layer_id_to_opacity.second;
619 property_trees_.effect_tree.set_needs_update(true); 622 property_trees_.effect_tree.set_needs_update(true);
620 } 623 }
621 } 624 }
622 opacity_animations_map_.clear(); 625 for (auto id : layer_ids_to_remove)
626 opacity_animations_map_.erase(id);
627 layer_ids_to_remove.clear();
623 628
624 for (auto& layer_id_to_transform : transform_animations_map_) { 629 for (auto& layer_id_to_transform : transform_animations_map_) {
625 const int id = layer_id_to_transform.first; 630 const int id = layer_id_to_transform.first;
626 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, 631 if (property_trees_.IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM,
627 id)) { 632 id)) {
628 TransformNode* node = property_trees_.transform_tree.Node( 633 TransformNode* node = property_trees_.transform_tree.Node(
629 property_trees_.transform_id_to_index_map[id]); 634 property_trees_.transform_id_to_index_map[id]);
630 if (!node->data.is_currently_animating || 635 if (!node->data.is_currently_animating ||
631 node->data.local == layer_id_to_transform.second) 636 node->data.local == layer_id_to_transform.second) {
637 layer_ids_to_remove.push_back(id);
632 continue; 638 continue;
639 }
633 node->data.local = layer_id_to_transform.second; 640 node->data.local = layer_id_to_transform.second;
634 node->data.needs_local_transform_update = true; 641 node->data.needs_local_transform_update = true;
635 property_trees_.transform_tree.set_needs_update(true); 642 property_trees_.transform_tree.set_needs_update(true);
636 } 643 }
637 } 644 }
638 transform_animations_map_.clear(); 645 for (auto id : layer_ids_to_remove)
646 transform_animations_map_.erase(id);
639 647
640 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) { 648 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [](LayerImpl* layer) {
641 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded(); 649 layer->UpdatePropertyTreeForScrollingAndAnimationIfNeeded();
642 }); 650 });
643 } 651 }
644 652
645 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) { 653 void LayerTreeImpl::SetPageScaleOnActiveTree(float active_page_scale) {
646 DCHECK(IsActiveTree()); 654 DCHECK(IsActiveTree());
647 if (page_scale_factor()->SetCurrent( 655 if (page_scale_factor()->SetCurrent(
648 ClampPageScaleFactorToLimits(active_page_scale))) { 656 ClampPageScaleFactorToLimits(active_page_scale))) {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 layers_that_should_push_properties_.end(); 1100 layers_that_should_push_properties_.end();
1093 } 1101 }
1094 1102
1095 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) { 1103 void LayerTreeImpl::RegisterLayer(LayerImpl* layer) {
1096 DCHECK(!LayerById(layer->id())); 1104 DCHECK(!LayerById(layer->id()));
1097 layer_id_map_[layer->id()] = layer; 1105 layer_id_map_[layer->id()] = layer;
1098 } 1106 }
1099 1107
1100 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) { 1108 void LayerTreeImpl::UnregisterLayer(LayerImpl* layer) {
1101 DCHECK(LayerById(layer->id())); 1109 DCHECK(LayerById(layer->id()));
1110 layers_that_should_push_properties_.erase(layer);
1111 transform_animations_map_.erase(layer->id());
1112 opacity_animations_map_.erase(layer->id());
1102 layer_id_map_.erase(layer->id()); 1113 layer_id_map_.erase(layer->id());
1103 } 1114 }
1104 1115
1105 // These manage ownership of the LayerImpl. 1116 // These manage ownership of the LayerImpl.
1106 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) { 1117 void LayerTreeImpl::AddLayer(std::unique_ptr<LayerImpl> layer) {
1107 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end()); 1118 DCHECK(std::find(layers_->begin(), layers_->end(), layer) == layers_->end());
1108 layers_->push_back(std::move(layer)); 1119 layers_->push_back(std::move(layer));
1109 set_needs_update_draw_properties(); 1120 set_needs_update_draw_properties();
1110 } 1121 }
1111 1122
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 2108
2098 void LayerTreeImpl::ResetAllChangeTracking() { 2109 void LayerTreeImpl::ResetAllChangeTracking() {
2099 layers_that_should_push_properties_.clear(); 2110 layers_that_should_push_properties_.clear();
2100 // Iterate over all layers, including masks and replicas. 2111 // Iterate over all layers, including masks and replicas.
2101 for (auto& layer : *layers_) 2112 for (auto& layer : *layers_)
2102 layer->ResetChangeTracking(); 2113 layer->ResetChangeTracking();
2103 property_trees_.ResetAllChangeTracking(); 2114 property_trees_.ResetAllChangeTracking();
2104 } 2115 }
2105 2116
2106 } // namespace cc 2117 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698