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

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: 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 bool LayerHasValidPropertyTreeIndices(LayerType* layer) {
80 DCHECK(layer);
81 return layer->transform_tree_index() != TransformTree::kInvalidNodeId &&
enne (OOO) 2017/04/21 22:57:28 One thing you might consider is to just make this
jaydasika 2017/04/25 21:02:38 Added AssertValidPropertyTreeIndices (we still nee
82 layer->effect_tree_index() != EffectTree::kInvalidNodeId &&
83 layer->clip_tree_index() != ClipTree::kInvalidNodeId &&
84 layer->scroll_tree_index() != ScrollTree::kInvalidNodeId;
85 }
86 #endif
87
77 template <typename LayerTreeType> 88 template <typename LayerTreeType>
78 void PushLayerList(OwnedLayerImplMap* old_layers, 89 void PushLayerList(OwnedLayerImplMap* old_layers,
79 LayerTreeType* host, 90 LayerTreeType* host,
80 LayerTreeImpl* tree_impl) { 91 LayerTreeImpl* tree_impl) {
81 tree_impl->ClearLayerList(); 92 tree_impl->ClearLayerList();
82 for (auto* layer : *host) { 93 for (auto* layer : *host) {
83 std::unique_ptr<LayerImpl> layer_impl( 94 std::unique_ptr<LayerImpl> layer_impl(
84 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl)); 95 ReuseOrCreateLayerImpl(old_layers, layer, tree_impl));
85 96
97 // Every layer should have valid property tree indices
98 DCHECK(LayerHasValidPropertyTreeIndices(layer));
99 // Every layer_impl should either have valid property tree indices already
100 // or the corresponding layer should push them onto layer_impl.
101 DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) ||
102 host->LayerNeedsPushPropertiesForTesting(layer));
86 tree_impl->AddToLayerList(layer_impl.get()); 103 tree_impl->AddToLayerList(layer_impl.get());
87 tree_impl->AddLayer(std::move(layer_impl)); 104 tree_impl->AddLayer(std::move(layer_impl));
88 } 105 }
89 tree_impl->OnCanDrawStateChangedForTree(); 106 tree_impl->OnCanDrawStateChangedForTree();
90 } 107 }
91 108
92 template <typename LayerType> 109 template <typename LayerType>
93 static void PushLayerPropertiesInternal( 110 static void PushLayerPropertiesInternal(
94 std::unordered_set<LayerType*> layers_that_should_push_properties, 111 std::unordered_set<LayerType*> layers_that_should_push_properties,
95 LayerTreeImpl* impl_tree) { 112 LayerTreeImpl* impl_tree) {
(...skipping 10 matching lines...) Expand all
106 active_tree); 123 active_tree);
107 } 124 }
108 125
109 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree, 126 void TreeSynchronizer::PushLayerProperties(LayerTreeHost* host_tree,
110 LayerTreeImpl* impl_tree) { 127 LayerTreeImpl* impl_tree) {
111 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(), 128 PushLayerPropertiesInternal(host_tree->LayersThatShouldPushProperties(),
112 impl_tree); 129 impl_tree);
113 } 130 }
114 131
115 } // namespace cc 132 } // 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