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

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

Issue 2829853009: cc : Add DCHECKs to ensure we have valid proprety tree indices at commit (Closed)
Patch Set: test failure and comments Created 3 years, 8 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/layers/scrollbar_layer_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | 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/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
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
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
OLDNEW
« no previous file with comments | « cc/layers/scrollbar_layer_unittest.cc ('k') | cc/trees/tree_synchronizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698