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

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

Issue 1588093004: Compute if a layer is drawn without LayerTree hierarchy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 1498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1509 data_from_ancestor.in_subtree_of_page_scale_layer; 1509 data_from_ancestor.in_subtree_of_page_scale_layer;
1510 data_for_children.subtree_can_use_lcd_text = 1510 data_for_children.subtree_can_use_lcd_text =
1511 data_from_ancestor.subtree_can_use_lcd_text; 1511 data_from_ancestor.subtree_can_use_lcd_text;
1512 1512
1513 // Layers that are marked as hidden will hide themselves and their subtree. 1513 // Layers that are marked as hidden will hide themselves and their subtree.
1514 // Exception: Layers with copy requests, whether hidden or not, must be drawn 1514 // Exception: Layers with copy requests, whether hidden or not, must be drawn
1515 // anyway. In this case, we will inform their subtree they are visible to get 1515 // anyway. In this case, we will inform their subtree they are visible to get
1516 // the right results. 1516 // the right results.
1517 const bool layer_is_visible = 1517 const bool layer_is_visible =
1518 data_from_ancestor.subtree_is_visible_from_ancestor && 1518 data_from_ancestor.subtree_is_visible_from_ancestor &&
1519 !layer->hide_layer_and_subtree(); 1519 layer->opacity() != 0;
1520 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); 1520 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest();
1521 1521
1522 // The root layer cannot skip CalcDrawProperties. 1522 // The root layer cannot skip CalcDrawProperties.
1523 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 1523 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
1524 return; 1524 return;
1525 } 1525 }
1526 1526
1527 // We need to circumvent the normal recursive flow of information for clip 1527 // We need to circumvent the normal recursive flow of information for clip
1528 // children (they don't inherit their direct ancestor's clip information). 1528 // children (they don't inherit their direct ancestor's clip information).
1529 // This is unfortunate, and would be unnecessary if we were to formally 1529 // This is unfortunate, and would be unnecessary if we were to formally
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
2321 inputs->can_use_lcd_text); 2321 inputs->can_use_lcd_text);
2322 } 2322 }
2323 } 2323 }
2324 2324
2325 enum PropertyTreeOption { 2325 enum PropertyTreeOption {
2326 BUILD_PROPERTY_TREES_IF_NEEDED, 2326 BUILD_PROPERTY_TREES_IF_NEEDED,
2327 DONT_BUILD_PROPERTY_TREES 2327 DONT_BUILD_PROPERTY_TREES
2328 }; 2328 };
2329 2329
2330 void CalculateRenderTargetInternal(LayerImpl* layer, 2330 void CalculateRenderTargetInternal(LayerImpl* layer,
2331 PropertyTrees* property_trees,
2331 bool subtree_visible_from_ancestor, 2332 bool subtree_visible_from_ancestor,
2332 bool can_render_to_separate_surface) { 2333 bool can_render_to_separate_surface,
2333 const bool layer_is_visible = 2334 bool use_property_trees) {
2334 subtree_visible_from_ancestor && !layer->hide_layer_and_subtree(); 2335 bool layer_is_drawn;
2335 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); 2336 if (use_property_trees) {
2337 DCHECK_GE(layer->effect_tree_index(), 0);
2338 layer_is_drawn =
2339 property_trees->effect_tree.Node(layer->effect_tree_index())
2340 ->data.is_drawn;
2341 } else {
2342 layer_is_drawn = (subtree_visible_from_ancestor && layer->opacity() != 0) ||
2343 layer->HasCopyRequest();
2344 }
2336 2345
2337 // The root layer cannot be skipped. 2346 // The root layer cannot be skipped.
2338 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2347 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2339 layer->draw_properties().render_target = nullptr; 2348 layer->draw_properties().render_target = nullptr;
2340 return; 2349 return;
2341 } 2350 }
2342 2351
2343 bool render_to_separate_surface = 2352 bool render_to_separate_surface =
2344 IsRootLayer(layer) || 2353 IsRootLayer(layer) ||
2345 (can_render_to_separate_surface && layer->render_surface()); 2354 (can_render_to_separate_surface && layer->render_surface());
(...skipping 12 matching lines...) Expand all
2358 layer; 2367 layer;
2359 2368
2360 } else { 2369 } else {
2361 DCHECK(layer->parent()); 2370 DCHECK(layer->parent());
2362 layer->draw_properties().render_target = layer->parent()->render_target(); 2371 layer->draw_properties().render_target = layer->parent()->render_target();
2363 } 2372 }
2364 2373
2365 for (size_t i = 0; i < layer->children().size(); ++i) { 2374 for (size_t i = 0; i < layer->children().size(); ++i) {
2366 CalculateRenderTargetInternal( 2375 CalculateRenderTargetInternal(
2367 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), 2376 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i),
2368 layer_is_drawn, can_render_to_separate_surface); 2377 property_trees, layer_is_drawn, can_render_to_separate_surface,
2378 use_property_trees);
2369 } 2379 }
2370 } 2380 }
2371 2381
2372 void CalculateRenderSurfaceLayerListInternal( 2382 void CalculateRenderSurfaceLayerListInternal(
2373 LayerImpl* layer, 2383 LayerImpl* layer,
2374 PropertyTrees* property_trees, 2384 PropertyTrees* property_trees,
2375 LayerImplList* render_surface_layer_list, 2385 LayerImplList* render_surface_layer_list,
2376 LayerImplList* descendants, 2386 LayerImplList* descendants,
2377 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, 2387 RenderSurfaceImpl* nearest_occlusion_immune_ancestor,
2378 bool subtree_visible_from_ancestor, 2388 bool subtree_visible_from_ancestor,
(...skipping 10 matching lines...) Expand all
2389 // |render_surface_layer_list| is the top level RenderSurfaceLayerList. 2399 // |render_surface_layer_list| is the top level RenderSurfaceLayerList.
2390 2400
2391 // |descendants| is used to determine what's in current layer's render 2401 // |descendants| is used to determine what's in current layer's render
2392 // surface's layer list. 2402 // surface's layer list.
2393 2403
2394 // |subtree_visible_from_ancestor| is set during recursion to affect current 2404 // |subtree_visible_from_ancestor| is set during recursion to affect current
2395 // layer's subtree. 2405 // layer's subtree.
2396 2406
2397 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id| 2407 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id|
2398 // are settings that should stay the same during recursion. 2408 // are settings that should stay the same during recursion.
2399 2409 bool layer_is_drawn = false;
2400 // Layers that are marked as hidden will hide themselves and their subtree. 2410 if (use_property_trees) {
2401 // Exception: Layers with copy requests, whether hidden or not, must be drawn 2411 DCHECK_GE(layer->effect_tree_index(), 0);
2402 // anyway. In this case, we will inform their subtree they are visible to get 2412 layer_is_drawn =
2403 // the right results. 2413 property_trees->effect_tree.Node(layer->effect_tree_index())
2404 const bool layer_is_visible = 2414 ->data.is_drawn;
2405 subtree_visible_from_ancestor && !layer->hide_layer_and_subtree(); 2415 } else {
2406 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); 2416 layer_is_drawn = (subtree_visible_from_ancestor && layer->opacity() != 0) ||
2417 layer->HasCopyRequest();
2418 }
2407 2419
2408 // The root layer cannot be skipped. 2420 // The root layer cannot be skipped.
2409 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2421 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2410 if (layer->render_surface()) 2422 if (layer->render_surface())
2411 layer->ClearRenderSurfaceLayerList(); 2423 layer->ClearRenderSurfaceLayerList();
2412 layer->draw_properties().render_target = nullptr; 2424 layer->draw_properties().render_target = nullptr;
2413 return; 2425 return;
2414 } 2426 }
2415 2427
2416 bool render_to_separate_surface = 2428 bool render_to_separate_surface =
(...skipping 28 matching lines...) Expand all
2445 layer->ClearRenderSurfaceLayerList(); 2457 layer->ClearRenderSurfaceLayerList();
2446 layer->draw_properties().render_target = nullptr; 2458 layer->draw_properties().render_target = nullptr;
2447 return; 2459 return;
2448 } 2460 }
2449 2461
2450 if (IsRootLayer(layer)) { 2462 if (IsRootLayer(layer)) {
2451 // The root surface does not contribute to any other surface, it has no 2463 // The root surface does not contribute to any other surface, it has no
2452 // target. 2464 // target.
2453 layer->render_surface()->set_contributes_to_drawn_surface(false); 2465 layer->render_surface()->set_contributes_to_drawn_surface(false);
2454 } else { 2466 } else {
2455 // Even if the |layer_is_drawn|, it only contributes to a drawn surface 2467 bool contributes_to_drawn_surface =
2456 // when the |layer_is_visible|. 2468 use_property_trees
2469 ? property_trees->effect_tree.ContributesToDrawnSurface(
2470 layer->effect_tree_index())
2471 : subtree_visible_from_ancestor && layer->opacity() != 0.f;
2457 layer->render_surface()->set_contributes_to_drawn_surface( 2472 layer->render_surface()->set_contributes_to_drawn_surface(
2458 layer_is_visible); 2473 contributes_to_drawn_surface);
2459 } 2474 }
2460 2475
2461 // Ignore occlusion from outside the surface when surface contents need to 2476 // Ignore occlusion from outside the surface when surface contents need to
2462 // be fully drawn. Layers with copy-request need to be complete. 2477 // be fully drawn. Layers with copy-request need to be complete.
2463 // We could be smarter about layers with replica and exclude regions 2478 // We could be smarter about layers with replica and exclude regions
2464 // where both layer and the replica are occluded, but this seems like an 2479 // where both layer and the replica are occluded, but this seems like an
2465 // overkill. The same is true for layers with filters that move pixels. 2480 // overkill. The same is true for layers with filters that move pixels.
2466 // TODO(senorblanco): make this smarter for the SkImageFilter case (check 2481 // TODO(senorblanco): make this smarter for the SkImageFilter case (check
2467 // for pixel-moving filters) 2482 // for pixel-moving filters)
2468 if (layer->HasCopyRequest() || layer->has_replica() || 2483 if (layer->HasCopyRequest() || layer->has_replica() ||
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 2628
2614 if (layer->HasContributingDelegatedRenderPasses()) { 2629 if (layer->HasContributingDelegatedRenderPasses()) {
2615 layer->render_target() 2630 layer->render_target()
2616 ->render_surface() 2631 ->render_surface()
2617 ->AddContributingDelegatedRenderPassLayer(layer); 2632 ->AddContributingDelegatedRenderPassLayer(layer);
2618 } 2633 }
2619 } 2634 }
2620 2635
2621 void CalculateRenderTarget( 2636 void CalculateRenderTarget(
2622 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { 2637 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
2623 CalculateRenderTargetInternal(inputs->root_layer, true, 2638 CalculateRenderTargetInternal(
2624 inputs->can_render_to_separate_surface); 2639 inputs->root_layer, inputs->property_trees, true,
2640 inputs->can_render_to_separate_surface,
2641 inputs->verify_property_trees || inputs->use_property_trees);
2625 } 2642 }
2626 2643
2627 void CalculateRenderSurfaceLayerList( 2644 void CalculateRenderSurfaceLayerList(
2628 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { 2645 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
2629 const bool subtree_visible_from_ancestor = true; 2646 const bool subtree_visible_from_ancestor = true;
2630 DCHECK_EQ( 2647 DCHECK_EQ(
2631 inputs->current_render_surface_layer_list_id, 2648 inputs->current_render_surface_layer_list_id,
2632 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id()); 2649 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id());
2633 CalculateRenderSurfaceLayerListInternal( 2650 CalculateRenderSurfaceLayerListInternal(
2634 inputs->root_layer, inputs->property_trees, 2651 inputs->root_layer, inputs->property_trees,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 2845
2829 PropertyTrees* GetPropertyTrees(Layer* layer) { 2846 PropertyTrees* GetPropertyTrees(Layer* layer) {
2830 return layer->layer_tree_host()->property_trees(); 2847 return layer->layer_tree_host()->property_trees();
2831 } 2848 }
2832 2849
2833 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 2850 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
2834 return layer->layer_tree_impl()->property_trees(); 2851 return layer->layer_tree_impl()->property_trees();
2835 } 2852 }
2836 2853
2837 } // namespace cc 2854 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698