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

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: 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_unittest.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_valid_render_surface_layer_list_id =
1137 current_render_surface_layer_list_id;
1138 if (layer->mask_layer()) {
1139 layer->mask_layer()
1140 ->draw_properties()
1141 .last_valid_render_surface_layer_list_id =
1142 current_render_surface_layer_list_id;
1143 }
1144 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
1145 layer->replica_layer()
1146 ->mask_layer()
1147 ->draw_properties()
1148 .last_valid_render_surface_layer_list_id =
1149 current_render_surface_layer_list_id;
1150 }
1151 }
1152
1153 template <typename LayerListType>
1154 static inline void MarkLayerListWithRenderSurfaceLayerListId(
1155 LayerListType* layer_list,
1156 int current_render_surface_layer_list_id) {
1157 for (typename LayerListType::iterator it = layer_list->begin();
1158 it != layer_list->end();
1159 ++it) {
1160 MarkLayerWithRenderSurfaceLayerListId(*it,
1161 current_render_surface_layer_list_id);
1162 }
1163 }
1164
1132 template <typename LayerType> 1165 template <typename LayerType>
1133 static inline void RemoveSurfaceForEarlyExit( 1166 static inline void RemoveSurfaceForEarlyExit(
1134 LayerType* layer_to_remove, 1167 LayerType* layer_to_remove,
1135 typename LayerType::RenderSurfaceListType* render_surface_layer_list) { 1168 typename LayerType::RenderSurfaceListType* render_surface_layer_list) {
1136 DCHECK(layer_to_remove->render_surface()); 1169 DCHECK(layer_to_remove->render_surface());
1137 // Technically, we know that the layer we want to remove should be 1170 // 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 1171 // at the back of the render_surface_layer_list. However, we have had
1139 // bugs before that added unnecessary layers here 1172 // bugs before that added unnecessary layers here
1140 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes 1173 // (https://bugs.webkit.org/show_bug.cgi?id=74147), but that causes
1141 // things to crash. So here we proactively remove any additional 1174 // things to crash. So here we proactively remove any additional
1142 // layers from the end of the list. 1175 // layers from the end of the list.
1143 while (render_surface_layer_list->back() != layer_to_remove) { 1176 while (render_surface_layer_list->back() != layer_to_remove) {
1177 MarkLayerListWithRenderSurfaceLayerListId(
1178 &render_surface_layer_list->back()->render_surface()->layer_list(), 0);
1179 MarkLayerWithRenderSurfaceLayerListId(render_surface_layer_list->back(), 0);
1180
1144 render_surface_layer_list->back()->ClearRenderSurfaceLayerList(); 1181 render_surface_layer_list->back()->ClearRenderSurfaceLayerList();
1145 render_surface_layer_list->pop_back(); 1182 render_surface_layer_list->pop_back();
1146 } 1183 }
1147 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); 1184 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove);
1185 MarkLayerListWithRenderSurfaceLayerListId(
1186 &layer_to_remove->render_surface()->layer_list(), 0);
1187 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0);
1148 render_surface_layer_list->pop_back(); 1188 render_surface_layer_list->pop_back();
1149 layer_to_remove->ClearRenderSurfaceLayerList(); 1189 layer_to_remove->ClearRenderSurfaceLayerList();
1150 } 1190 }
1151 1191
1152 struct PreCalculateMetaInformationRecursiveData { 1192 struct PreCalculateMetaInformationRecursiveData {
1153 bool layer_or_descendant_has_copy_request; 1193 bool layer_or_descendant_has_copy_request;
1154 int num_unclipped_descendants; 1194 int num_unclipped_descendants;
1155 1195
1156 PreCalculateMetaInformationRecursiveData() 1196 PreCalculateMetaInformationRecursiveData()
1157 : layer_or_descendant_has_copy_request(false), 1197 : layer_or_descendant_has_copy_request(false),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 1456
1417 // Recursively walks the layer tree starting at the given node and computes all 1457 // Recursively walks the layer tree starting at the given node and computes all
1418 // the necessary transformations, clip rects, render surfaces, etc. 1458 // the necessary transformations, clip rects, render surfaces, etc.
1419 template <typename LayerType> 1459 template <typename LayerType>
1420 static void CalculateDrawPropertiesInternal( 1460 static void CalculateDrawPropertiesInternal(
1421 LayerType* layer, 1461 LayerType* layer,
1422 const SubtreeGlobals<LayerType>& globals, 1462 const SubtreeGlobals<LayerType>& globals,
1423 const DataForRecursion<LayerType>& data_from_ancestor, 1463 const DataForRecursion<LayerType>& data_from_ancestor,
1424 typename LayerType::RenderSurfaceListType* render_surface_layer_list, 1464 typename LayerType::RenderSurfaceListType* render_surface_layer_list,
1425 typename LayerType::LayerListType* layer_list, 1465 typename LayerType::LayerListType* layer_list,
1426 std::vector<AccumulatedSurfaceState<LayerType> >* 1466 std::vector<AccumulatedSurfaceState<LayerType> >* accumulated_surface_state,
1427 accumulated_surface_state) { 1467 int current_render_surface_layer_list_id) {
1428 // This function computes the new matrix transformations recursively for this 1468 // This function computes the new matrix transformations recursively for this
1429 // layer and all its descendants. It also computes the appropriate render 1469 // layer and all its descendants. It also computes the appropriate render
1430 // surfaces. 1470 // surfaces.
1431 // Some important points to remember: 1471 // Some important points to remember:
1432 // 1472 //
1433 // 0. Here, transforms are notated in Matrix x Vector order, and in words we 1473 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
1434 // describe what the transform does from left to right. 1474 // describe what the transform does from left to right.
1435 // 1475 //
1436 // 1. In our terminology, the "layer origin" refers to the top-left corner of 1476 // 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 1477 // a layer, and the positive Y-axis points downwards. This interpretation is
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
1927 if (!subtree_is_clipped_by_surface_bounds) { 1967 if (!subtree_is_clipped_by_surface_bounds) {
1928 render_surface->SetClipRect(gfx::Rect()); 1968 render_surface->SetClipRect(gfx::Rect());
1929 clip_rect_of_target_surface_in_target_space = 1969 clip_rect_of_target_surface_in_target_space =
1930 data_from_ancestor.clip_rect_of_target_surface_in_target_space; 1970 data_from_ancestor.clip_rect_of_target_surface_in_target_space;
1931 } 1971 }
1932 1972
1933 // If the new render surface is drawn translucent or with a non-integral 1973 // If the new render surface is drawn translucent or with a non-integral
1934 // translation then the subtree that gets drawn on this render surface 1974 // translation then the subtree that gets drawn on this render surface
1935 // cannot use LCD text. 1975 // cannot use LCD text.
1936 data_for_children.subtree_can_use_lcd_text = layer_can_use_lcd_text; 1976 data_for_children.subtree_can_use_lcd_text = layer_can_use_lcd_text;
1937
danakj 2014/05/06 22:48:02 nit: keep this whitespace i guess, separates it fr
vmpstr 2014/05/06 23:24:46 Done.
1938 render_surface_layer_list->push_back(layer); 1977 render_surface_layer_list->push_back(layer);
1939 } else { 1978 } else {
1940 DCHECK(layer->parent()); 1979 DCHECK(layer->parent());
1941 1980
1942 // Note: layer_draw_properties.target_space_transform is computed above, 1981 // Note: layer_draw_properties.target_space_transform is computed above,
1943 // before this if-else statement. 1982 // before this if-else statement.
1944 layer_draw_properties.target_space_transform_is_animating = 1983 layer_draw_properties.target_space_transform_is_animating =
1945 animating_transform_to_target; 1984 animating_transform_to_target;
1946 layer_draw_properties.screen_space_transform_is_animating = 1985 layer_draw_properties.screen_space_transform_is_animating =
1947 animating_transform_to_screen; 1986 animating_transform_to_screen;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } 2043 }
2005 2044
2006 typename LayerType::LayerListType& descendants = 2045 typename LayerType::LayerListType& descendants =
2007 (layer->render_surface() ? layer->render_surface()->layer_list() 2046 (layer->render_surface() ? layer->render_surface()->layer_list()
2008 : *layer_list); 2047 : *layer_list);
2009 2048
2010 // Any layers that are appended after this point are in the layer's subtree 2049 // Any layers that are appended after this point are in the layer's subtree
2011 // and should be included in the sorting process. 2050 // and should be included in the sorting process.
2012 size_t sorting_start_index = descendants.size(); 2051 size_t sorting_start_index = descendants.size();
2013 2052
2014 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) 2053 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) {
2054 MarkLayerWithRenderSurfaceLayerListId(layer,
2055 current_render_surface_layer_list_id);
2015 descendants.push_back(layer); 2056 descendants.push_back(layer);
2057 }
2016 2058
2017 // Any layers that are appended after this point may need to be sorted if we 2059 // Any layers that are appended after this point may need to be sorted if we
2018 // visit the children out of order. 2060 // visit the children out of order.
2019 size_t render_surface_layer_list_child_sorting_start_index = 2061 size_t render_surface_layer_list_child_sorting_start_index =
2020 render_surface_layer_list->size(); 2062 render_surface_layer_list->size();
2021 size_t layer_list_child_sorting_start_index = descendants.size(); 2063 size_t layer_list_child_sorting_start_index = descendants.size();
2022 2064
2023 if (!layer->children().empty()) { 2065 if (!layer->children().empty()) {
2024 if (layer == globals.page_scale_application_layer) { 2066 if (layer == globals.page_scale_application_layer) {
2025 data_for_children.parent_matrix.Scale( 2067 data_for_children.parent_matrix.Scale(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 LayerType* child = 2107 LayerType* child =
2066 layer_draw_properties.has_child_with_a_scroll_parent 2108 layer_draw_properties.has_child_with_a_scroll_parent
2067 ? sorted_children[i] 2109 ? sorted_children[i]
2068 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); 2110 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
2069 2111
2070 child->draw_properties().index_of_first_descendants_addition = 2112 child->draw_properties().index_of_first_descendants_addition =
2071 descendants.size(); 2113 descendants.size();
2072 child->draw_properties().index_of_first_render_surface_layer_list_addition = 2114 child->draw_properties().index_of_first_render_surface_layer_list_addition =
2073 render_surface_layer_list->size(); 2115 render_surface_layer_list->size();
2074 2116
2075 CalculateDrawPropertiesInternal<LayerType>(child, 2117 CalculateDrawPropertiesInternal<LayerType>(
2076 globals, 2118 child,
2077 data_for_children, 2119 globals,
2078 render_surface_layer_list, 2120 data_for_children,
2079 &descendants, 2121 render_surface_layer_list,
2080 accumulated_surface_state); 2122 &descendants,
2123 accumulated_surface_state,
2124 current_render_surface_layer_list_id);
2081 if (child->render_surface() && 2125 if (child->render_surface() &&
2082 !child->render_surface()->layer_list().empty() && 2126 !child->render_surface()->layer_list().empty() &&
2083 !child->render_surface()->content_rect().IsEmpty()) { 2127 !child->render_surface()->content_rect().IsEmpty()) {
2128 // This child will contribute its render surface, which means
2129 // we need to mark just the mask layer (and replica mask layer)
2130 // with the id.
2131 if (child->mask_layer()) {
2132 MarkLayerWithRenderSurfaceLayerListId(
2133 child->mask_layer(), current_render_surface_layer_list_id);
2134 }
2135 if (child->replica_layer() && child->replica_layer()->mask_layer()) {
2136 MarkLayerWithRenderSurfaceLayerListId(
2137 child->replica_layer()->mask_layer(),
2138 current_render_surface_layer_list_id);
2139 }
2084 descendants.push_back(child); 2140 descendants.push_back(child);
2085 } 2141 }
2086 2142
2087 child->draw_properties().num_descendants_added = 2143 child->draw_properties().num_descendants_added =
2088 descendants.size() - 2144 descendants.size() -
2089 child->draw_properties().index_of_first_descendants_addition; 2145 child->draw_properties().index_of_first_descendants_addition;
2090 child->draw_properties().num_render_surfaces_added = 2146 child->draw_properties().num_render_surfaces_added =
2091 render_surface_layer_list->size() - 2147 render_surface_layer_list->size() -
2092 child->draw_properties() 2148 child->draw_properties()
2093 .index_of_first_render_surface_layer_list_addition; 2149 .index_of_first_render_surface_layer_list_addition;
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 void LayerTreeHostCommon::CalculateDrawProperties( 2377 void LayerTreeHostCommon::CalculateDrawProperties(
2322 CalcDrawPropsMainInputs* inputs) { 2378 CalcDrawPropsMainInputs* inputs) {
2323 LayerList dummy_layer_list; 2379 LayerList dummy_layer_list;
2324 SubtreeGlobals<Layer> globals; 2380 SubtreeGlobals<Layer> globals;
2325 DataForRecursion<Layer> data_for_recursion; 2381 DataForRecursion<Layer> data_for_recursion;
2326 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2382 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2327 2383
2328 PreCalculateMetaInformationRecursiveData recursive_data; 2384 PreCalculateMetaInformationRecursiveData recursive_data;
2329 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2385 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2330 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; 2386 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state;
2331 CalculateDrawPropertiesInternal<Layer>(inputs->root_layer, 2387 CalculateDrawPropertiesInternal<Layer>(
2332 globals, 2388 inputs->root_layer,
2333 data_for_recursion, 2389 globals,
2334 inputs->render_surface_layer_list, 2390 data_for_recursion,
2335 &dummy_layer_list, 2391 inputs->render_surface_layer_list,
2336 &accumulated_surface_state); 2392 &dummy_layer_list,
2393 &accumulated_surface_state,
2394 inputs->current_render_surface_layer_list_id);
2337 2395
2338 // The dummy layer list should not have been used. 2396 // The dummy layer list should not have been used.
2339 DCHECK_EQ(0u, dummy_layer_list.size()); 2397 DCHECK_EQ(0u, dummy_layer_list.size());
2340 // A root layer render_surface should always exist after 2398 // A root layer render_surface should always exist after
2341 // CalculateDrawProperties. 2399 // CalculateDrawProperties.
2342 DCHECK(inputs->root_layer->render_surface()); 2400 DCHECK(inputs->root_layer->render_surface());
2343 } 2401 }
2344 2402
2345 void LayerTreeHostCommon::CalculateDrawProperties( 2403 void LayerTreeHostCommon::CalculateDrawProperties(
2346 CalcDrawPropsImplInputs* inputs) { 2404 CalcDrawPropsImplInputs* inputs) {
2347 LayerImplList dummy_layer_list; 2405 LayerImplList dummy_layer_list;
2348 SubtreeGlobals<LayerImpl> globals; 2406 SubtreeGlobals<LayerImpl> globals;
2349 DataForRecursion<LayerImpl> data_for_recursion; 2407 DataForRecursion<LayerImpl> data_for_recursion;
2350 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2408 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2351 2409
2352 LayerSorter layer_sorter; 2410 LayerSorter layer_sorter;
2353 globals.layer_sorter = &layer_sorter; 2411 globals.layer_sorter = &layer_sorter;
2354 2412
2355 PreCalculateMetaInformationRecursiveData recursive_data; 2413 PreCalculateMetaInformationRecursiveData recursive_data;
2356 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2414 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2357 std::vector<AccumulatedSurfaceState<LayerImpl> > 2415 std::vector<AccumulatedSurfaceState<LayerImpl> >
2358 accumulated_surface_state; 2416 accumulated_surface_state;
2359 CalculateDrawPropertiesInternal<LayerImpl>(inputs->root_layer, 2417 CalculateDrawPropertiesInternal<LayerImpl>(
2360 globals, 2418 inputs->root_layer,
2361 data_for_recursion, 2419 globals,
2362 inputs->render_surface_layer_list, 2420 data_for_recursion,
2363 &dummy_layer_list, 2421 inputs->render_surface_layer_list,
2364 &accumulated_surface_state); 2422 &dummy_layer_list,
2423 &accumulated_surface_state,
2424 inputs->current_render_surface_layer_list_id);
2365 2425
2366 // The dummy layer list should not have been used. 2426 // The dummy layer list should not have been used.
2367 DCHECK_EQ(0u, dummy_layer_list.size()); 2427 DCHECK_EQ(0u, dummy_layer_list.size());
2368 // A root layer render_surface should always exist after 2428 // A root layer render_surface should always exist after
2369 // CalculateDrawProperties. 2429 // CalculateDrawProperties.
2370 DCHECK(inputs->root_layer->render_surface()); 2430 DCHECK(inputs->root_layer->render_surface());
2371 } 2431 }
2372 2432
2373 static bool PointHitsRect( 2433 static bool PointHitsRect(
2374 const gfx::PointF& screen_space_point, 2434 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 2640 // 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 2641 // 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 2642 // was not clipped in such a way that the hit point actually should not hit
2583 // the layer. 2643 // the layer.
2584 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2644 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2585 return false; 2645 return false;
2586 2646
2587 return true; 2647 return true;
2588 } 2648 }
2589 } // namespace cc 2649 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_common.h ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698