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

Unified Diff: cc/trees/layer_tree_impl.cc

Issue 2639103002: [Reland] Add DCHECK for duplicate layers with the same cc::ElementId. (Closed)
Patch Set: == ps2 Created 3 years, 11 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_impl.cc
diff --git a/cc/trees/layer_tree_impl.cc b/cc/trees/layer_tree_impl.cc
index 4cd9aae75103100b01bf11715f3d23ce8405f9f7..7957734ff26fe535b21b81196117f4bc7881f588 100644
--- a/cc/trees/layer_tree_impl.cc
+++ b/cc/trees/layer_tree_impl.cc
@@ -544,18 +544,25 @@ LayerImpl* LayerTreeImpl::LayerByElementId(ElementId element_id) const {
}
void LayerTreeImpl::AddToElementMap(LayerImpl* layer) {
- if (!layer->element_id())
+ ElementId element_id = layer->element_id();
+ if (!element_id)
return;
TRACE_EVENT2(TRACE_DISABLED_BY_DEFAULT("compositor-worker"),
"LayerTreeImpl::AddToElementMap", "element",
- layer->element_id().AsValue().release(), "layer_id",
- layer->id());
+ element_id.AsValue().release(), "layer_id", layer->id());
- element_layers_map_[layer->element_id()] = layer->id();
+#if DCHECK_IS_ON()
+ LayerImpl* existing_layer = LayerByElementId(element_id);
+ bool element_id_collision_detected =
+ existing_layer && existing_layer != layer;
+ DCHECK(!element_id_collision_detected);
+#endif
+
+ element_layers_map_[element_id] = layer->id();
layer_tree_host_impl_->mutator_host()->RegisterElement(
- layer->element_id(),
+ element_id,
IsActiveTree() ? ElementListType::ACTIVE : ElementListType::PENDING);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698