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