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

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
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 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1416 1416
1417 // Recursively walks the layer tree starting at the given node and computes all 1417 // Recursively walks the layer tree starting at the given node and computes all
1418 // the necessary transformations, clip rects, render surfaces, etc. 1418 // the necessary transformations, clip rects, render surfaces, etc.
1419 template <typename LayerType> 1419 template <typename LayerType>
1420 static void CalculateDrawPropertiesInternal( 1420 static void CalculateDrawPropertiesInternal(
1421 LayerType* layer, 1421 LayerType* layer,
1422 const SubtreeGlobals<LayerType>& globals, 1422 const SubtreeGlobals<LayerType>& globals,
1423 const DataForRecursion<LayerType>& data_from_ancestor, 1423 const DataForRecursion<LayerType>& data_from_ancestor,
1424 typename LayerType::RenderSurfaceListType* render_surface_layer_list, 1424 typename LayerType::RenderSurfaceListType* render_surface_layer_list,
1425 typename LayerType::LayerListType* layer_list, 1425 typename LayerType::LayerListType* layer_list,
1426 std::vector<AccumulatedSurfaceState<LayerType> >* 1426 std::vector<AccumulatedSurfaceState<LayerType> >* accumulated_surface_state,
1427 accumulated_surface_state) { 1427 size_t current_calculate_draw_properties_count) {
1428 // This function computes the new matrix transformations recursively for this 1428 // This function computes the new matrix transformations recursively for this
1429 // layer and all its descendants. It also computes the appropriate render 1429 // layer and all its descendants. It also computes the appropriate render
1430 // surfaces. 1430 // surfaces.
1431 // Some important points to remember: 1431 // Some important points to remember:
1432 // 1432 //
1433 // 0. Here, transforms are notated in Matrix x Vector order, and in words we 1433 // 0. Here, transforms are notated in Matrix x Vector order, and in words we
1434 // describe what the transform does from left to right. 1434 // describe what the transform does from left to right.
1435 // 1435 //
1436 // 1. In our terminology, the "layer origin" refers to the top-left corner of 1436 // 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 1437 // a layer, and the positive Y-axis points downwards. This interpretation is
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 2005
2006 typename LayerType::LayerListType& descendants = 2006 typename LayerType::LayerListType& descendants =
2007 (layer->render_surface() ? layer->render_surface()->layer_list() 2007 (layer->render_surface() ? layer->render_surface()->layer_list()
2008 : *layer_list); 2008 : *layer_list);
2009 2009
2010 // Any layers that are appended after this point are in the layer's subtree 2010 // Any layers that are appended after this point are in the layer's subtree
2011 // and should be included in the sorting process. 2011 // and should be included in the sorting process.
2012 size_t sorting_start_index = descendants.size(); 2012 size_t sorting_start_index = descendants.size();
2013 2013
2014 if (!LayerShouldBeSkipped(layer, layer_is_drawn)) 2014 if (!LayerShouldBeSkipped(layer, layer_is_drawn))
2015 descendants.push_back(layer); 2015 descendants.push_back(layer);
danakj 2014/05/02 23:45:26 Here we might not have added the layer even tho we
vmpstr 2014/05/05 18:46:43 I've changed this around a bit. From my understand
2016 2016
2017 // Any layers that are appended after this point may need to be sorted if we 2017 // Any layers that are appended after this point may need to be sorted if we
2018 // visit the children out of order. 2018 // visit the children out of order.
2019 size_t render_surface_layer_list_child_sorting_start_index = 2019 size_t render_surface_layer_list_child_sorting_start_index =
2020 render_surface_layer_list->size(); 2020 render_surface_layer_list->size();
2021 size_t layer_list_child_sorting_start_index = descendants.size(); 2021 size_t layer_list_child_sorting_start_index = descendants.size();
2022 2022
2023 if (!layer->children().empty()) { 2023 if (!layer->children().empty()) {
2024 if (layer == globals.page_scale_application_layer) { 2024 if (layer == globals.page_scale_application_layer) {
2025 data_for_children.parent_matrix.Scale( 2025 data_for_children.parent_matrix.Scale(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2065 LayerType* child = 2065 LayerType* child =
2066 layer_draw_properties.has_child_with_a_scroll_parent 2066 layer_draw_properties.has_child_with_a_scroll_parent
2067 ? sorted_children[i] 2067 ? sorted_children[i]
2068 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i); 2068 : LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i);
2069 2069
2070 child->draw_properties().index_of_first_descendants_addition = 2070 child->draw_properties().index_of_first_descendants_addition =
2071 descendants.size(); 2071 descendants.size();
2072 child->draw_properties().index_of_first_render_surface_layer_list_addition = 2072 child->draw_properties().index_of_first_render_surface_layer_list_addition =
2073 render_surface_layer_list->size(); 2073 render_surface_layer_list->size();
2074 2074
2075 CalculateDrawPropertiesInternal<LayerType>(child, 2075 CalculateDrawPropertiesInternal<LayerType>(
2076 globals, 2076 child,
2077 data_for_children, 2077 globals,
2078 render_surface_layer_list, 2078 data_for_children,
2079 &descendants, 2079 render_surface_layer_list,
2080 accumulated_surface_state); 2080 &descendants,
2081 accumulated_surface_state,
2082 current_calculate_draw_properties_count);
2081 if (child->render_surface() && 2083 if (child->render_surface() &&
2082 !child->render_surface()->layer_list().empty() && 2084 !child->render_surface()->layer_list().empty() &&
2083 !child->render_surface()->content_rect().IsEmpty()) { 2085 !child->render_surface()->content_rect().IsEmpty()) {
2084 descendants.push_back(child); 2086 descendants.push_back(child);
2085 } 2087 }
2086 2088
2087 child->draw_properties().num_descendants_added = 2089 child->draw_properties().num_descendants_added =
2088 descendants.size() - 2090 descendants.size() -
2089 child->draw_properties().index_of_first_descendants_addition; 2091 child->draw_properties().index_of_first_descendants_addition;
2090 child->draw_properties().num_render_surfaces_added = 2092 child->draw_properties().num_render_surfaces_added =
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 globals.layer_sorter); 2257 globals.layer_sorter);
2256 } 2258 }
2257 2259
2258 UpdateAccumulatedSurfaceState<LayerType>( 2260 UpdateAccumulatedSurfaceState<LayerType>(
2259 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state); 2261 layer, local_drawable_content_rect_of_subtree, accumulated_surface_state);
2260 2262
2261 if (layer->HasContributingDelegatedRenderPasses()) { 2263 if (layer->HasContributingDelegatedRenderPasses()) {
2262 layer->render_target()->render_surface()-> 2264 layer->render_target()->render_surface()->
2263 AddContributingDelegatedRenderPassLayer(layer); 2265 AddContributingDelegatedRenderPassLayer(layer);
2264 } 2266 }
2267
2268 // If the layer passed all of the early outs, that means it's finally in the
vmpstr 2014/05/02 23:41:22 Kind of like so?
2269 // render surface layer list: mark it as a member.
2270 layer_draw_properties.last_render_surface_list_membership_index =
2271 current_calculate_draw_properties_count;
2272 if (layer->mask_layer()) {
2273 layer->mask_layer()
2274 ->draw_properties()
2275 .last_render_surface_list_membership_index =
2276 current_calculate_draw_properties_count;
2277 }
2278 if (layer->replica_layer() && layer->replica_layer()->mask_layer()) {
2279 layer->replica_layer()
2280 ->mask_layer()
2281 ->draw_properties()
2282 .last_render_surface_list_membership_index =
2283 current_calculate_draw_properties_count;
2284 }
2265 } 2285 }
2266 2286
2267 template <typename LayerType, typename RenderSurfaceLayerListType> 2287 template <typename LayerType, typename RenderSurfaceLayerListType>
2268 static void ProcessCalcDrawPropsInputs( 2288 static void ProcessCalcDrawPropsInputs(
2269 const LayerTreeHostCommon::CalcDrawPropsInputs<LayerType, 2289 const LayerTreeHostCommon::CalcDrawPropsInputs<LayerType,
2270 RenderSurfaceLayerListType>& 2290 RenderSurfaceLayerListType>&
2271 inputs, 2291 inputs,
2272 SubtreeGlobals<LayerType>* globals, 2292 SubtreeGlobals<LayerType>* globals,
2273 DataForRecursion<LayerType>* data_for_recursion) { 2293 DataForRecursion<LayerType>* data_for_recursion) {
2274 DCHECK(inputs.root_layer); 2294 DCHECK(inputs.root_layer);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 void LayerTreeHostCommon::CalculateDrawProperties( 2341 void LayerTreeHostCommon::CalculateDrawProperties(
2322 CalcDrawPropsMainInputs* inputs) { 2342 CalcDrawPropsMainInputs* inputs) {
2323 LayerList dummy_layer_list; 2343 LayerList dummy_layer_list;
2324 SubtreeGlobals<Layer> globals; 2344 SubtreeGlobals<Layer> globals;
2325 DataForRecursion<Layer> data_for_recursion; 2345 DataForRecursion<Layer> data_for_recursion;
2326 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2346 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2327 2347
2328 PreCalculateMetaInformationRecursiveData recursive_data; 2348 PreCalculateMetaInformationRecursiveData recursive_data;
2329 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2349 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2330 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; 2350 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state;
2331 CalculateDrawPropertiesInternal<Layer>(inputs->root_layer, 2351 CalculateDrawPropertiesInternal<Layer>(
2332 globals, 2352 inputs->root_layer,
2333 data_for_recursion, 2353 globals,
2334 inputs->render_surface_layer_list, 2354 data_for_recursion,
2335 &dummy_layer_list, 2355 inputs->render_surface_layer_list,
2336 &accumulated_surface_state); 2356 &dummy_layer_list,
2357 &accumulated_surface_state,
2358 inputs->current_calculate_draw_properties_count);
2337 2359
2338 // The dummy layer list should not have been used. 2360 // The dummy layer list should not have been used.
2339 DCHECK_EQ(0u, dummy_layer_list.size()); 2361 DCHECK_EQ(0u, dummy_layer_list.size());
2340 // A root layer render_surface should always exist after 2362 // A root layer render_surface should always exist after
2341 // CalculateDrawProperties. 2363 // CalculateDrawProperties.
2342 DCHECK(inputs->root_layer->render_surface()); 2364 DCHECK(inputs->root_layer->render_surface());
2343 } 2365 }
2344 2366
2345 void LayerTreeHostCommon::CalculateDrawProperties( 2367 void LayerTreeHostCommon::CalculateDrawProperties(
2346 CalcDrawPropsImplInputs* inputs) { 2368 CalcDrawPropsImplInputs* inputs) {
2347 LayerImplList dummy_layer_list; 2369 LayerImplList dummy_layer_list;
2348 SubtreeGlobals<LayerImpl> globals; 2370 SubtreeGlobals<LayerImpl> globals;
2349 DataForRecursion<LayerImpl> data_for_recursion; 2371 DataForRecursion<LayerImpl> data_for_recursion;
2350 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2372 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2351 2373
2352 LayerSorter layer_sorter; 2374 LayerSorter layer_sorter;
2353 globals.layer_sorter = &layer_sorter; 2375 globals.layer_sorter = &layer_sorter;
2354 2376
2355 PreCalculateMetaInformationRecursiveData recursive_data; 2377 PreCalculateMetaInformationRecursiveData recursive_data;
2356 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); 2378 PreCalculateMetaInformation(inputs->root_layer, &recursive_data);
2357 std::vector<AccumulatedSurfaceState<LayerImpl> > 2379 std::vector<AccumulatedSurfaceState<LayerImpl> >
2358 accumulated_surface_state; 2380 accumulated_surface_state;
2359 CalculateDrawPropertiesInternal<LayerImpl>(inputs->root_layer, 2381 CalculateDrawPropertiesInternal<LayerImpl>(
2360 globals, 2382 inputs->root_layer,
2361 data_for_recursion, 2383 globals,
2362 inputs->render_surface_layer_list, 2384 data_for_recursion,
2363 &dummy_layer_list, 2385 inputs->render_surface_layer_list,
2364 &accumulated_surface_state); 2386 &dummy_layer_list,
2387 &accumulated_surface_state,
2388 inputs->current_calculate_draw_properties_count);
2365 2389
2366 // The dummy layer list should not have been used. 2390 // The dummy layer list should not have been used.
2367 DCHECK_EQ(0u, dummy_layer_list.size()); 2391 DCHECK_EQ(0u, dummy_layer_list.size());
2368 // A root layer render_surface should always exist after 2392 // A root layer render_surface should always exist after
2369 // CalculateDrawProperties. 2393 // CalculateDrawProperties.
2370 DCHECK(inputs->root_layer->render_surface()); 2394 DCHECK(inputs->root_layer->render_surface());
2371 } 2395 }
2372 2396
2373 static bool PointHitsRect( 2397 static bool PointHitsRect(
2374 const gfx::PointF& screen_space_point, 2398 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 2604 // 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 2605 // 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 2606 // was not clipped in such a way that the hit point actually should not hit
2583 // the layer. 2607 // the layer.
2584 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) 2608 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl))
2585 return false; 2609 return false;
2586 2610
2587 return true; 2611 return true;
2588 } 2612 }
2589 } // namespace cc 2613 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698