| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 LayerType* layer, | 67 LayerType* layer, |
| 68 LayerTreeImpl* tree_impl) { | 68 LayerTreeImpl* tree_impl) { |
| 69 if (!layer) | 69 if (!layer) |
| 70 return nullptr; | 70 return nullptr; |
| 71 std::unique_ptr<LayerImpl> layer_impl = std::move((*old_layers)[layer->id()]); | 71 std::unique_ptr<LayerImpl> layer_impl = std::move((*old_layers)[layer->id()]); |
| 72 if (!layer_impl) | 72 if (!layer_impl) |
| 73 layer_impl = layer->CreateLayerImpl(tree_impl); | 73 layer_impl = layer->CreateLayerImpl(tree_impl); |
| 74 return layer_impl; | 74 return layer_impl; |
| 75 } | 75 } |
| 76 | 76 |
| 77 #if DCHECK_IS_ON() |
| 78 template <typename LayerType> |
| 79 static void AssertValidPropertyTreeIndices(LayerType* layer) { |
| 80 DCHECK(layer); |
| 81 DCHECK_NE(layer->transform_tree_index(), TransformTree::kInvalidNodeId); |
| 82 DCHECK_NE(layer->effect_tree_index(), EffectTree::kInvalidNodeId); |
| 83 DCHECK_NE(layer->clip_tree_index(), ClipTree::kInvalidNodeId); |
| 84 DCHECK_NE(layer->scroll_tree_index(), ScrollTree::kInvalidNodeId); |
| 85 } |
| 86 |
| 87 static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) { |
| 88 DCHECK(layer); |
| 89 return layer->transform_tree_index() != TransformTree::kInvalidNodeId && |
| 90 layer->effect_tree_index() != EffectTree::kInvalidNodeId && |
| 91 layer->clip_tree_index() != ClipTree::kInvalidNodeId && |
| 92 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId; |
| 93 } |
| 94 #endif |
| 95 |
| 77 template <typename LayerTreeType> | 96 template <typename LayerTreeType> |
| 78 void PushLayerList(OwnedLayerImplMap* old_layers, | 97 void PushLayerList(OwnedLayerImplMap* old_layers, |
| 79 LayerTreeType* host, | 98 LayerTreeType* host, |
| 80 LayerTreeImpl* tree_impl) { | 99 LayerTreeImpl* tree_impl) { |
| 81 tree_impl->ClearLayerList(); | 100 tree_impl->ClearLayerList(); |
| 82 for (auto* layer : *host) { | 101 for (auto* layer : *host) { |
| 83 std::unique_ptr<LayerImpl> layer_impl( | 102 std::unique_ptr<LayerImpl> layer_impl( |
| 84 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); | 103 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); |
| 85 | 104 |
| 105 #if DCHECK_IS_ON() |
| 106 // Every layer should have valid property tree indices |
| 107 AssertValidPropertyTreeIndices(layer); |
| 108 // Every layer_impl should either have valid property tree indices already |
| 109 // or the corresponding layer should push them onto layer_impl. |
| 110 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) || |
| 111 host->LayerNeedsPushPropertiesForTesting(layer)); |
| 112 #endif |
| 113 |
| 86 tree_impl->AddToLayerList(layer_impl.get()); | 114 tree_impl->AddToLayerList(layer_impl.get()); |
| 87 tree_impl->AddLayer(std::move(layer_impl)); | 115 tree_impl->AddLayer(std::move(layer_impl)); |
| 88 } | 116 } |
| 89 tree_impl->OnCanDrawStateChangedForTree(); | 117 tree_impl->OnCanDrawStateChangedForTree(); |
| 90 } | 118 } |
| 91 | 119 |
| 92 template <typename LayerType> | 120 template <typename LayerType> |
| 93 static void PushLayerPropertiesInternal( | 121 static void PushLayerPropertiesInternal( |
| 94 std::unordered_set<LayerType*> layers_that_should_push_properties, | 122 std::unordered_set<LayerType*> layers_that_should_push_properties, |
| 95 LayerTreeImpl* impl_tree) { | 123 LayerTreeImpl* impl_tree) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 106 active_tree); | 134 active_tree); |
| 107 } | 135 } |
| 108 | 136 |
| 109 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, | 137 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, |
| 110 LayerTreeImpl* impl_tree) { | 138 LayerTreeImpl* impl_tree) { |
| 111 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), | 139 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), |
| 112 impl_tree); | 140 impl_tree); |
| 113 } | 141 } |
| 114 | 142 |
| 115 } // namespace cc | 143 } // namespace cc |
| OLD | NEW |