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

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

Issue 1231453002: Compute if a layer is clipped outside CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialized is_clipped_ Created 5 years, 5 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/test/fake_layer_tree_host_impl.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 <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
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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
2504 const bool can_use_lcd_text_match = 2505 const bool can_use_lcd_text_match =
2505 CanUseLcdTextFromPropertyTrees( 2506 CanUseLcdTextFromPropertyTrees(
2506 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, 2507 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text,
2507 property_trees) == current_layer->can_use_lcd_text(); 2508 property_trees) == current_layer->can_use_lcd_text();
2508 CHECK(can_use_lcd_text_match); 2509 CHECK(can_use_lcd_text_match);
2509 } 2510 }
2510 2511
2511 void VerifyPropertyTreeValues( 2512 void VerifyPropertyTreeValues(
2512 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { 2513 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) {
2513 } 2514 }
(...skipping 29 matching lines...) Expand all
2543 2544
2544 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion); 2545 ProcessCalcDrawPropsInputs(*inputs, &globals, &data_for_recursion);
2545 UpdateMetaInformationSequenceNumber(inputs->root_layer); 2546 UpdateMetaInformationSequenceNumber(inputs->root_layer);
2546 PreCalculateMetaInformationRecursiveData recursive_data; 2547 PreCalculateMetaInformationRecursiveData recursive_data;
2547 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); 2548 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data);
2548 2549
2549 const bool should_measure_property_tree_performance = 2550 const bool should_measure_property_tree_performance =
2550 inputs->verify_property_trees && 2551 inputs->verify_property_trees &&
2551 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); 2552 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED);
2552 2553
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) { 2554 if (inputs->verify_property_trees) {
2570 typename LayerType::LayerListType update_layer_list; 2555 typename LayerType::LayerListType update_layer_list;
2571 2556
2572 // For testing purposes, sometimes property trees need to be built on the 2557 // 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, 2558 // compositor thread, so this can't just switch on Layer vs LayerImpl,
2574 // even though in practice only the main thread builds property trees. 2559 // even though in practice only the main thread builds property trees.
2575 switch (property_tree_option) { 2560 switch (property_tree_option) {
2576 case BUILD_PROPERTY_TREES_IF_NEEDED: { 2561 case BUILD_PROPERTY_TREES_IF_NEEDED: {
2577 // The translation from layer to property trees is an intermediate 2562 // The translation from layer to property trees is an intermediate
2578 // state. We will eventually get these data passed directly to the 2563 // state. We will eventually get these data passed directly to the
(...skipping 22 matching lines...) Expand all
2601 } 2586 }
2602 case DONT_BUILD_PROPERTY_TREES: { 2587 case DONT_BUILD_PROPERTY_TREES: {
2603 TRACE_EVENT0( 2588 TRACE_EVENT0(
2604 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), 2589 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"),
2605 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); 2590 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees");
2606 ComputeVisibleRectsUsingPropertyTrees( 2591 ComputeVisibleRectsUsingPropertyTrees(
2607 inputs->root_layer, inputs->property_trees, &update_layer_list); 2592 inputs->root_layer, inputs->property_trees, &update_layer_list);
2608 break; 2593 break;
2609 } 2594 }
2610 } 2595 }
2596 }
2611 2597
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)
2612 VerifyPropertyTreeValues(inputs); 2615 VerifyPropertyTreeValues(inputs);
2613 }
2614 2616
2615 // The dummy layer list should not have been used. 2617 // The dummy layer list should not have been used.
2616 DCHECK_EQ(0u, dummy_layer_list.size()); 2618 DCHECK_EQ(0u, dummy_layer_list.size());
2617 // A root layer render_surface should always exist after 2619 // A root layer render_surface should always exist after
2618 // CalculateDrawProperties. 2620 // CalculateDrawProperties.
2619 DCHECK(inputs->root_layer->render_surface()); 2621 DCHECK(inputs->root_layer->render_surface());
2620 } 2622 }
2621 2623
2622 void LayerTreeHostCommon::CalculateDrawProperties( 2624 void LayerTreeHostCommon::CalculateDrawProperties(
2623 CalcDrawPropsMainInputs* inputs) { 2625 CalcDrawPropsMainInputs* inputs) {
(...skipping 15 matching lines...) Expand all
2639 2641
2640 PropertyTrees* GetPropertyTrees(Layer* layer) { 2642 PropertyTrees* GetPropertyTrees(Layer* layer) {
2641 return layer->layer_tree_host()->property_trees(); 2643 return layer->layer_tree_host()->property_trees();
2642 } 2644 }
2643 2645
2644 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { 2646 PropertyTrees* GetPropertyTrees(LayerImpl* layer) {
2645 return layer->layer_tree_impl()->property_trees(); 2647 return layer->layer_tree_impl()->property_trees();
2646 } 2648 }
2647 2649
2648 } // namespace cc 2650 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_layer_tree_host_impl.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