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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 clip_parent = layer->clip_parent(); | 179 clip_parent = layer->clip_parent(); |
180 | 180 |
181 if (!clip_parent || clip_parent == layer->parent()) | 181 if (!clip_parent || clip_parent == layer->parent()) |
182 return; | 182 return; |
183 | 183 |
184 // The root layer is never a clip child. | 184 // The root layer is never a clip child. |
185 DCHECK(layer->parent()); | 185 DCHECK(layer->parent()); |
186 | 186 |
187 // Grab the cached values. | 187 // Grab the cached values. |
188 *clip_rect_in_parent_target_space = clip_parent->clip_rect(); | 188 *clip_rect_in_parent_target_space = clip_parent->clip_rect(); |
189 *subtree_should_be_clipped = clip_parent->is_clipped(); | 189 *subtree_should_be_clipped = clip_parent->is_clipped_from_property_tree(); |
190 | 190 |
191 // We may have to project the clip rect into our parent's target space. Note, | 191 // We may have to project the clip rect into our parent's target space. Note, |
192 // it must be our parent's target space, not ours. For one, we haven't | 192 // it must be our parent's target space, not ours. For one, we haven't |
193 // computed our transforms, so we couldn't put it in our space yet even if we | 193 // computed our transforms, so we couldn't put it in our space yet even if we |
194 // wanted to. But more importantly, this matches the expectations of | 194 // wanted to. But more importantly, this matches the expectations of |
195 // CalculateDrawPropertiesInternal. If we, say, create a render surface, these | 195 // CalculateDrawPropertiesInternal. If we, say, create a render surface, these |
196 // clip rects will want to be in its target space, not ours. | 196 // clip rects will want to be in its target space, not ours. |
197 if (clip_parent == layer->clip_parent()) { | 197 if (clip_parent == layer->clip_parent()) { |
198 *clip_rect_in_parent_target_space = TranslateRectToTargetSpace<LayerType>( | 198 *clip_rect_in_parent_target_space = TranslateRectToTargetSpace<LayerType>( |
199 *clip_parent, *layer->parent(), *clip_rect_in_parent_target_space, | 199 *clip_parent, *layer->parent(), *clip_rect_in_parent_target_space, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
254 | 254 |
255 // If the layer owns a surface, then the content rect is in the wrong space. | 255 // If the layer owns a surface, then the content rect is in the wrong space. |
256 // Instead, we will use the surface's DrawableContentRect which is in target | 256 // Instead, we will use the surface's DrawableContentRect which is in target |
257 // space as required. | 257 // space as required. |
258 gfx::Rect target_rect = drawable_content_rect; | 258 gfx::Rect target_rect = drawable_content_rect; |
259 if (layer->render_surface()) { | 259 if (layer->render_surface()) { |
260 target_rect = | 260 target_rect = |
261 gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect()); | 261 gfx::ToEnclosedRect(layer->render_surface()->DrawableContentRect()); |
262 } | 262 } |
263 | 263 |
264 if (render_target->is_clipped()) { | 264 if (render_target->is_clipped_from_property_tree()) { |
265 gfx::Rect clip_rect = render_target->clip_rect(); | 265 gfx::Rect clip_rect = render_target->clip_rect(); |
266 // If the layer has a clip parent, the clip rect may be in the wrong space, | 266 // If the layer has a clip parent, the clip rect may be in the wrong space, |
267 // so we'll need to transform it before it is applied. | 267 // so we'll need to transform it before it is applied. |
268 if (layer->clip_parent()) { | 268 if (layer->clip_parent()) { |
269 clip_rect = TranslateRectToTargetSpace<LayerType>( | 269 clip_rect = TranslateRectToTargetSpace<LayerType>( |
270 *layer->clip_parent(), *layer, clip_rect, | 270 *layer->clip_parent(), *layer, clip_rect, |
271 TRANSLATE_RECT_DIRECTION_TO_DESCENDANT); | 271 TRANSLATE_RECT_DIRECTION_TO_DESCENDANT); |
272 } | 272 } |
273 target_rect.Intersect(clip_rect); | 273 target_rect.Intersect(clip_rect); |
274 } | 274 } |
(...skipping 1779 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 CHECK_EQ(layer_or_ancestor_clips_descendants, |
2065 layer->is_clipped_from_property_tree()); | |
2065 if (layer_or_ancestor_clips_descendants) { | 2066 if (layer_or_ancestor_clips_descendants) { |
2066 layer_draw_properties.clip_rect = clip_rect_in_target_space; | 2067 layer_draw_properties.clip_rect = clip_rect_in_target_space; |
2067 } else { | 2068 } else { |
2068 // Initialize the clip rect to a safe value that will not clip the | 2069 // Initialize the clip rect to a safe value that will not clip the |
2069 // layer, just in case clipping is still accidentally used. | 2070 // layer, just in case clipping is still accidentally used. |
2070 layer_draw_properties.clip_rect = rect_in_target_space; | 2071 layer_draw_properties.clip_rect = rect_in_target_space; |
2071 } | 2072 } |
2072 | 2073 |
2073 typename LayerType::LayerListType& descendants = | 2074 typename LayerType::LayerListType& descendants = |
2074 (render_to_separate_surface ? layer->render_surface()->layer_list() | 2075 (render_to_separate_surface ? layer->render_surface()->layer_list() |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2494 << DrawTransformFromPropertyTrees( | 2495 << DrawTransformFromPropertyTrees( |
2495 current_layer, property_trees->transform_tree).ToString(); | 2496 current_layer, property_trees->transform_tree).ToString(); |
2496 | 2497 |
2497 const bool draw_opacities_match = | 2498 const bool draw_opacities_match = |
2498 current_layer->draw_opacity() == | 2499 current_layer->draw_opacity() == |
2499 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); | 2500 DrawOpacityFromPropertyTrees(current_layer, property_trees->opacity_tree); |
2500 CHECK(draw_opacities_match) | 2501 CHECK(draw_opacities_match) |
2501 << "expected: " << current_layer->draw_opacity() | 2502 << "expected: " << current_layer->draw_opacity() |
2502 << " actual: " << DrawOpacityFromPropertyTrees( | 2503 << " actual: " << DrawOpacityFromPropertyTrees( |
2503 current_layer, property_trees->opacity_tree); | 2504 current_layer, property_trees->opacity_tree); |
2505 | |
Ian Vollick
2015/07/09 14:26:27
nit: spurious ws.
jaydasika
2015/07/09 15:11:49
Done.
| |
2504 const bool can_use_lcd_text_match = | 2506 const bool can_use_lcd_text_match = |
2505 CanUseLcdTextFromPropertyTrees( | 2507 CanUseLcdTextFromPropertyTrees( |
2506 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, | 2508 current_layer, layers_always_allowed_lcd_text, can_use_lcd_text, |
2507 property_trees) == current_layer->can_use_lcd_text(); | 2509 property_trees) == current_layer->can_use_lcd_text(); |
2508 CHECK(can_use_lcd_text_match); | 2510 CHECK(can_use_lcd_text_match); |
2509 } | 2511 } |
2510 | 2512 |
2511 void VerifyPropertyTreeValues( | 2513 void VerifyPropertyTreeValues( |
2512 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { | 2514 LayerTreeHostCommon::CalcDrawPropsMainInputs* inputs) { |
2513 } | 2515 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2546 PreCalculateMetaInformationRecursiveData recursive_data; | 2548 PreCalculateMetaInformationRecursiveData recursive_data; |
2547 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); | 2549 PreCalculateMetaInformationInternal(inputs->root_layer, &recursive_data); |
2548 | 2550 |
2549 const bool should_measure_property_tree_performance = | 2551 const bool should_measure_property_tree_performance = |
2550 inputs->verify_property_trees && | 2552 inputs->verify_property_trees && |
2551 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); | 2553 (property_tree_option == BUILD_PROPERTY_TREES_IF_NEEDED); |
2552 | 2554 |
2553 if (should_measure_property_tree_performance) { | 2555 if (should_measure_property_tree_performance) { |
2554 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2556 TRACE_EVENT_BEGIN0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2555 "LayerTreeHostCommon::CalculateDrawProperties"); | 2557 "LayerTreeHostCommon::CalculateDrawProperties"); |
2556 } | 2558 } |
Ian Vollick
2015/07/09 14:26:27
This TRACE_EVENT_BEGIN0 and TRACE_EVENT_END0 here
jaydasika
2015/07/09 15:11:49
Done.
| |
2557 | 2559 |
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) { | 2560 if (should_measure_property_tree_performance) { |
2565 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2561 TRACE_EVENT_END0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2566 "LayerTreeHostCommon::CalculateDrawProperties"); | 2562 "LayerTreeHostCommon::CalculateDrawProperties"); |
2567 } | 2563 } |
2568 | 2564 |
2569 if (inputs->verify_property_trees) { | 2565 if (inputs->verify_property_trees) { |
2570 typename LayerType::LayerListType update_layer_list; | 2566 typename LayerType::LayerListType update_layer_list; |
2571 | 2567 |
2572 // For testing purposes, sometimes property trees need to be built on the | 2568 // 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, | 2569 // compositor thread, so this can't just switch on Layer vs LayerImpl, |
(...skipping 27 matching lines...) Expand all Loading... | |
2601 } | 2597 } |
2602 case DONT_BUILD_PROPERTY_TREES: { | 2598 case DONT_BUILD_PROPERTY_TREES: { |
2603 TRACE_EVENT0( | 2599 TRACE_EVENT0( |
2604 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 2600 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
2605 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); | 2601 "LayerTreeHostCommon::ComputeJustVisibleRectsWithPropertyTrees"); |
2606 ComputeVisibleRectsUsingPropertyTrees( | 2602 ComputeVisibleRectsUsingPropertyTrees( |
2607 inputs->root_layer, inputs->property_trees, &update_layer_list); | 2603 inputs->root_layer, inputs->property_trees, &update_layer_list); |
2608 break; | 2604 break; |
2609 } | 2605 } |
2610 } | 2606 } |
2607 } | |
2611 | 2608 |
2609 std::vector<AccumulatedSurfaceState<LayerType>> accumulated_surface_state; | |
2610 CalculateDrawPropertiesInternal<LayerType>( | |
2611 inputs->root_layer, globals, data_for_recursion, | |
2612 inputs->render_surface_layer_list, &dummy_layer_list, | |
2613 &accumulated_surface_state, inputs->current_render_surface_layer_list_id); | |
2614 | |
2615 if (inputs->verify_property_trees) | |
2612 VerifyPropertyTreeValues(inputs); | 2616 VerifyPropertyTreeValues(inputs); |
2613 } | |
2614 | 2617 |
2615 // The dummy layer list should not have been used. | 2618 // The dummy layer list should not have been used. |
2616 DCHECK_EQ(0u, dummy_layer_list.size()); | 2619 DCHECK_EQ(0u, dummy_layer_list.size()); |
2617 // A root layer render_surface should always exist after | 2620 // A root layer render_surface should always exist after |
2618 // CalculateDrawProperties. | 2621 // CalculateDrawProperties. |
2619 DCHECK(inputs->root_layer->render_surface()); | 2622 DCHECK(inputs->root_layer->render_surface()); |
2620 } | 2623 } |
2621 | 2624 |
2622 void LayerTreeHostCommon::CalculateDrawProperties( | 2625 void LayerTreeHostCommon::CalculateDrawProperties( |
2623 CalcDrawPropsMainInputs* inputs) { | 2626 CalcDrawPropsMainInputs* inputs) { |
(...skipping 15 matching lines...) Expand all Loading... | |
2639 | 2642 |
2640 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2643 PropertyTrees* GetPropertyTrees(Layer* layer) { |
2641 return layer->layer_tree_host()->property_trees(); | 2644 return layer->layer_tree_host()->property_trees(); |
2642 } | 2645 } |
2643 | 2646 |
2644 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2647 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
2645 return layer->layer_tree_impl()->property_trees(); | 2648 return layer->layer_tree_impl()->property_trees(); |
2646 } | 2649 } |
2647 | 2650 |
2648 } // namespace cc | 2651 } // namespace cc |
OLD | NEW |