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

Unified Diff: cc/trees/property_tree.cc

Issue 2571263002: cc: Remove map lookup from RenderSurfaceImpl::EffectTreeIndex (Closed)
Patch Set: Fix post-rebase unit test failure 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 | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/property_tree.cc
diff --git a/cc/trees/property_tree.cc b/cc/trees/property_tree.cc
index dd449d033aec7b00f7b03d73fb1a607fdebb7f01..1b0b5954a547fef475042fc8985caa199747098d 100644
--- a/cc/trees/property_tree.cc
+++ b/cc/trees/property_tree.cc
@@ -991,6 +991,79 @@ void EffectTree::ResetChangeTracking() {
}
}
+EffectTree::StableIdRenderSurfaceList
+EffectTree::CreateStableIdRenderSurfaceList() const {
+ StableIdRenderSurfaceList stable_id_render_surface_list;
+ for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
+ const EffectNode* node = Node(id);
+ if (node->render_surface) {
+ stable_id_render_surface_list.push_back(
+ std::make_pair(node->owning_layer_id, node->render_surface));
+ }
+ }
+ std::sort(stable_id_render_surface_list.begin(),
+ stable_id_render_surface_list.end());
+ return stable_id_render_surface_list;
+}
+
+void EffectTree::UpdateRenderSurfaceEffectIds(
+ const EffectTree::StableIdRenderSurfaceList& stable_id_render_surface_list,
+ LayerTreeImpl* layer_tree_impl) {
+ // Make a list of {stable id, node id} pairs for nodes that are supposed to
+ // have surfaces.
+ std::vector<std::pair<int, int>> stable_id_node_id_list;
+ for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
+ const EffectNode* node = Node(id);
+ if (node->has_render_surface) {
+ stable_id_node_id_list.push_back(
+ std::make_pair(node->owning_layer_id, node->id));
+ }
+ }
+
+ // Sort by stable id so that we can process the two lists cosequentially.
+ std::sort(stable_id_node_id_list.begin(), stable_id_node_id_list.end());
+
+ auto surface_list_it = stable_id_render_surface_list.begin();
+ auto node_id_list_it = stable_id_node_id_list.begin();
+ while (surface_list_it != stable_id_render_surface_list.end() &&
+ node_id_list_it != stable_id_node_id_list.end()) {
+ if (surface_list_it->first == node_id_list_it->first) {
+ RenderSurfaceImpl* surface = surface_list_it->second;
+ int node_id = node_id_list_it->second;
+ Node(node_id)->render_surface = surface;
+ surface->set_effect_tree_index(node_id);
+ surface_list_it++;
+ node_id_list_it++;
+ continue;
+ }
+
+ if (surface_list_it->first > node_id_list_it->first) {
+ node_id_list_it++;
+ continue;
+ }
+
+ // If we reach here, there's no longer an effect node with stable id
+ // |surface_list_it->first| that has a render surface. If there's no longer
+ // any corresponding layer either, there's nothing more to do since the
+ // surface owned by that layer would have been destroyed when the layer was
+ // destroyed. But if the layer still exists, we need to destroy the surface
+ // since it now has an invalid effect node id.
+ if (LayerImpl* layer_impl =
+ layer_tree_impl->LayerById(surface_list_it->first)) {
+ layer_impl->SetHasRenderSurface(false);
+ }
+ surface_list_it++;
+ }
+
+ while (surface_list_it != stable_id_render_surface_list.end()) {
+ if (LayerImpl* layer_impl =
+ layer_tree_impl->LayerById(surface_list_it->first)) {
+ layer_impl->SetHasRenderSurface(false);
+ }
+ surface_list_it++;
+ }
+}
+
void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations(
TransformNode* node,
TransformNode* parent_node) {
@@ -1520,6 +1593,7 @@ void PropertyTrees::clear() {
full_tree_damaged = false;
changed = false;
non_root_surfaces_enabled = true;
+ sequence_number++;
#if DCHECK_IS_ON()
PropertyTrees tree;
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698