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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/tree_synchronizer.cc
diff --git a/cc/trees/tree_synchronizer.cc b/cc/trees/tree_synchronizer.cc
index 52f1bb384c752137b6ca7f2bfc72139e4bc42ad1..87efee06cab3859b3382d1fbd7e7c8d6e07037b5 100644
--- a/cc/trees/tree_synchronizer.cc
+++ b/cc/trees/tree_synchronizer.cc
@@ -74,6 +74,25 @@ std::unique_ptr<LayerImpl> ReuseOrCreateLayerImpl(OwnedLayerImplMap* old_layers,
return layer_impl;
}
+#if DCHECK_IS_ON()
+template <typename LayerType>
+static void AssertValidPropertyTreeIndices(LayerType* layer) {
+ DCHECK(layer);
+ DCHECK_NE(layer->transform_tree_index(), TransformTree::kInvalidNodeId);
+ DCHECK_NE(layer->effect_tree_index(), EffectTree::kInvalidNodeId);
+ DCHECK_NE(layer->clip_tree_index(), ClipTree::kInvalidNodeId);
+ DCHECK_NE(layer->scroll_tree_index(), ScrollTree::kInvalidNodeId);
+}
+
+static bool LayerHasValidPropertyTreeIndices(LayerImpl* layer) {
+ DCHECK(layer);
+ return layer->transform_tree_index() != TransformTree::kInvalidNodeId &&
+ layer->effect_tree_index() != EffectTree::kInvalidNodeId &&
+ layer->clip_tree_index() != ClipTree::kInvalidNodeId &&
+ layer->scroll_tree_index() != ScrollTree::kInvalidNodeId;
+}
+#endif
+
template <typename LayerTreeType>
void PushLayerList(OwnedLayerImplMap* old_layers,
LayerTreeType* host,
@@ -83,6 +102,15 @@ void PushLayerList(OwnedLayerImplMap* old_layers,
std::unique_ptr<LayerImpl> layer_impl(
ReuseOrCreateLayerImpl(old_layers, layer, tree_impl));
+#if DCHECK_IS_ON()
+ // Every layer should have valid property tree indices
+ AssertValidPropertyTreeIndices(layer);
+ // Every layer_impl should either have valid property tree indices already
+ // or the corresponding layer should push them onto layer_impl.
+ DCHECK(LayerHasValidPropertyTreeIndices(layer_impl.get()) ||
+ host->LayerNeedsPushPropertiesForTesting(layer));
+#endif
+
tree_impl->AddToLayerList(layer_impl.get());
tree_impl->AddLayer(std::move(layer_impl));
}
« 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