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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 return node->is_drawn && (!parent_node || parent_node->is_drawn); 984 return node->is_drawn && (!parent_node || parent_node->is_drawn);
985 } 985 }
986 986
987 void EffectTree::ResetChangeTracking() { 987 void EffectTree::ResetChangeTracking() {
988 for (int id = 1; id < static_cast<int>(size()); ++id) { 988 for (int id = 1; id < static_cast<int>(size()); ++id) {
989 EffectNode* node = Node(id); 989 EffectNode* node = Node(id);
990 node->effect_changed = false; 990 node->effect_changed = false;
991 } 991 }
992 } 992 }
993 993
994 EffectTree::StableIdRenderSurfaceList
995 EffectTree::CreateStableIdRenderSurfaceList() const {
996 StableIdRenderSurfaceList stable_id_render_surface_list;
997 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
998 const EffectNode* node = Node(id);
999 if (node->render_surface) {
1000 stable_id_render_surface_list.push_back(
1001 std::make_pair(node->owning_layer_id, node->render_surface));
1002 }
1003 }
1004 std::sort(stable_id_render_surface_list.begin(),
1005 stable_id_render_surface_list.end());
1006 return stable_id_render_surface_list;
1007 }
1008
1009 void EffectTree::UpdateRenderSurfaceEffectIds(
1010 const EffectTree::StableIdRenderSurfaceList& stable_id_render_surface_list,
1011 LayerTreeImpl* layer_tree_impl) {
1012 // Make a list of {stable id, node id} pairs for nodes that are supposed to
1013 // have surfaces.
1014 std::vector<std::pair<int, int>> stable_id_node_id_list;
1015 for (int id = kContentsRootNodeId; id < static_cast<int>(size()); ++id) {
1016 const EffectNode* node = Node(id);
1017 if (node->has_render_surface) {
1018 stable_id_node_id_list.push_back(
1019 std::make_pair(node->owning_layer_id, node->id));
1020 }
1021 }
1022
1023 // Sort by stable id so that we can process the two lists cosequentially.
1024 std::sort(stable_id_node_id_list.begin(), stable_id_node_id_list.end());
1025
1026 auto surface_list_it = stable_id_render_surface_list.begin();
1027 auto node_id_list_it = stable_id_node_id_list.begin();
1028 while (surface_list_it != stable_id_render_surface_list.end() &&
1029 node_id_list_it != stable_id_node_id_list.end()) {
1030 if (surface_list_it->first == node_id_list_it->first) {
1031 RenderSurfaceImpl* surface = surface_list_it->second;
1032 int node_id = node_id_list_it->second;
1033 Node(node_id)->render_surface = surface;
1034 surface->set_effect_tree_index(node_id);
1035 surface_list_it++;
1036 node_id_list_it++;
1037 continue;
1038 }
1039
1040 if (surface_list_it->first > node_id_list_it->first) {
1041 node_id_list_it++;
1042 continue;
1043 }
1044
1045 // If we reach here, there's no longer an effect node with stable id
1046 // |surface_list_it->first| that has a render surface. If there's no longer
1047 // any corresponding layer either, there's nothing more to do since the
1048 // surface owned by that layer would have been destroyed when the layer was
1049 // destroyed. But if the layer still exists, we need to destroy the surface
1050 // since it now has an invalid effect node id.
1051 if (LayerImpl* layer_impl =
1052 layer_tree_impl->LayerById(surface_list_it->first)) {
1053 layer_impl->SetHasRenderSurface(false);
1054 }
1055 surface_list_it++;
1056 }
1057
1058 while (surface_list_it != stable_id_render_surface_list.end()) {
1059 if (LayerImpl* layer_impl =
1060 layer_tree_impl->LayerById(surface_list_it->first)) {
1061 layer_impl->SetHasRenderSurface(false);
1062 }
1063 surface_list_it++;
1064 }
1065 }
1066
994 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( 1067 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations(
995 TransformNode* node, 1068 TransformNode* node,
996 TransformNode* parent_node) { 1069 TransformNode* parent_node) {
997 DCHECK(parent_node); 1070 DCHECK(parent_node);
998 node->node_and_ancestors_have_only_integer_translation = 1071 node->node_and_ancestors_have_only_integer_translation =
999 node->to_parent.IsIdentityOrIntegerTranslation() && 1072 node->to_parent.IsIdentityOrIntegerTranslation() &&
1000 parent_node->node_and_ancestors_have_only_integer_translation; 1073 parent_node->node_and_ancestors_have_only_integer_translation;
1001 } 1074 }
1002 1075
1003 void ClipTree::SetViewportClip(gfx::RectF viewport_rect) { 1076 void ClipTree::SetViewportClip(gfx::RectF viewport_rect) {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 transform_id_to_index_map.clear(); 1586 transform_id_to_index_map.clear();
1514 effect_id_to_index_map.clear(); 1587 effect_id_to_index_map.clear();
1515 clip_id_to_index_map.clear(); 1588 clip_id_to_index_map.clear();
1516 scroll_id_to_index_map.clear(); 1589 scroll_id_to_index_map.clear();
1517 always_use_active_tree_opacity_effect_ids.clear(); 1590 always_use_active_tree_opacity_effect_ids.clear();
1518 1591
1519 needs_rebuild = true; 1592 needs_rebuild = true;
1520 full_tree_damaged = false; 1593 full_tree_damaged = false;
1521 changed = false; 1594 changed = false;
1522 non_root_surfaces_enabled = true; 1595 non_root_surfaces_enabled = true;
1596 sequence_number++;
1523 1597
1524 #if DCHECK_IS_ON() 1598 #if DCHECK_IS_ON()
1525 PropertyTrees tree; 1599 PropertyTrees tree;
1526 tree.transform_tree = transform_tree; 1600 tree.transform_tree = transform_tree;
1527 tree.effect_tree = effect_tree; 1601 tree.effect_tree = effect_tree;
1528 tree.clip_tree = clip_tree; 1602 tree.clip_tree = clip_tree;
1529 tree.scroll_tree = scroll_tree; 1603 tree.scroll_tree = scroll_tree;
1530 // Scroll offset map and currently scrolling node id may not be copied 1604 // Scroll offset map and currently scrolling node id may not be copied
1531 // during operator=. 1605 // during operator=.
1532 ScrollTree::ScrollOffsetMap& map = tree.scroll_tree.scroll_offset_map(); 1606 ScrollTree::ScrollOffsetMap& map = tree.scroll_tree.scroll_offset_map();
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 2052
1979 const EffectNode* effect_node = effect_tree.Node(effect_id); 2053 const EffectNode* effect_node = effect_tree.Node(effect_id);
1980 2054
1981 bool success = GetFromTarget(transform_id, effect_id, transform); 2055 bool success = GetFromTarget(transform_id, effect_id, transform);
1982 transform->Scale(effect_node->surface_contents_scale.x(), 2056 transform->Scale(effect_node->surface_contents_scale.x(),
1983 effect_node->surface_contents_scale.y()); 2057 effect_node->surface_contents_scale.y());
1984 return success; 2058 return success;
1985 } 2059 }
1986 2060
1987 } // namespace cc 2061 } // namespace cc
OLDNEW
« 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