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/tree_synchronizer.h" | 5 #include "cc/trees/tree_synchronizer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... | |
28 std::unique_ptr<OwnedLayerImplList> old_layers(tree_impl->DetachLayers()); | 28 std::unique_ptr<OwnedLayerImplList> old_layers(tree_impl->DetachLayers()); |
29 | 29 |
30 OwnedLayerImplMap old_layer_map; | 30 OwnedLayerImplMap old_layer_map; |
31 for (auto& it : *old_layers) { | 31 for (auto& it : *old_layers) { |
32 DCHECK(it); | 32 DCHECK(it); |
33 old_layer_map[it->id()] = std::move(it); | 33 old_layer_map[it->id()] = std::move(it); |
34 } | 34 } |
35 | 35 |
36 PushLayerList(&old_layer_map, source_tree, tree_impl); | 36 PushLayerList(&old_layer_map, source_tree, tree_impl); |
37 | 37 |
38 // We also push hidden surface layer ids as they maybe needed to handle copy | |
39 // requests on surfaces. | |
40 tree_impl->ClearHiddenSurfaceLayerIds(); | |
enne (OOO)
2017/05/19 22:27:05
This seems like something that should happen as a
jaydasika
2017/05/23 00:25:14
Done.
| |
41 tree_impl->SetHiddenSurfaceLayerIds(source_tree->HiddenSurfaceLayerIds()); | |
42 // Reset for next update. | |
43 source_tree->ClearHiddenSurfaceLayerIds(); | |
44 | |
38 for (int id : property_trees->effect_tree.mask_layer_ids()) { | 45 for (int id : property_trees->effect_tree.mask_layer_ids()) { |
39 std::unique_ptr<LayerImpl> layer_impl(ReuseOrCreateLayerImpl( | 46 std::unique_ptr<LayerImpl> layer_impl(ReuseOrCreateLayerImpl( |
40 &old_layer_map, source_tree->LayerById(id), tree_impl)); | 47 &old_layer_map, source_tree->LayerById(id), tree_impl)); |
41 tree_impl->AddLayer(std::move(layer_impl)); | 48 tree_impl->AddLayer(std::move(layer_impl)); |
42 } | 49 } |
43 } | 50 } |
44 | 51 |
45 void TreeSynchronizer::SynchronizeTrees(Layer* layer_root, | 52 void TreeSynchronizer::SynchronizeTrees(Layer* layer_root, |
46 LayerTreeImpl* tree_impl) { | 53 LayerTreeImpl* tree_impl) { |
47 if (!layer_root) { | 54 if (!layer_root) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 | 93 |
87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { | 94 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { |
88 DCHECK(layer); | 95 DCHECK(layer); |
89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && | 96 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && |
90 layer->effect_tree_index() != EffectTree::kInvalidNodeId && | 97 layer->effect_tree_index() != EffectTree::kInvalidNodeId && |
91 layer->clip_tree_index() != ClipTree::kInvalidNodeId && | 98 layer->clip_tree_index() != ClipTree::kInvalidNodeId && |
92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; | 99 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; |
93 } | 100 } |
94 #endif | 101 #endif |
95 | 102 |
103 static bool IsHidden(Layer* layer) { | |
104 return layer->is_hidden(); | |
105 } | |
106 | |
107 static bool IsHidden(LayerImpl* layer) { | |
108 return false; | |
109 } | |
110 | |
96 template <typename LayerTreeType> | 111 template <typename LayerTreeType> |
97 void PushLayerList(OwnedLayerImplMap* old_layers, | 112 void PushLayerList(OwnedLayerImplMap* old_layers, |
98 LayerTreeType* host, | 113 LayerTreeType* host, |
99 LayerTreeImpl* tree_impl) { | 114 LayerTreeImpl* tree_impl) { |
100 tree_impl->ClearLayerList(); | 115 tree_impl->ClearLayerList(); |
101 for (auto* layer : *host) { | 116 for (auto* layer : *host) { |
102 std::unique_ptr<LayerImpl> layer_impl( | 117 if (!IsHidden(layer)) { |
enne (OOO)
2017/05/19 22:27:05
I'm not sure if this needs to be done in this patc
jaydasika
2017/05/23 00:25:14
Acknowledged.
| |
103 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); | 118 std::unique_ptr<LayerImpl> layer_impl( |
119 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); | |
104 | 120 |
105 #if DCHECK_IS_ON() | 121 #if DCHECK_IS_ON() |
106 // Every layer should have valid property tree indices | 122 // Every layer should have valid property tree indices |
107 AssertValidPropertyTreeIndices(layer); | 123 AssertValidPropertyTreeIndices(layer); |
108 // Every layer_impl should either have valid property tree indices already | 124 // Every layer_impl should either have valid property tree indices already |
109 // or the corresponding layer should push them onto layer_impl. | 125 // or the corresponding layer should push them onto layer_impl. |
110 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || | 126 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || |
111 host->LayerNeedsPushPropertiesForTesting(layer)); | 127 host->LayerNeedsPushPropertiesForTesting(layer)); |
112 #endif | 128 #endif |
113 | 129 tree_impl->AddToLayerList(layer_impl.get()); |
114 tree_impl->AddToLayerList(layer_impl.get()); | 130 tree_impl->AddLayer(std::move(layer_impl)); |
115 tree_impl->AddLayer(std::move(layer_impl)); | 131 } |
116 } | 132 } |
117 tree_impl->OnCanDrawStateChangedForTree(); | 133 tree_impl->OnCanDrawStateChangedForTree(); |
118 } | 134 } |
119 | 135 |
120 template <typename LayerType> | 136 template <typename LayerType> |
121 static void PushLayerPropertiesInternal( | 137 static void PushLayerPropertiesInternal( |
122 std::unordered_set<LayerType*> layers_that_should_push_properties, | 138 std::unordered_set<LayerType*> layers_that_should_push_properties, |
123 LayerTreeImpl* impl_tree) { | 139 LayerTreeImpl* impl_tree) { |
124 for (auto layer : layers_that_should_push_properties) { | 140 for (auto layer : layers_that_should_push_properties) { |
125 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); | 141 if (!IsHidden(layer)) { |
enne (OOO)
2017/05/19 22:27:05
Maybe setting IsHidden should just SetNeedsCommit
jaydasika
2017/05/23 00:25:14
I will remove SetNeedsPushProperties from Layer::S
| |
126 DCHECK(layer_impl); | 142 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); |
127 layer->PushPropertiesTo(layer_impl); | 143 DCHECK(layer_impl); |
144 layer->PushPropertiesTo(layer_impl); | |
145 } | |
128 } | 146 } |
129 } | 147 } |
130 | 148 |
131 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, | 149 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, |
132 LayerTreeImpl* active_tree) { | 150 LayerTreeImpl* active_tree) { |
133 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), | 151 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), |
134 active_tree); | 152 active_tree); |
135 } | 153 } |
136 | 154 |
137 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, | 155 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, |
138 LayerTreeImpl* impl_tree) { | 156 LayerTreeImpl* impl_tree) { |
139 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), | 157 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), |
140 impl_tree); | 158 impl_tree); |
141 } | 159 } |
142 | 160 |
143 } // namespace cc | 161 } // namespace cc |
OLD | NEW |