| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { | 87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { |
| 88 DCHECK(layer); | 88 DCHECK(layer); |
| 89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && | 89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && |
| 90 layer->effect_tree_index() != EffectTree::kInvalidNodeId && | 90 layer->effect_tree_index() != EffectTree::kInvalidNodeId && |
| 91 layer->clip_tree_index() != ClipTree::kInvalidNodeId && | 91 layer->clip_tree_index() != ClipTree::kInvalidNodeId && |
| 92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; | 92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; |
| 93 } | 93 } |
| 94 #endif | 94 #endif |
| 95 | 95 |
| 96 static bool IsHidden(Layer* layer) { |
| 97 return layer->is_hidden(); |
| 98 } |
| 99 |
| 100 static bool IsHidden(LayerImpl* layer) { |
| 101 return false; |
| 102 } |
| 103 |
| 96 template <typename LayerTreeType> | 104 template <typename LayerTreeType> |
| 97 void PushLayerList(OwnedLayerImplMap* old_layers, | 105 void PushLayerList(OwnedLayerImplMap* old_layers, |
| 98 LayerTreeType* host, | 106 LayerTreeType* host, |
| 99 LayerTreeImpl* tree_impl) { | 107 LayerTreeImpl* tree_impl) { |
| 100 tree_impl->ClearLayerList(); | 108 tree_impl->ClearLayerList(); |
| 101 for (auto* layer : *host) { | 109 for (auto* layer : *host) { |
| 102 std::unique_ptr<LayerImpl> layer_impl( | 110 // TODO(crbug.com/726535) : Try not pushing all skipped layers and not just |
| 103 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); | 111 // the hidden layers here. |
| 112 if (!IsHidden(layer)) { |
| 113 std::unique_ptr<LayerImpl> layer_impl( |
| 114 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); |
| 104 | 115 |
| 105 #if DCHECK_IS_ON() | 116 #if DCHECK_IS_ON() |
| 106 // Every layer should have valid property tree indices | 117 // Every layer should have valid property tree indices |
| 107 AssertValidPropertyTreeIndices(layer); | 118 AssertValidPropertyTreeIndices(layer); |
| 108 // Every layer_impl should either have valid property tree indices already | 119 // Every layer_impl should either have valid property tree indices already |
| 109 // or the corresponding layer should push them onto layer_impl. | 120 // or the corresponding layer should push them onto layer_impl. |
| 110 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || | 121 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || |
| 111 host->LayerNeedsPushPropertiesForTesting(layer)); | 122 host->LayerNeedsPushPropertiesForTesting(layer)); |
| 112 #endif | 123 #endif |
| 113 | 124 tree_impl->AddToLayerList(layer_impl.get()); |
| 114 tree_impl->AddToLayerList(layer_impl.get()); | 125 tree_impl->AddLayer(std::move(layer_impl)); |
| 115 tree_impl->AddLayer(std::move(layer_impl)); | 126 } |
| 116 } | 127 } |
| 117 tree_impl->OnCanDrawStateChangedForTree(); | 128 tree_impl->OnCanDrawStateChangedForTree(); |
| 118 } | 129 } |
| 119 | 130 |
| 120 template <typename LayerType> | 131 template <typename LayerType> |
| 121 static void PushLayerPropertiesInternal( | 132 static void PushLayerPropertiesInternal( |
| 122 std::unordered_set<LayerType*> layers_that_should_push_properties, | 133 std::unordered_set<LayerType*> layers_that_should_push_properties, |
| 123 LayerTreeImpl* impl_tree) { | 134 LayerTreeImpl* impl_tree) { |
| 124 for (auto layer : layers_that_should_push_properties) { | 135 for (auto layer : layers_that_should_push_properties) { |
| 125 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); | 136 if (!IsHidden(layer)) { |
| 126 DCHECK(layer_impl); | 137 LayerImpl* layer_impl = impl_tree->LayerById(layer->id()); |
| 127 layer->PushPropertiesTo(layer_impl); | 138 DCHECK(layer_impl); |
| 139 layer->PushPropertiesTo(layer_impl); |
| 140 } |
| 128 } | 141 } |
| 129 } | 142 } |
| 130 | 143 |
| 131 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, | 144 void TreeSynchronizer::PushLayerProperties(LayerTreeImpl* pending_tree, |
| 132 LayerTreeImpl* active_tree) { | 145 LayerTreeImpl* active_tree) { |
| 133 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), | 146 PushLayerPropertiesInternal(pending_tree->LayersThatShouldPushProperties(), |
| 134 active_tree); | 147 active_tree); |
| 135 } | 148 } |
| 136 | 149 |
| 137 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, | 150 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, |
| 138 LayerTreeImpl* impl_tree) { | 151 LayerTreeImpl* impl_tree) { |
| 139 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), | 152 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), |
| 140 impl_tree); | 153 impl_tree); |
| 141 } | 154 } |
| 142 | 155 |
| 143 } // namespace cc | 156 } // namespace cc |
| OLD | NEW |