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 layer_draw_properties.is_clipped = layer_or_ancestor_clips_descendants; | 2064 DCHECK_EQ(layer_or_ancestor_clips_descendants, layer->is_clipped()); |
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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2400 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned; | 2400 transform->Preserves2dAxisAlignment() && *draw_transform_is_axis_aligned; |
2401 if (IsRootLayer(layer) || (can_render_to_separate_surface && | 2401 if (IsRootLayer(layer) || (can_render_to_separate_surface && |
2402 SubtreeShouldRenderToSeparateSurface( | 2402 SubtreeShouldRenderToSeparateSurface( |
2403 layer, preserves_2d_axis_alignment))) { | 2403 layer, preserves_2d_axis_alignment))) { |
2404 // We reset the transform here so that any axis-changing transforms | 2404 // We reset the transform here so that any axis-changing transforms |
2405 // will now be relative to this RenderSurface. | 2405 // will now be relative to this RenderSurface. |
2406 transform->MakeIdentity(); | 2406 transform->MakeIdentity(); |
2407 *draw_transform_is_axis_aligned = true; | 2407 *draw_transform_is_axis_aligned = true; |
2408 if (!layer->render_surface()) { | 2408 if (!layer->render_surface()) { |
2409 layer->CreateRenderSurface(); | 2409 layer->CreateRenderSurface(); |
2410 layer->layer_tree_host()->property_trees()->needs_rebuild = true; | |
ajuma
2015/07/10 22:16:18
How about doing this inside Layer::SetHasRenderSur
jaydasika
2015/07/13 14:38:44
Done.
| |
2410 } | 2411 } |
2411 layer->SetHasRenderSurface(true); | 2412 layer->SetHasRenderSurface(true); |
2412 return; | 2413 return; |
2413 } | 2414 } |
2414 layer->SetHasRenderSurface(false); | 2415 layer->SetHasRenderSurface(false); |
2415 if (layer->render_surface()) | 2416 if (layer->render_surface()) { |
2416 layer->ClearRenderSurface(); | 2417 layer->ClearRenderSurface(); |
2418 layer->layer_tree_host()->property_trees()->needs_rebuild = true; | |
2419 } | |
2417 } | 2420 } |
2418 | 2421 |
2419 void LayerTreeHostCommon::UpdateRenderSurfaces( | 2422 void LayerTreeHostCommon::UpdateRenderSurfaces( |
2420 Layer* layer, | 2423 Layer* layer, |
2421 bool can_render_to_separate_surface, | 2424 bool can_render_to_separate_surface, |
2422 const gfx::Transform& parent_transform, | 2425 const gfx::Transform& parent_transform, |
2423 bool draw_transform_is_axis_aligned) { | 2426 bool draw_transform_is_axis_aligned) { |
2424 gfx::Transform transform_for_children = layer->transform(); | 2427 gfx::Transform transform_for_children = layer->transform(); |
2425 transform_for_children *= parent_transform; | 2428 transform_for_children *= parent_transform; |
2426 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment(); | 2429 draw_transform_is_axis_aligned &= layer->AnimationsPreserveAxisAlignment(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2494 << DrawTransformFromPropertyTrees( | 2497 << DrawTransformFromPropertyTrees( |
2495 current_layer, property_trees->transform_tree).ToString(); | 2498 current_layer, property_trees->transform_tree).ToString(); |
2496 | 2499 |
2497 const bool draw_opacities_match = | 2500 const bool draw_opacities_match = |
2498 current_layer->draw_opacity() == | 2501 current_layer->draw_opacity() == |
2499 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); | 2502 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); |
2500 CHECK(draw_opacities_match) | 2503 CHECK(draw_opacities_match) |
2501 << "expected: " << current_layer->draw_opacity() | 2504 << "expected: " << current_layer->draw_opacity() |
2502 << " actual: " << DrawOpacityFromPropertyTrees( | 2505 << " actual: " << DrawOpacityFromPropertyTrees( |
2503 current_layer, property_trees->opacity_tree); | 2506 current_layer, property_trees->opacity_tree); |
2507 | |
2504 const bool can_use_lcd_text_match = | 2508 const bool can_use_lcd_text_match = |
2505 CanUseLcdTextFromPropertyTrees( | 2509 CanUseLcdTextFromPropertyTrees( |
2506 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, | 2510 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, |
2507 property_trees) == current_layer->can_use_lcd_text(); | 2511 property_trees) == current_layer->can_use_lcd_text(); |
2508 CHECK(can_use_lcd_text_match); | 2512 CHECK(can_use_lcd_text_match); |
2509 } | 2513 } |
2510 | 2514 |
2511 void VerifyPropertyTreeValues( | 2515 void VerifyPropertyTreeValues( |
2512 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { | 2516 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { |
2513 } | 2517 } |
(...skipping 29 matching lines...) Expand all Loading... | |
2543 | 2547 |
2544 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); | 2548 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); |
2545 UpdateMetaInformationSequenceNumber(inputs->root_layer); | 2549 UpdateMetaInformationSequenceNumber(inputs->root_layer); |
2546 PreCalculateMetaInformationRecursiveData recursive_data; | 2550 PreCalculateMetaInformationRecursiveData recursive_data; |
2547 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); | 2551 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); |
2548 | 2552 |
2549 const bool should_measure_property_tree_performance = | 2553 const bool should_measure_property_tree_performance = |
2550 inputs->verify_property_trees && | 2554 inputs->verify_property_trees && |
2551 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); | 2555 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); |
2552 | 2556 |
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 | |
2569 if (inputs->verify_property_trees) { | 2557 if (inputs->verify_property_trees) { |
2570 typename LayerType::LayerListType update_layer_list; | 2558 typename LayerType::LayerListType update_layer_list; |
2571 | 2559 |
2572 // For testing purposes, sometimes property trees need to be built on the | 2560 // For testing purposes, sometimes property trees need to be built on the |
2573 // compositor thread, so this can't just switch on Layer vs LayerImpl, | 2561 // compositor thread, so this can't just switch on Layer vs LayerImpl, |
2574 // even though in practice only the main thread builds property trees. | 2562 // even though in practice only the main thread builds property trees. |
2575 switch (property_tree_option) { | 2563 switch (property_tree_option) { |
2576 case BUILD_PROPERTY_TREES_IF_NEEDED: { | 2564 case BUILD_PROPERTY_TREES_IF_NEEDED: { |
2577 // The translation from layer to property trees is an intermediate | 2565 // The translation from layer to property trees is an intermediate |
2578 // state. We will eventually get these data passed directly to the | 2566 // state. We will eventually get these data passed directly to the |
(...skipping 22 matching lines...) Expand all Loading... | |
2601 } | 2589 } |
2602 case DONT_BUILD_PROPERTY_TREES: { | 2590 case DONT_BUILD_PROPERTY_TREES: { |
2603 TRACE_EVENT0( | 2591 TRACE_EVENT0( |
2604 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2592 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2605 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); | 2593 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); |
2606 ComputeVisibleRectsUsingPropertyTrees( | 2594 ComputeVisibleRectsUsingPropertyTrees( |
2607 inputs->root_layer, inputs->property_trees, &update_layer_list); | 2595 inputs->root_layer, inputs->property_trees, &update_layer_list); |
2608 break; | 2596 break; |
2609 } | 2597 } |
2610 } | 2598 } |
2599 } | |
2611 | 2600 |
2601 if (should_measure_property_tree_performance) { | |
2602 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | |
2603 "LayerTreeHostCommon::CalculateDrawProperties"); | |
2604 } | |
2605 | |
2606 std::vector<AccumulatedSurfaceState<LayerType>> accumulated_surface_state; | |
2607 CalculateDrawPropertiesInternal<LayerType>( | |
2608 inputs->root_layer, globals, data_for_recursion, | |
2609 inputs->render_surface_layer_list, &dummy_layer_list, | |
2610 &accumulated_surface_state, inputs->current_render_surface_layer_list_id); | |
2611 | |
2612 if (should_measure_property_tree_performance) { | |
2613 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | |
2614 "LayerTreeHostCommon::CalculateDrawProperties"); | |
2615 } | |
2616 | |
2617 if (inputs->verify_property_trees) | |
2612 VerifyPropertyTreeValues(inputs); | 2618 VerifyPropertyTreeValues(inputs); |
2613 } | |
2614 | 2619 |
2615 // The dummy layer list should not have been used. | 2620 // The dummy layer list should not have been used. |
2616 DCHECK_EQ(0u, dummy_layer_list.size()); | 2621 DCHECK_EQ(0u, dummy_layer_list.size()); |
2617 // A root layer render_surface should always exist after | 2622 // A root layer render_surface should always exist after |
2618 // CalculateDrawProperties. | 2623 // CalculateDrawProperties. |
2619 DCHECK(inputs->root_layer->render_surface()); | 2624 DCHECK(inputs->root_layer->render_surface()); |
2620 } | 2625 } |
2621 | 2626 |
2622 void LayerTreeHostCommon::CalculateDrawProperties( | 2627 void LayerTreeHostCommon::CalculateDrawProperties( |
2623 CalcDrawPropsMainInputs* inputs) { | 2628 CalcDrawPropsMainInputs* inputs) { |
(...skipping 15 matching lines...) Expand all Loading... | |
2639 | 2644 |
2640 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2645 PropertyTrees* GetPropertyTrees(Layer* layer) { |
2641 return layer->layer_tree_host()->property_trees(); | 2646 return layer->layer_tree_host()->property_trees(); |
2642 } | 2647 } |
2643 | 2648 |
2644 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2649 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
2645 return layer->layer_tree_impl()->property_trees(); | 2650 return layer->layer_tree_impl()->property_trees(); |
2646 } | 2651 } |
2647 | 2652 |
2648 } // namespace cc | 2653 } // namespace cc |
OLD | NEW |