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

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
« no previous file with comments | « cc/trees/draw_property_utils.cc ('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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 return false; 661 return false;
662 662
663 // If layer has a background filter, don't skip the layer, even it the 663 // If layer has a background filter, don't skip the layer, even it the
664 // opacity is 0. 664 // opacity is 0.
665 if (!layer->background_filters().IsEmpty()) 665 if (!layer->background_filters().IsEmpty())
666 return false; 666 return false;
667 667
668 // The opacity of a layer always applies to its children (either implicitly 668 // The opacity of a layer always applies to its children (either implicitly
669 // via a render surface or explicitly if the parent preserves 3D), so the 669 // via a render surface or explicitly if the parent preserves 3D), so the
670 // entire subtree can be skipped if this layer is fully transparent. 670 // entire subtree can be skipped if this layer is fully transparent.
671 return !layer->opacity(); 671 return !layer->EffectiveOpacity();
672 } 672 }
673 673
674 static inline void SavePaintPropertiesLayer(LayerImpl* layer) {} 674 static inline void SavePaintPropertiesLayer(LayerImpl* layer) {}
675 675
676 // This function returns a translation matrix that can be applied on a vector 676 // This function returns a translation matrix that can be applied on a vector
677 // that's in the layer's target surface coordinate, while the position offset is 677 // that's in the layer's target surface coordinate, while the position offset is
678 // specified in some ancestor layer's coordinate. 678 // specified in some ancestor layer's coordinate.
679 gfx::Transform ComputeSizeDeltaCompensation( 679 gfx::Transform ComputeSizeDeltaCompensation(
680 LayerImpl* layer, 680 LayerImpl* layer,
681 LayerImpl* container, 681 LayerImpl* container,
(...skipping 827 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->EffectiveOpacity() != 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 =
2343 (subtree_visible_from_ancestor && layer->EffectiveOpacity() != 0) ||
2344 layer->HasCopyRequest();
2345 }
2336 2346
2337 // The root layer cannot be skipped. 2347 // The root layer cannot be skipped.
2338 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2348 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2339 layer->draw_properties().render_target = nullptr; 2349 layer->draw_properties().render_target = nullptr;
2340 return; 2350 return;
2341 } 2351 }
2342 2352
2343 bool render_to_separate_surface = 2353 bool render_to_separate_surface =
2344 IsRootLayer(layer) || 2354 IsRootLayer(layer) ||
2345 (can_render_to_separate_surface && layer->render_surface()); 2355 (can_render_to_separate_surface && layer->render_surface());
(...skipping 12 matching lines...) Expand all
2358 layer; 2368 layer;
2359 2369
2360 } else { 2370 } else {
2361 DCHECK(layer->parent()); 2371 DCHECK(layer->parent());
2362 layer->draw_properties().render_target = layer->parent()->render_target(); 2372 layer->draw_properties().render_target = layer->parent()->render_target();
2363 } 2373 }
2364 2374
2365 for (size_t i = 0; i < layer->children().size(); ++i) { 2375 for (size_t i = 0; i < layer->children().size(); ++i) {
2366 CalculateRenderTargetInternal( 2376 CalculateRenderTargetInternal(
2367 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i), 2377 LayerTreeHostCommon::get_layer_as_raw_ptr(layer->children(), i),
2368 layer_is_drawn, can_render_to_separate_surface); 2378 property_trees, layer_is_drawn, can_render_to_separate_surface,
2379 use_property_trees);
2369 } 2380 }
2370 } 2381 }
2371 2382
2372 void CalculateRenderSurfaceLayerListInternal( 2383 void CalculateRenderSurfaceLayerListInternal(
2373 LayerImpl* layer, 2384 LayerImpl* layer,
2374 PropertyTrees* property_trees, 2385 PropertyTrees* property_trees,
2375 LayerImplList* render_surface_layer_list, 2386 LayerImplList* render_surface_layer_list,
2376 LayerImplList* descendants, 2387 LayerImplList* descendants,
2377 RenderSurfaceImpl* nearest_occlusion_immune_ancestor, 2388 RenderSurfaceImpl* nearest_occlusion_immune_ancestor,
2378 bool subtree_visible_from_ancestor, 2389 bool subtree_visible_from_ancestor,
(...skipping 10 matching lines...) Expand all
2389 // |render_surface_layer_list| is the top level RenderSurfaceLayerList. 2400 // |render_surface_layer_list| is the top level RenderSurfaceLayerList.
2390 2401
2391 // |descendants| is used to determine what's in current layer's render 2402 // |descendants| is used to determine what's in current layer's render
2392 // surface's layer list. 2403 // surface's layer list.
2393 2404
2394 // |subtree_visible_from_ancestor| is set during recursion to affect current 2405 // |subtree_visible_from_ancestor| is set during recursion to affect current
2395 // layer's subtree. 2406 // layer's subtree.
2396 2407
2397 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id| 2408 // |can_render_to_separate_surface| and |current_render_surface_layer_list_id|
2398 // are settings that should stay the same during recursion. 2409 // are settings that should stay the same during recursion.
2399 2410 bool layer_is_drawn = false;
2400 // Layers that are marked as hidden will hide themselves and their subtree. 2411 if (use_property_trees) {
2401 // Exception: Layers with copy requests, whether hidden or not, must be drawn 2412 DCHECK_GE(layer->effect_tree_index(), 0);
2402 // anyway. In this case, we will inform their subtree they are visible to get 2413 layer_is_drawn =
2403 // the right results. 2414 property_trees->effect_tree.Node(layer->effect_tree_index())
2404 const bool layer_is_visible = 2415 ->data.is_drawn;
2405 subtree_visible_from_ancestor && !layer->hide_layer_and_subtree(); 2416 } else {
2406 const bool layer_is_drawn = layer_is_visible || layer->HasCopyRequest(); 2417 layer_is_drawn =
2418 (subtree_visible_from_ancestor && layer->EffectiveOpacity() != 0) ||
2419 layer->HasCopyRequest();
2420 }
2407 2421
2408 // The root layer cannot be skipped. 2422 // The root layer cannot be skipped.
2409 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) { 2423 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_drawn)) {
2410 if (layer->render_surface()) 2424 if (layer->render_surface())
2411 layer->ClearRenderSurfaceLayerList(); 2425 layer->ClearRenderSurfaceLayerList();
2412 layer->draw_properties().render_target = nullptr; 2426 layer->draw_properties().render_target = nullptr;
2413 return; 2427 return;
2414 } 2428 }
2415 2429
2416 bool render_to_separate_surface = 2430 bool render_to_separate_surface =
(...skipping 28 matching lines...) Expand all
2445 layer->ClearRenderSurfaceLayerList(); 2459 layer->ClearRenderSurfaceLayerList();
2446 layer->draw_properties().render_target = nullptr; 2460 layer->draw_properties().render_target = nullptr;
2447 return; 2461 return;
2448 } 2462 }
2449 2463
2450 if (IsRootLayer(layer)) { 2464 if (IsRootLayer(layer)) {
2451 // The root surface does not contribute to any other surface, it has no 2465 // The root surface does not contribute to any other surface, it has no
2452 // target. 2466 // target.
2453 layer->render_surface()->set_contributes_to_drawn_surface(false); 2467 layer->render_surface()->set_contributes_to_drawn_surface(false);
2454 } else { 2468 } else {
2455 // Even if the |layer_is_drawn|, it only contributes to a drawn surface 2469 bool contributes_to_drawn_surface =
2456 // when the |layer_is_visible|. 2470 use_property_trees
2471 ? property_trees->effect_tree.ContributesToDrawnSurface(
2472 layer->effect_tree_index())
2473 : subtree_visible_from_ancestor &&
2474 layer->EffectiveOpacity() != 0.f;
2457 layer->render_surface()->set_contributes_to_drawn_surface( 2475 layer->render_surface()->set_contributes_to_drawn_surface(
2458 layer_is_visible); 2476 contributes_to_drawn_surface);
2459 } 2477 }
2460 2478
2461 // Ignore occlusion from outside the surface when surface contents need to 2479 // Ignore occlusion from outside the surface when surface contents need to
2462 // be fully drawn. Layers with copy-request need to be complete. 2480 // be fully drawn. Layers with copy-request need to be complete.
2463 // We could be smarter about layers with replica and exclude regions 2481 // 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 2482 // 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. 2483 // overkill. The same is true for layers with filters that move pixels.
2466 // TODO(senorblanco): make this smarter for the SkImageFilter case (check 2484 // TODO(senorblanco): make this smarter for the SkImageFilter case (check
2467 // for pixel-moving filters) 2485 // for pixel-moving filters)
2468 if (layer->HasCopyRequest() || layer->has_replica() || 2486 if (layer->HasCopyRequest() || layer->has_replica() ||
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2613 2631
2614 if (layer->HasContributingDelegatedRenderPasses()) { 2632 if (layer->HasContributingDelegatedRenderPasses()) {
2615 layer->render_target() 2633 layer->render_target()
2616 ->render_surface() 2634 ->render_surface()
2617 ->AddContributingDelegatedRenderPassLayer(layer); 2635 ->AddContributingDelegatedRenderPassLayer(layer);
2618 } 2636 }
2619 } 2637 }
2620 2638
2621 void CalculateRenderTarget( 2639 void CalculateRenderTarget(
2622 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { 2640 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
2623 CalculateRenderTargetInternal(inputs->root_layer, true, 2641 CalculateRenderTargetInternal(
2624 inputs->can_render_to_separate_surface); 2642 inputs->root_layer, inputs->property_trees, true,
2643 inputs->can_render_to_separate_surface,
2644 inputs->verify_property_trees || inputs->use_property_trees);
2625 } 2645 }
2626 2646
2627 void CalculateRenderSurfaceLayerList( 2647 void CalculateRenderSurfaceLayerList(
2628 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { 2648 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) {
2629 const bool subtree_visible_from_ancestor = true; 2649 const bool subtree_visible_from_ancestor = true;
2630 DCHECK_EQ( 2650 DCHECK_EQ(
2631 inputs->current_render_surface_layer_list_id, 2651 inputs->current_render_surface_layer_list_id,
2632 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id()); 2652 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id());
2633 CalculateRenderSurfaceLayerListInternal( 2653 CalculateRenderSurfaceLayerListInternal(
2634 inputs->root_layer, inputs->property_trees, 2654 inputs->root_layer, inputs->property_trees,
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2828 2848
2829 PropertyTrees* GetPropertyTrees(Layer* layer) { 2849 PropertyTrees* GetPropertyTrees(Layer* layer) {
2830 return layer->layer_tree_host()->property_trees(); 2850 return layer->layer_tree_host()->property_trees();
2831 } 2851 }
2832 2852
2833 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 2853 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
2834 return layer->layer_tree_impl()->property_trees(); 2854 return layer->layer_tree_impl()->property_trees();
2835 } 2855 }
2836 2856
2837 } // namespace cc 2857 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | cc/trees/layer_tree_host_common_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698