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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 use_property_trees(use_property_trees), | 103 use_property_trees(use_property_trees), |
104 render_surface_layer_list(render_surface_layer_list), | 104 render_surface_layer_list(render_surface_layer_list), |
105 current_render_surface_layer_list_id( | 105 current_render_surface_layer_list_id( |
106 current_render_surface_layer_list_id), | 106 current_render_surface_layer_list_id), |
107 property_trees(property_trees) {} | 107 property_trees(property_trees) {} |
108 | 108 |
109 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting:: | 109 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting:: |
110 CalcDrawPropsImplInputsForTesting(LayerImpl* root_layer, | 110 CalcDrawPropsImplInputsForTesting(LayerImpl* root_layer, |
111 const gfx::Size& device_viewport_size, | 111 const gfx::Size& device_viewport_size, |
112 const gfx::Transform& device_transform, | 112 const gfx::Transform& device_transform, |
113 LayerImplList* render_surface_layer_list) | 113 LayerImplList* render_surface_layer_list, |
| 114 int current_render_surface_layer_list_id) |
114 : CalcDrawPropsImplInputs(root_layer, | 115 : CalcDrawPropsImplInputs(root_layer, |
115 device_viewport_size, | 116 device_viewport_size, |
116 device_transform, | 117 device_transform, |
117 1.f, | 118 1.f, |
118 1.f, | 119 1.f, |
119 NULL, | 120 NULL, |
120 NULL, | 121 NULL, |
121 NULL, | 122 NULL, |
122 gfx::Vector2dF(), | 123 gfx::Vector2dF(), |
123 NULL, | 124 NULL, |
124 std::numeric_limits<int>::max() / 2, | 125 std::numeric_limits<int>::max() / 2, |
125 false, | 126 false, |
126 false, | 127 false, |
127 true, | 128 true, |
128 false, | 129 false, |
129 true, | 130 true, |
130 false, | 131 false, |
131 render_surface_layer_list, | 132 render_surface_layer_list, |
132 0, | 133 current_render_surface_layer_list_id, |
133 GetPropertyTrees(root_layer)) { | 134 GetPropertyTrees(root_layer)) { |
134 DCHECK(root_layer); | 135 DCHECK(root_layer); |
135 DCHECK(render_surface_layer_list); | 136 DCHECK(render_surface_layer_list); |
136 } | 137 } |
137 | 138 |
138 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting:: | 139 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting:: |
139 CalcDrawPropsImplInputsForTesting(LayerImpl* root_layer, | 140 CalcDrawPropsImplInputsForTesting(LayerImpl* root_layer, |
140 const gfx::Size& device_viewport_size, | 141 const gfx::Size& device_viewport_size, |
141 LayerImplList* render_surface_layer_list) | 142 LayerImplList* render_surface_layer_list, |
| 143 int current_render_surface_layer_list_id) |
142 : CalcDrawPropsImplInputsForTesting(root_layer, | 144 : CalcDrawPropsImplInputsForTesting(root_layer, |
143 device_viewport_size, | 145 device_viewport_size, |
144 gfx::Transform(), | 146 gfx::Transform(), |
145 render_surface_layer_list) {} | 147 render_surface_layer_list, |
| 148 current_render_surface_layer_list_id) {} |
146 | 149 |
147 ScrollAndScaleSet::ScrollAndScaleSet() | 150 ScrollAndScaleSet::ScrollAndScaleSet() |
148 : page_scale_delta(1.f), top_controls_delta(0.f) { | 151 : page_scale_delta(1.f), top_controls_delta(0.f) { |
149 } | 152 } |
150 | 153 |
151 ScrollAndScaleSet::~ScrollAndScaleSet() {} | 154 ScrollAndScaleSet::~ScrollAndScaleSet() {} |
152 | 155 |
153 static gfx::Vector2dF GetEffectiveScrollDelta(LayerImpl* layer) { | 156 static gfx::Vector2dF GetEffectiveScrollDelta(LayerImpl* layer) { |
154 // Layer's scroll offset can have an integer part and fractional part. | 157 // Layer's scroll offset can have an integer part and fractional part. |
155 // Due to Blink's limitation, it only counter-scrolls the position-fixed | 158 // Due to Blink's limitation, it only counter-scrolls the position-fixed |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 // The current W3C spec on CSS transforms says that backface visibility should | 454 // The current W3C spec on CSS transforms says that backface visibility should |
452 // be determined differently depending on whether the layer is in a "3d | 455 // be determined differently depending on whether the layer is in a "3d |
453 // rendering context" or not. For Chromium code, we can determine whether we | 456 // rendering context" or not. For Chromium code, we can determine whether we |
454 // are in a 3d rendering context by checking if the parent preserves 3d. | 457 // are in a 3d rendering context by checking if the parent preserves 3d. |
455 | 458 |
456 if (LayerIsInExisting3DRenderingContext(layer)) { | 459 if (LayerIsInExisting3DRenderingContext(layer)) { |
457 if (use_property_trees) { | 460 if (use_property_trees) { |
458 return DrawTransformFromPropertyTrees(layer, transform_tree) | 461 return DrawTransformFromPropertyTrees(layer, transform_tree) |
459 .IsBackFaceVisible(); | 462 .IsBackFaceVisible(); |
460 } else { | 463 } else { |
461 return layer->draw_transform().IsBackFaceVisible(); | 464 return layer->draw_properties() |
| 465 .target_space_transform.IsBackFaceVisible(); |
462 } | 466 } |
463 } | 467 } |
464 | 468 |
465 // In this case, either the layer establishes a new 3d rendering context, or | 469 // In this case, either the layer establishes a new 3d rendering context, or |
466 // is not in a 3d rendering context at all. | 470 // is not in a 3d rendering context at all. |
467 return layer->transform().IsBackFaceVisible(); | 471 return layer->transform().IsBackFaceVisible(); |
468 } | 472 } |
469 | 473 |
470 static bool IsSurfaceBackFaceVisible(LayerImpl* layer, | 474 static bool IsSurfaceBackFaceVisible(LayerImpl* layer, |
471 const gfx::Transform& draw_transform) { | 475 const gfx::Transform& draw_transform) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 // layer. | 521 // layer. |
518 visible_rect_in_target_surface_space.Intersect( | 522 visible_rect_in_target_surface_space.Intersect( |
519 clip_rect_of_target_surface_in_target_space); | 523 clip_rect_of_target_surface_in_target_space); |
520 } | 524 } |
521 | 525 |
522 if (visible_rect_in_target_surface_space.IsEmpty()) | 526 if (visible_rect_in_target_surface_space.IsEmpty()) |
523 return gfx::Rect(); | 527 return gfx::Rect(); |
524 | 528 |
525 return CalculateVisibleRectWithCachedLayerRect( | 529 return CalculateVisibleRectWithCachedLayerRect( |
526 visible_rect_in_target_surface_space, gfx::Rect(layer->bounds()), | 530 visible_rect_in_target_surface_space, gfx::Rect(layer->bounds()), |
527 layer_rect_in_target_space, layer->draw_transform()); | 531 layer_rect_in_target_space, |
| 532 layer->draw_properties().target_space_transform); |
528 } | 533 } |
529 | 534 |
530 static bool LayerShouldBeSkipped(LayerImpl* layer, | 535 static bool LayerShouldBeSkipped(LayerImpl* layer, |
531 bool layer_is_drawn, | 536 bool layer_is_drawn, |
532 bool use_property_trees, | 537 bool use_property_trees, |
533 const TransformTree& transform_tree) { | 538 const TransformTree& transform_tree) { |
534 // Layers can be skipped if any of these conditions are met. | 539 // Layers can be skipped if any of these conditions are met. |
535 // - is not drawn due to it or one of its ancestors being hidden (or having | 540 // - is not drawn due to it or one of its ancestors being hidden (or having |
536 // no copy requests). | 541 // no copy requests). |
537 // - does not draw content. | 542 // - does not draw content. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 current_target_surface && | 785 current_target_surface && |
781 current_target_surface != container_target_surface; | 786 current_target_surface != container_target_surface; |
782 current_target_surface = NextTargetSurface(current_target_surface)) { | 787 current_target_surface = NextTargetSurface(current_target_surface)) { |
783 // Note: Concat is used here to convert the result coordinate space from | 788 // Note: Concat is used here to convert the result coordinate space from |
784 // current render surface to the next render surface. | 789 // current render surface to the next render surface. |
785 target_surface_space_to_container_layer_space.ConcatTransform( | 790 target_surface_space_to_container_layer_space.ConcatTransform( |
786 current_target_surface->render_surface()->draw_transform()); | 791 current_target_surface->render_surface()->draw_transform()); |
787 } | 792 } |
788 // Calculate step 1b | 793 // Calculate step 1b |
789 gfx::Transform container_layer_space_to_container_target_surface_space = | 794 gfx::Transform container_layer_space_to_container_target_surface_space = |
790 container->draw_transform(); | 795 container->draw_properties().target_space_transform; |
791 gfx::Transform container_target_surface_space_to_container_layer_space; | 796 gfx::Transform container_target_surface_space_to_container_layer_space; |
792 if (container_layer_space_to_container_target_surface_space.GetInverse( | 797 if (container_layer_space_to_container_target_surface_space.GetInverse( |
793 &container_target_surface_space_to_container_layer_space)) { | 798 &container_target_surface_space_to_container_layer_space)) { |
794 // Note: Again, Concat is used to conver the result coordinate space from | 799 // Note: Again, Concat is used to conver the result coordinate space from |
795 // the container render surface to the container layer. | 800 // the container render surface to the container layer. |
796 target_surface_space_to_container_layer_space.ConcatTransform( | 801 target_surface_space_to_container_layer_space.ConcatTransform( |
797 container_target_surface_space_to_container_layer_space); | 802 container_target_surface_space_to_container_layer_space); |
798 } | 803 } |
799 | 804 |
800 // Apply step 3 | 805 // Apply step 3 |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1945 // clipping goes on between layers here. | 1950 // clipping goes on between layers here. |
1946 clip_rect_of_target_surface_in_target_space = | 1951 clip_rect_of_target_surface_in_target_space = |
1947 data_from_ancestor.clip_rect_of_target_surface_in_target_space; | 1952 data_from_ancestor.clip_rect_of_target_surface_in_target_space; |
1948 } | 1953 } |
1949 | 1954 |
1950 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; | 1955 layer_draw_properties.can_use_lcd_text = layer_can_use_lcd_text; |
1951 | 1956 |
1952 // The layer bounds() includes the layer's bounds_delta() which we want | 1957 // The layer bounds() includes the layer's bounds_delta() which we want |
1953 // for the clip rect. | 1958 // for the clip rect. |
1954 gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( | 1959 gfx::Rect rect_in_target_space = MathUtil::MapEnclosingClippedRect( |
1955 layer->draw_transform(), gfx::Rect(layer->bounds())); | 1960 layer->draw_properties().target_space_transform, |
| 1961 gfx::Rect(layer->bounds())); |
1956 | 1962 |
1957 if (LayerClipsSubtree(layer)) { | 1963 if (LayerClipsSubtree(layer)) { |
1958 layer_or_ancestor_clips_descendants = true; | 1964 layer_or_ancestor_clips_descendants = true; |
1959 if (ancestor_clips_subtree && !render_to_separate_surface) { | 1965 if (ancestor_clips_subtree && !render_to_separate_surface) { |
1960 // A layer without render surface shares the same target as its ancestor. | 1966 // A layer without render surface shares the same target as its ancestor. |
1961 clip_rect_in_target_space = | 1967 clip_rect_in_target_space = |
1962 ancestor_clip_rect_in_target_space; | 1968 ancestor_clip_rect_in_target_space; |
1963 clip_rect_in_target_space.Intersect(rect_in_target_space); | 1969 clip_rect_in_target_space.Intersect(rect_in_target_space); |
1964 } else { | 1970 } else { |
1965 clip_rect_in_target_space = rect_in_target_space; | 1971 clip_rect_in_target_space = rect_in_target_space; |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2346 current_layer, property_trees, layers_always_allowed_lcd_text, | 2352 current_layer, property_trees, layers_always_allowed_lcd_text, |
2347 can_use_lcd_text, &draw_properties); | 2353 can_use_lcd_text, &draw_properties); |
2348 | 2354 |
2349 const bool visible_rects_match = ApproximatelyEqual( | 2355 const bool visible_rects_match = ApproximatelyEqual( |
2350 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); | 2356 current_layer->visible_layer_rect(), draw_properties.visible_layer_rect); |
2351 CHECK(visible_rects_match) | 2357 CHECK(visible_rects_match) |
2352 << "expected: " << current_layer->visible_layer_rect().ToString() | 2358 << "expected: " << current_layer->visible_layer_rect().ToString() |
2353 << " actual: " << draw_properties.visible_layer_rect.ToString(); | 2359 << " actual: " << draw_properties.visible_layer_rect.ToString(); |
2354 | 2360 |
2355 const bool draw_transforms_match = ApproximatelyEqual( | 2361 const bool draw_transforms_match = ApproximatelyEqual( |
2356 current_layer->draw_transform(), draw_properties.target_space_transform); | 2362 current_layer->draw_properties().target_space_transform, |
| 2363 draw_properties.target_space_transform); |
2357 CHECK(draw_transforms_match) | 2364 CHECK(draw_transforms_match) |
2358 << "expected: " << current_layer->draw_transform().ToString() | 2365 << "expected: " |
| 2366 << current_layer->draw_properties().target_space_transform.ToString() |
2359 << " actual: " << draw_properties.target_space_transform.ToString(); | 2367 << " actual: " << draw_properties.target_space_transform.ToString(); |
2360 | 2368 |
2361 CHECK_EQ(current_layer->draw_opacity(), draw_properties.opacity); | 2369 CHECK_EQ(current_layer->draw_opacity(), draw_properties.opacity); |
2362 CHECK_EQ(current_layer->can_use_lcd_text(), draw_properties.can_use_lcd_text); | 2370 CHECK_EQ(current_layer->can_use_lcd_text(), draw_properties.can_use_lcd_text); |
2363 CHECK_EQ(current_layer->is_clipped(), draw_properties.is_clipped); | 2371 CHECK_EQ(current_layer->is_clipped(), draw_properties.is_clipped); |
2364 CHECK_EQ(current_layer->screen_space_transform_is_animating(), | 2372 CHECK_EQ(current_layer->screen_space_transform_is_animating(), |
2365 draw_properties.screen_space_transform_is_animating); | 2373 draw_properties.screen_space_transform_is_animating); |
2366 | 2374 |
2367 const bool drawable_content_rects_match = | 2375 const bool drawable_content_rects_match = |
2368 ApproximatelyEqual(current_layer->drawable_content_rect(), | 2376 ApproximatelyEqual(current_layer->drawable_content_rect(), |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2698 | 2706 |
2699 void CalculateRenderTarget( | 2707 void CalculateRenderTarget( |
2700 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { | 2708 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { |
2701 CalculateRenderTargetInternal(inputs->root_layer, true, | 2709 CalculateRenderTargetInternal(inputs->root_layer, true, |
2702 inputs->can_render_to_separate_surface); | 2710 inputs->can_render_to_separate_surface); |
2703 } | 2711 } |
2704 | 2712 |
2705 void CalculateRenderSurfaceLayerList( | 2713 void CalculateRenderSurfaceLayerList( |
2706 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { | 2714 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs) { |
2707 const bool subtree_visible_from_ancestor = true; | 2715 const bool subtree_visible_from_ancestor = true; |
| 2716 DCHECK_EQ( |
| 2717 inputs->current_render_surface_layer_list_id, |
| 2718 inputs->root_layer->layer_tree_impl()->current_render_surface_list_id()); |
2708 CalculateRenderSurfaceLayerListInternal( | 2719 CalculateRenderSurfaceLayerListInternal( |
2709 inputs->root_layer, inputs->property_trees, | 2720 inputs->root_layer, inputs->property_trees, |
2710 inputs->render_surface_layer_list, nullptr, nullptr, | 2721 inputs->render_surface_layer_list, nullptr, nullptr, |
2711 subtree_visible_from_ancestor, inputs->can_render_to_separate_surface, | 2722 subtree_visible_from_ancestor, inputs->can_render_to_separate_surface, |
2712 inputs->current_render_surface_layer_list_id, inputs->max_texture_size, | 2723 inputs->current_render_surface_layer_list_id, inputs->max_texture_size, |
2713 inputs->verify_property_trees, inputs->use_property_trees); | 2724 inputs->verify_property_trees, inputs->use_property_trees); |
2714 } | 2725 } |
2715 | 2726 |
2716 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer, | 2727 static void ComputeMaskLayerDrawProperties(const LayerImpl* layer, |
2717 LayerImpl* mask_layer) { | 2728 LayerImpl* mask_layer) { |
2718 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties(); | 2729 DrawProperties& mask_layer_draw_properties = mask_layer->draw_properties(); |
2719 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds()); | 2730 mask_layer_draw_properties.visible_layer_rect = gfx::Rect(layer->bounds()); |
2720 mask_layer_draw_properties.target_space_transform = layer->draw_transform(); | 2731 mask_layer_draw_properties.target_space_transform = |
| 2732 layer->draw_properties().target_space_transform; |
2721 mask_layer_draw_properties.maximum_animation_contents_scale = | 2733 mask_layer_draw_properties.maximum_animation_contents_scale = |
2722 layer->draw_properties().maximum_animation_contents_scale; | 2734 layer->draw_properties().maximum_animation_contents_scale; |
2723 mask_layer_draw_properties.starting_animation_contents_scale = | 2735 mask_layer_draw_properties.starting_animation_contents_scale = |
2724 layer->draw_properties().starting_animation_contents_scale; | 2736 layer->draw_properties().starting_animation_contents_scale; |
2725 } | 2737 } |
2726 | 2738 |
2727 void CalculateDrawPropertiesAndVerify( | 2739 void CalculateDrawPropertiesAndVerify( |
2728 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, | 2740 LayerTreeHostCommon::CalcDrawPropsImplInputs* inputs, |
2729 PropertyTreeOption property_tree_option) { | 2741 PropertyTreeOption property_tree_option) { |
2730 inputs->render_surface_layer_list->clear(); | 2742 inputs->render_surface_layer_list->clear(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 | 2885 |
2874 PropertyTrees* GetPropertyTrees(Layer* layer) { | 2886 PropertyTrees* GetPropertyTrees(Layer* layer) { |
2875 return layer->layer_tree_host()->property_trees(); | 2887 return layer->layer_tree_host()->property_trees(); |
2876 } | 2888 } |
2877 | 2889 |
2878 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 2890 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
2879 return layer->layer_tree_impl()->property_trees(); | 2891 return layer->layer_tree_impl()->property_trees(); |
2880 } | 2892 } |
2881 | 2893 |
2882 } // namespace cc | 2894 } // namespace cc |
OLD | NEW |