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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 } else { | 2054 } else { |
2055 clip_rect_in_target_space = rect_in_target_space; | 2055 clip_rect_in_target_space = rect_in_target_space; |
2056 } | 2056 } |
2057 } | 2057 } |
2058 | 2058 |
2059 // Tell the layer the rect that it's clipped by. In theory we could use a | 2059 // Tell the layer the rect that it's clipped by. In theory we could use a |
2060 // tighter clip rect here (drawable_content_rect), but that actually does not | 2060 // tighter clip rect here (drawable_content_rect), but that actually does not |
2061 // reduce how much would be drawn, and instead it would create unnecessary | 2061 // reduce how much would be drawn, and instead it would create unnecessary |
2062 // changes to scissor state affecting GPU performance. Our clip information | 2062 // changes to scissor state affecting GPU performance. Our clip information |
2063 // is used in the recursion below, so we must set it beforehand. | 2063 // is used in the recursion below, so we must set it beforehand. |
2064 DCHECK_EQ(layer_or_ancestor_clips_descendants, layer->is_clipped()); | 2064 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; |
2065 if (layer_or_ancestor_clips_descendants) { | 2065 if (layer_or_ancestor_clips_descendants) { |
2066 layer_draw_properties.clip_rect = clip_rect_in_target_space; | 2066 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
2067 } else { | 2067 } else { |
2068 // Initialize the clip rect to a safe value that will not clip the | 2068 // Initialize the clip rect to a safe value that will not clip the |
2069 // layer, just in case clipping is still accidentally used. | 2069 // layer, just in case clipping is still accidentally used. |
2070 layer_draw_properties.clip_rect = rect_in_target_space; | 2070 layer_draw_properties.clip_rect = rect_in_target_space; |
2071 } | 2071 } |
2072 | 2072 |
2073 typename LayerType::LayerListType& descendants = | 2073 typename LayerType::LayerListType& descendants = |
2074 (render_to_separate_surface ? layer->render_surface()->layer_list() | 2074 (render_to_separate_surface ? layer->render_surface()->layer_list() |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2494 << DrawTransformFromPropertyTrees( | 2494 << DrawTransformFromPropertyTrees( |
2495 current_layer, property_trees->transform_tree).ToString(); | 2495 current_layer, property_trees->transform_tree).ToString(); |
2496 | 2496 |
2497 const bool draw_opacities_match = | 2497 const bool draw_opacities_match = |
2498 current_layer->draw_opacity() == | 2498 current_layer->draw_opacity() == |
2499 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); | 2499 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); |
2500 CHECK(draw_opacities_match) | 2500 CHECK(draw_opacities_match) |
2501 << "expected: " << current_layer->draw_opacity() | 2501 << "expected: " << current_layer->draw_opacity() |
2502 << " actual: " << DrawOpacityFromPropertyTrees( | 2502 << " actual: " << DrawOpacityFromPropertyTrees( |
2503 current_layer, property_trees->opacity_tree); | 2503 current_layer, property_trees->opacity_tree); |
2504 | |
2505 const bool can_use_lcd_text_match = | 2504 const bool can_use_lcd_text_match = |
2506 CanUseLcdTextFromPropertyTrees( | 2505 CanUseLcdTextFromPropertyTrees( |
2507 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, | 2506 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, |
2508 property_trees) == current_layer->can_use_lcd_text(); | 2507 property_trees) == current_layer->can_use_lcd_text(); |
2509 CHECK(can_use_lcd_text_match); | 2508 CHECK(can_use_lcd_text_match); |
2510 } | 2509 } |
2511 | 2510 |
2512 void VerifyPropertyTreeValues( | 2511 void VerifyPropertyTreeValues( |
2513 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { | 2512 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { |
2514 } | 2513 } |
(...skipping 29 matching lines...) Expand all Loading... |
2544 | 2543 |
2545 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2544 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
2546 UpdateMetaInformationSequenceNumber(inputs->root_layer); | 2545 UpdateMetaInformationSequenceNumber(inputs->root_layer); |
2547 PreCalculateMetaInformationRecursiveData recursive_data; | 2546 PreCalculateMetaInformationRecursiveData recursive_data; |
2548 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); | 2547 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); |
2549 | 2548 |
2550 const bool should_measure_property_tree_performance = | 2549 const bool should_measure_property_tree_performance = |
2551 inputs->verify_property_trees && | 2550 inputs->verify_property_trees && |
2552 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); | 2551 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); |
2553 | 2552 |
| 2553 if (should_measure_property_tree_performance) { |
| 2554 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
| 2555 "LayerTreeHostCommon::CalculateDrawProperties"); |
| 2556 } |
| 2557 |
| 2558 std::vector<AccumulatedSurfaceState<LayerType>> accumulated_surface_state; |
| 2559 CalculateDrawPropertiesInternal<LayerType>( |
| 2560 inputs->root_layer, globals, data_for_recursion, |
| 2561 inputs->render_surface_layer_list, &dummy_layer_list, |
| 2562 &accumulated_surface_state, inputs->current_render_surface_layer_list_id); |
| 2563 |
| 2564 if (should_measure_property_tree_performance) { |
| 2565 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
| 2566 "LayerTreeHostCommon::CalculateDrawProperties"); |
| 2567 } |
| 2568 |
2554 if (inputs->verify_property_trees) { | 2569 if (inputs->verify_property_trees) { |
2555 typename LayerType::LayerListType update_layer_list; | 2570 typename LayerType::LayerListType update_layer_list; |
2556 | 2571 |
2557 // For testing purposes, sometimes property trees need to be built on the | 2572 // For testing purposes, sometimes property trees need to be built on the |
2558 // compositor thread, so this can't just switch on Layer vs LayerImpl, | 2573 // compositor thread, so this can't just switch on Layer vs LayerImpl, |
2559 // even though in practice only the main thread builds property trees. | 2574 // even though in practice only the main thread builds property trees. |
2560 switch (property_tree_option) { | 2575 switch (property_tree_option) { |
2561 case BUILD_PROPERTY_TREES_IF_NEEDED: { | 2576 case BUILD_PROPERTY_TREES_IF_NEEDED: { |
2562 // The translation from layer to property trees is an intermediate | 2577 // The translation from layer to property trees is an intermediate |
2563 // state. We will eventually get these data passed directly to the | 2578 // state. We will eventually get these data passed directly to the |
(...skipping 22 matching lines...) Expand all Loading... |
2586 } | 2601 } |
2587 case DONT_BUILD_PROPERTY_TREES: { | 2602 case DONT_BUILD_PROPERTY_TREES: { |
2588 TRACE_EVENT0( | 2603 TRACE_EVENT0( |
2589 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2604 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2590 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); | 2605 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); |
2591 ComputeVisibleRectsUsingPropertyTrees( | 2606 ComputeVisibleRectsUsingPropertyTrees( |
2592 inputs->root_layer, inputs->property_trees, &update_layer_list); | 2607 inputs->root_layer, inputs->property_trees, &update_layer_list); |
2593 break; | 2608 break; |
2594 } | 2609 } |
2595 } | 2610 } |
| 2611 |
| 2612 VerifyPropertyTreeValues(inputs); |
2596 } | 2613 } |
2597 | 2614 |
2598 if (should_measure_property_tree_performance) { | |
2599 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | |
2600 "LayerTreeHostCommon::CalculateDrawProperties"); | |
2601 } | |
2602 | |
2603 std::vector<AccumulatedSurfaceState<LayerType>> accumulated_surface_state; | |
2604 CalculateDrawPropertiesInternal<LayerType>( | |
2605 inputs->root_layer, globals, data_for_recursion, | |
2606 inputs->render_surface_layer_list, &dummy_layer_list, | |
2607 &accumulated_surface_state, inputs->current_render_surface_layer_list_id); | |
2608 | |
2609 if (should_measure_property_tree_performance) { | |
2610 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | |
2611 "LayerTreeHostCommon::CalculateDrawProperties"); | |
2612 } | |
2613 | |
2614 if (inputs->verify_property_trees) | |
2615 VerifyPropertyTreeValues(inputs); | |
2616 | |
2617 // The dummy layer list should not have been used. | 2615 // The dummy layer list should not have been used. |
2618 DCHECK_EQ(0u, dummy_layer_list.size()); | 2616 DCHECK_EQ(0u, dummy_layer_list.size()); |
2619 // A root layer render_surface should always exist after | 2617 // A root layer render_surface should always exist after |
2620 // CalculateDrawProperties. | 2618 // CalculateDrawProperties. |
2621 DCHECK(inputs->root_layer->render_surface()); | 2619 DCHECK(inputs->root_layer->render_surface()); |
2622 } | 2620 } |
2623 | 2621 |
2624 void LayerTreeHostCommon::CalculateDrawProperties( | 2622 void LayerTreeHostCommon::CalculateDrawProperties( |
2625 CalcDrawPropsMainInputs* inputs) { | 2623 CalcDrawPropsMainInputs* inputs) { |
2626 UpdateRenderSurfaces(inputs->root_layer, | 2624 UpdateRenderSurfaces(inputs->root_layer, |
(...skipping 14 matching lines...) Expand all Loading... |
2641 | 2639 |
2642 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2640 PropertyTrees* GetPropertyTrees(Layer* layer) { |
2643 return layer->layer_tree_host()->property_trees(); | 2641 return layer->layer_tree_host()->property_trees(); |
2644 } | 2642 } |
2645 | 2643 |
2646 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2644 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
2647 return layer->layer_tree_impl()->property_trees(); | 2645 return layer->layer_tree_impl()->property_trees(); |
2648 } | 2646 } |
2649 | 2647 |
2650 } // namespace cc | 2648 } // namespace cc |
OLD | NEW |