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

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

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