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

Side by Side Diff: cc/trees/layer_tree_host_common.cc

Issue 265883013: cc: Add a flag to layers that returns true if the layer is in RSLL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: perftest fix Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_perftest.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/layer_tree_host_common.h" 5 #include "cc/trees/layer_tree_host_common.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "cc/base/math_util.h" 10 #include "cc/base/math_util.h"
(...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 LayerType* layer) { 1122 LayerType* layer) {
1123 if (!layer->render_surface()) { 1123 if (!layer->render_surface()) {
1124 layer->CreateRenderSurface(); 1124 layer->CreateRenderSurface();
1125 return layer->render_surface(); 1125 return layer->render_surface();
1126 } 1126 }
1127 1127
1128 layer->render_surface()->ClearLayerLists(); 1128 layer->render_surface()->ClearLayerLists();
1129 return layer->render_surface(); 1129 return layer->render_surface();
1130 } 1130 }
1131 1131
1132 template <typename LayerTypePtr>
1133 static inline void MarkLayerWithRenderSurfaceLayerListId(
1134 LayerTypePtr layer,
1135 int current_render_surface_layer_list_id) {
1136 layer->draw_properties().last_drawn_render_surface_layer_list_id =
1137 current_render_surface_layer_list_id;
1138 }
1139
1140 template <typename LayerTypePtr>
1141 static inline void MarkMasksWithRenderSurfaceLayerListId(
1142 LayerTypePtr layer,
1143 int current_render_surface_layer_list_id) {
1144 if (layer->mask_layer()) {
1145 MarkLayerWithRenderSurfaceLayerListId(layer->mask_layer(),
1146 current_render_surface_layer_list_id);
1147 }
1148 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
1149 MarkLayerWithRenderSurfaceLayerListId(layer->replica_layer()->mask_layer(),
1150 current_render_surface_layer_list_id);
1151 }
1152 }
1153
1154 template <typename LayerListType>
1155 static inline void MarkLayerListWithRenderSurfaceLayerListId(
1156 LayerListType* layer_list,
1157 int current_render_surface_layer_list_id) {
1158 for (typename LayerListType::iterator it = layer_list->begin();
1159 it != layer_list->end();
1160 ++it) {
1161 MarkLayerWithRenderSurfaceLayerListId(*it,
1162 current_render_surface_layer_list_id);
1163 MarkMasksWithRenderSurfaceLayerListId(*it,
1164 current_render_surface_layer_list_id);
1165 }
1166 }
1167
1132 template <typename LayerType> 1168 template <typename LayerType>
1133 static inline void RemoveSurfaceForEarlyExit( 1169 static inline void RemoveSurfaceForEarlyExit(
1134 LayerType* layer_to_remove, 1170 LayerType* layer_to_remove,
1135 typename LayerType::RenderSurfaceListType* render_surface_layer_list) { 1171 typename LayerType::RenderSurfaceListType* render_surface_layer_list) {
1136 DCHECK(layer_to_remove->render_surface()); 1172 DCHECK(layer_to_remove->render_surface());
1137 // Technically, we know that the layer we want to remove should be 1173 // Technically, we know that the layer we want to remove should be
1138 // at the back of the render_surface_layer_list. However, we have had 1174 // at the back of the render_surface_layer_list. However, we have had
1139 // bugs before that added unnecessary layers here 1175 // bugs before that added unnecessary layers here
1140 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes 1176 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes
1141 // things to crash. So here we proactively remove any additional 1177 // things to crash. So here we proactively remove any additional
1142 // layers from the end of the list. 1178 // layers from the end of the list.
1143 while (render_surface_layer_list->back() != layer_to_remove) { 1179 while (render_surface_layer_list->back() != layer_to_remove) {
1180 MarkLayerListWithRenderSurfaceLayerListId(
1181 &render_surface_layer_list->back()->render_surface()->layer_list(), 0);
1182 MarkLayerWithRenderSurfaceLayerListId(render_surface_layer_list->back(), 0);
1183
1144 render_surface_layer_list->back()->ClearRenderSurfaceLayerList(); 1184 render_surface_layer_list->back()->ClearRenderSurfaceLayerList();
1145 render_surface_layer_list->pop_back(); 1185 render_surface_layer_list->pop_back();
1146 } 1186 }
1147 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); 1187 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove);
1188 MarkLayerListWithRenderSurfaceLayerListId(
1189 &layer_to_remove->render_surface()->layer_list(), 0);
1190 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0);
1148 render_surface_layer_list->pop_back(); 1191 render_surface_layer_list->pop_back();
1149 layer_to_remove->ClearRenderSurfaceLayerList(); 1192 layer_to_remove->ClearRenderSurfaceLayerList();
1150 } 1193 }
1151 1194
1152 struct PreCalculateMetaInformationRecursiveData { 1195 struct PreCalculateMetaInformationRecursiveData {
1153 bool layer_or_descendant_has_copy_request; 1196 bool layer_or_descendant_has_copy_request;
1154 int num_unclipped_descendants; 1197 int num_unclipped_descendants;
1155 1198
1156 PreCalculateMetaInformationRecursiveData() 1199 PreCalculateMetaInformationRecursiveData()
1157 : layer_or_descendant_has_copy_request(false), 1200 : layer_or_descendant_has_copy_request(false),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 1459
1417 // Recursively walks the layer tree starting at the given node and computes all 1460 // Recursively walks the layer tree starting at the given node and computes all
1418 // the necessary transformations, clip rects, render surfaces, etc. 1461 // the necessary transformations, clip rects, render surfaces, etc.
1419 template <typename LayerType> 1462 template <typename LayerType>
1420 static void CalculateDrawPropertiesInternal( 1463 static void CalculateDrawPropertiesInternal(
1421 LayerType* layer, 1464 LayerType* layer,
1422 const SubtreeGlobals<LayerType>& globals, 1465 const SubtreeGlobals<LayerType>& globals,
1423 const DataForRecursion<LayerType>& data_from_ancestor, 1466 const DataForRecursion<LayerType>& data_from_ancestor,
1424 typename LayerType::RenderSurfaceListType* render_surface_layer_list, 1467 typename LayerType::RenderSurfaceListType* render_surface_layer_list,
1425 typename LayerType::LayerListType* layer_list, 1468 typename LayerType::LayerListType* layer_list,
1426 std::vector<AccumulatedSurfaceState<LayerType> >* 1469 std::vector<AccumulatedSurfaceState<LayerType> >* accumulated_surface_state,
1427 accumulated_surface_state) { 1470 int current_render_surface_layer_list_id) {
1428 // This function computes the new matrix transformations recursively for this 1471 // This function computes the new matrix transformations recursively for this
1429 // layer and all its descendants. It also computes the appropriate render 1472 // layer and all its descendants. It also computes the appropriate render
1430 // surfaces. 1473 // surfaces.
1431 // Some important points to remember: 1474 // Some important points to remember:
1432 // 1475 //
1433 // 0. Here, transforms are notated in Matrix x Vector order, and in words we 1476 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
1434 // describe what the transform does from left to right. 1477 // describe what the transform does from left to right.
1435 // 1478 //
1436 // 1. In our terminology, the "layer origin" refers to the top-left corner of 1479 // 1. In our terminology, the "layer origin" refers to the top-left corner of
1437 // a layer, and the positive Y-axis points downwards. This interpretation is 1480 // a layer, and the positive Y-axis points downwards. This interpretation is
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } 2047 }
2005 2048
2006 typename LayerType::LayerListType& descendants = 2049 typename LayerType::LayerListType& descendants =
2007 (layer->render_surface() ? layer->render_surface()->layer_list() 2050 (layer->render_surface() ? layer->render_surface()->layer_list()
2008 : *layer_list); 2051 : *layer_list);
2009 2052
2010 // Any layers that are appended after this point are in the layer's subtree 2053 // Any layers that are appended after this point are in the layer's subtree
2011 // and should be included in the sorting process. 2054 // and should be included in the sorting process.
2012 size_t sorting_start_index = descendants.size(); 2055 size_t sorting_start_index = descendants.size();
2013 2056
2014 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) 2057 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) {
2058 MarkLayerWithRenderSurfaceLayerListId(layer,
2059 current_render_surface_layer_list_id);
2015 descendants.push_back(layer); 2060 descendants.push_back(layer);
2061 }
2016 2062
2017 // Any layers that are appended after this point may need to be sorted if we 2063 // Any layers that are appended after this point may need to be sorted if we
2018 // visit the children out of order. 2064 // visit the children out of order.
2019 size_t render_surface_layer_list_child_sorting_start_index = 2065 size_t render_surface_layer_list_child_sorting_start_index =
2020 render_surface_layer_list->size(); 2066 render_surface_layer_list->size();
2021 size_t layer_list_child_sorting_start_index = descendants.size(); 2067 size_t layer_list_child_sorting_start_index = descendants.size();
2022 2068
2023 if (!layer->children().empty()) { 2069 if (!layer->children().empty()) {
2024 if (layer == globals.page_scale_application_layer) { 2070 if (layer == globals.page_scale_application_layer) {
2025 data_for_children.parent_matrix.Scale( 2071 data_for_children.parent_matrix.Scale(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 LayerType* child = 2111 LayerType* child =
2066 layer_draw_properties.has_child_with_a_scroll_parent 2112 layer_draw_properties.has_child_with_a_scroll_parent
2067 ? sorted_children[i] 2113 ? sorted_children[i]
2068 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); 2114 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
2069 2115
2070 child->draw_properties().index_of_first_descendants_addition = 2116 child->draw_properties().index_of_first_descendants_addition =
2071 descendants.size(); 2117 descendants.size();
2072 child->draw_properties().index_of_first_render_surface_layer_list_addition = 2118 child->draw_properties().index_of_first_render_surface_layer_list_addition =
2073 render_surface_layer_list->size(); 2119 render_surface_layer_list->size();
2074 2120
2075 CalculateDrawPropertiesInternal<LayerType>(child, 2121 CalculateDrawPropertiesInternal<LayerType>(
2076 globals, 2122 child,
2077 data_for_children, 2123 globals,
2078 render_surface_layer_list, 2124 data_for_children,
2079 &descendants, 2125 render_surface_layer_list,
2080 accumulated_surface_state); 2126 &descendants,
2127 accumulated_surface_state,
2128 current_render_surface_layer_list_id);
2081 if (child->render_surface() && 2129 if (child->render_surface() &&
2082 !child->render_surface()->layer_list().empty() && 2130 !child->render_surface()->layer_list().empty() &&
2083 !child->render_surface()->content_rect().IsEmpty()) { 2131 !child->render_surface()->content_rect().IsEmpty()) {
2132 // This child will contribute its render surface, which means
2133 // we need to mark just the mask layer (and replica mask layer)
2134 // with the id.
2135 MarkMasksWithRenderSurfaceLayerListId(
2136 child, current_render_surface_layer_list_id);
2084 descendants.push_back(child); 2137 descendants.push_back(child);
2085 } 2138 }
2086 2139
2087 child->draw_properties().num_descendants_added = 2140 child->draw_properties().num_descendants_added =
2088 descendants.size() - 2141 descendants.size() -
2089 child->draw_properties().index_of_first_descendants_addition; 2142 child->draw_properties().index_of_first_descendants_addition;
2090 child->draw_properties().num_render_surfaces_added = 2143 child->draw_properties().num_render_surfaces_added =
2091 render_surface_layer_list->size() - 2144 render_surface_layer_list->size() -
2092 child->draw_properties() 2145 child->draw_properties()
2093 .index_of_first_render_surface_layer_list_addition; 2146 .index_of_first_render_surface_layer_list_addition;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 void LayerTreeHostCommon::CalculateDrawProperties( 2374 void LayerTreeHostCommon::CalculateDrawProperties(
2322 CalcDrawPropsMainInputs* inputs) { 2375 CalcDrawPropsMainInputs* inputs) {
2323 LayerList dummy_layer_list; 2376 LayerList dummy_layer_list;
2324 SubtreeGlobals<Layer> globals; 2377 SubtreeGlobals<Layer> globals;
2325 DataForRecursion<Layer> data_for_recursion; 2378 DataForRecursion<Layer> data_for_recursion;
2326 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2379 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2327 2380
2328 PreCalculateMetaInformationRecursiveData recursive_data; 2381 PreCalculateMetaInformationRecursiveData recursive_data;
2329 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2382 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2330 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; 2383 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state;
2331 CalculateDrawPropertiesInternal<Layer>(inputs->root_layer, 2384 CalculateDrawPropertiesInternal<Layer>(
2332 globals, 2385 inputs->root_layer,
2333 data_for_recursion, 2386 globals,
2334 inputs->render_surface_layer_list, 2387 data_for_recursion,
2335 &dummy_layer_list, 2388 inputs->render_surface_layer_list,
2336 &accumulated_surface_state); 2389 &dummy_layer_list,
2390 &accumulated_surface_state,
2391 inputs->current_render_surface_layer_list_id);
2337 2392
2338 // The dummy layer list should not have been used. 2393 // The dummy layer list should not have been used.
2339 DCHECK_EQ(0u, dummy_layer_list.size()); 2394 DCHECK_EQ(0u, dummy_layer_list.size());
2340 // A root layer render_surface should always exist after 2395 // A root layer render_surface should always exist after
2341 // CalculateDrawProperties. 2396 // CalculateDrawProperties.
2342 DCHECK(inputs->root_layer->render_surface()); 2397 DCHECK(inputs->root_layer->render_surface());
2343 } 2398 }
2344 2399
2345 void LayerTreeHostCommon::CalculateDrawProperties( 2400 void LayerTreeHostCommon::CalculateDrawProperties(
2346 CalcDrawPropsImplInputs* inputs) { 2401 CalcDrawPropsImplInputs* inputs) {
2347 LayerImplList dummy_layer_list; 2402 LayerImplList dummy_layer_list;
2348 SubtreeGlobals<LayerImpl> globals; 2403 SubtreeGlobals<LayerImpl> globals;
2349 DataForRecursion<LayerImpl> data_for_recursion; 2404 DataForRecursion<LayerImpl> data_for_recursion;
2350 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2405 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2351 2406
2352 LayerSorter layer_sorter; 2407 LayerSorter layer_sorter;
2353 globals.layer_sorter = &layer_sorter; 2408 globals.layer_sorter = &layer_sorter;
2354 2409
2355 PreCalculateMetaInformationRecursiveData recursive_data; 2410 PreCalculateMetaInformationRecursiveData recursive_data;
2356 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2411 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2357 std::vector<AccumulatedSurfaceState<LayerImpl> > 2412 std::vector<AccumulatedSurfaceState<LayerImpl> >
2358 accumulated_surface_state; 2413 accumulated_surface_state;
2359 CalculateDrawPropertiesInternal<LayerImpl>(inputs->root_layer, 2414 CalculateDrawPropertiesInternal<LayerImpl>(
2360 globals, 2415 inputs->root_layer,
2361 data_for_recursion, 2416 globals,
2362 inputs->render_surface_layer_list, 2417 data_for_recursion,
2363 &dummy_layer_list, 2418 inputs->render_surface_layer_list,
2364 &accumulated_surface_state); 2419 &dummy_layer_list,
2420 &accumulated_surface_state,
2421 inputs->current_render_surface_layer_list_id);
2365 2422
2366 // The dummy layer list should not have been used. 2423 // The dummy layer list should not have been used.
2367 DCHECK_EQ(0u, dummy_layer_list.size()); 2424 DCHECK_EQ(0u, dummy_layer_list.size());
2368 // A root layer render_surface should always exist after 2425 // A root layer render_surface should always exist after
2369 // CalculateDrawProperties. 2426 // CalculateDrawProperties.
2370 DCHECK(inputs->root_layer->render_surface()); 2427 DCHECK(inputs->root_layer->render_surface());
2371 } 2428 }
2372 2429
2373 static bool PointHitsRect( 2430 static bool PointHitsRect(
2374 const gfx::PointF& screen_space_point, 2431 const gfx::PointF& screen_space_point,
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
2580 // At this point, we think the point does hit the touch event handler region 2637 // At this point, we think the point does hit the touch event handler region
2581 // on the layer, but we need to walk up the parents to ensure that the layer 2638 // on the layer, but we need to walk up the parents to ensure that the layer
2582 // was not clipped in such a way that the hit point actually should not hit 2639 // was not clipped in such a way that the hit point actually should not hit
2583 // the layer. 2640 // the layer.
2584 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2641 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2585 return false; 2642 return false;
2586 2643
2587 return true; 2644 return true;
2588 } 2645 }
2589 } // namespace cc 2646 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698