| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/layer_tree_host_common_test.h" | 5 #include "cc/test/layer_tree_host_common_test.h" |
| 6 | 6 |
| 7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
| 8 #include "cc/layers/layer_impl.h" | 8 #include "cc/layers/layer_impl.h" |
| 9 #include "cc/test/fake_layer_tree_host.h" | 9 #include "cc/test/fake_layer_tree_host.h" |
| 10 #include "cc/trees/draw_property_utils.h" | 10 #include "cc/trees/draw_property_utils.h" |
| 11 #include "cc/trees/layer_tree_host_common.h" | 11 #include "cc/trees/layer_tree_host_common.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 |
| 14 LayerTreeHostCommonTestBase::LayerTreeHostCommonTestBase( | 15 LayerTreeHostCommonTestBase::LayerTreeHostCommonTestBase( |
| 15 const LayerTreeSettings& settings) | 16 const LayerTreeSettings& settings) |
| 16 : LayerTestCommon::LayerImplTest(settings), | 17 : LayerTestCommon::LayerImplTest(settings), |
| 17 render_surface_layer_list_count_(0) { | 18 render_surface_layer_list_count_(0) { |
| 18 } | 19 } |
| 19 | 20 |
| 20 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() { | 21 LayerTreeHostCommonTestBase::~LayerTreeHostCommonTestBase() { |
| 21 } | 22 } |
| 22 | 23 |
| 23 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( | 24 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( |
| 24 Layer* layer, | 25 Layer* layer, |
| 25 const gfx::Transform& transform, | 26 const gfx::Transform& transform, |
| 26 const gfx::Point3F& transform_origin, | 27 const gfx::Point3F& transform_origin, |
| 27 const gfx::PointF& position, | 28 const gfx::PointF& position, |
| 28 const gfx::Size& bounds, | 29 const gfx::Size& bounds, |
| 29 bool flatten_transform, | 30 bool flatten_transform, |
| 30 bool is_3d_sorted) { | 31 bool is_3d_sorted) { |
| 31 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, | 32 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, |
| 32 position, bounds, flatten_transform, | 33 position, bounds, flatten_transform, |
| 33 is_3d_sorted); | 34 is_3d_sorted); |
| 34 } | 35 } |
| 35 | 36 |
| 36 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( | 37 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( |
| 37 LayerImpl* layer, | 38 LayerImpl* layer, |
| 38 const gfx::Transform& transform, | 39 const gfx::Transform& transform, |
| 39 const gfx::Point3F& transform_origin, | 40 const gfx::Point3F& transform_origin, |
| 40 const gfx::PointF& position, | 41 const gfx::PointF& position, |
| 41 const gfx::Size& bounds, | 42 const gfx::Size& bounds, |
| 42 bool flatten_transform, | 43 bool flatten_transform, |
| 43 bool is_3d_sorted) { | |
| 44 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, | |
| 45 position, bounds, flatten_transform, | |
| 46 is_3d_sorted); | |
| 47 } | |
| 48 | |
| 49 void LayerTreeHostCommonTestBase::SetLayerPropertiesForTesting( | |
| 50 LayerImpl* layer, | |
| 51 const gfx::Transform& transform, | |
| 52 const gfx::Point3F& transform_origin, | |
| 53 const gfx::PointF& position, | |
| 54 const gfx::Size& bounds, | |
| 55 bool flatten_transform, | |
| 56 bool is_3d_sorted, | 44 bool is_3d_sorted, |
| 57 bool create_render_surface) { | 45 bool create_render_surface) { |
| 58 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, | 46 SetLayerPropertiesForTestingInternal(layer, transform, transform_origin, |
| 59 position, bounds, flatten_transform, | 47 position, bounds, flatten_transform, |
| 60 is_3d_sorted); | 48 is_3d_sorted); |
| 61 if (create_render_surface) { | 49 if (create_render_surface) { |
| 62 layer->SetForceRenderSurface(true); | 50 layer->SetHasRenderSurface(true); |
| 63 } | 51 } |
| 64 } | 52 } |
| 65 | 53 |
| 66 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( | 54 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( |
| 67 Layer* root_layer, | 55 Layer* root_layer, |
| 68 float device_scale_factor, | 56 float device_scale_factor, |
| 69 float page_scale_factor, | 57 float page_scale_factor, |
| 70 Layer* page_scale_layer, | 58 Layer* page_scale_layer, |
| 71 bool can_use_lcd_text, | 59 bool can_use_lcd_text, |
| 72 bool layers_always_allowed_lcd_text) { | 60 bool layers_always_allowed_lcd_text) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 88 inputs.page_scale_layer = page_scale_layer; | 76 inputs.page_scale_layer = page_scale_layer; |
| 89 LayerTreeHostCommon::CalculateDrawProperties(&inputs); | 77 LayerTreeHostCommon::CalculateDrawProperties(&inputs); |
| 90 } | 78 } |
| 91 | 79 |
| 92 void LayerTreeHostCommonTestBase:: | 80 void LayerTreeHostCommonTestBase:: |
| 93 ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) { | 81 ExecuteCalculateDrawPropertiesWithPropertyTrees(Layer* root_layer) { |
| 94 DCHECK(root_layer->layer_tree_host()); | 82 DCHECK(root_layer->layer_tree_host()); |
| 95 LayerTreeHostCommon::PreCalculateMetaInformation(root_layer); | 83 LayerTreeHostCommon::PreCalculateMetaInformation(root_layer); |
| 96 | 84 |
| 97 gfx::Transform identity_transform; | 85 gfx::Transform identity_transform; |
| 98 | 86 bool preserves_2d_axis_alignment = false; |
| 99 bool can_render_to_separate_surface = true; | 87 bool can_render_to_separate_surface = true; |
| 88 LayerTreeHostCommon::UpdateRenderSurfaces( |
| 89 root_layer, can_render_to_separate_surface, identity_transform, |
| 90 preserves_2d_axis_alignment); |
| 100 | 91 |
| 101 Layer* page_scale_layer = nullptr; | 92 Layer* page_scale_layer = nullptr; |
| 102 Layer* inner_viewport_scroll_layer = | 93 Layer* inner_viewport_scroll_layer = |
| 103 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); | 94 root_layer->layer_tree_host()->inner_viewport_scroll_layer(); |
| 104 Layer* outer_viewport_scroll_layer = | 95 Layer* outer_viewport_scroll_layer = |
| 105 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); | 96 root_layer->layer_tree_host()->outer_viewport_scroll_layer(); |
| 106 const Layer* overscroll_elasticity_layer = | 97 const Layer* overscroll_elasticity_layer = |
| 107 root_layer->layer_tree_host()->overscroll_elasticity_layer(); | 98 root_layer->layer_tree_host()->overscroll_elasticity_layer(); |
| 108 gfx::Vector2dF elastic_overscroll = | 99 gfx::Vector2dF elastic_overscroll = |
| 109 root_layer->layer_tree_host()->elastic_overscroll(); | 100 root_layer->layer_tree_host()->elastic_overscroll(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 120 can_render_to_separate_surface, | 111 can_render_to_separate_surface, |
| 121 root_layer->layer_tree_host()->property_trees(), &update_layer_list_); | 112 root_layer->layer_tree_host()->property_trees(), &update_layer_list_); |
| 122 } | 113 } |
| 123 | 114 |
| 124 void LayerTreeHostCommonTestBase:: | 115 void LayerTreeHostCommonTestBase:: |
| 125 ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) { | 116 ExecuteCalculateDrawPropertiesWithPropertyTrees(LayerImpl* root_layer) { |
| 126 DCHECK(root_layer->layer_tree_impl()); | 117 DCHECK(root_layer->layer_tree_impl()); |
| 127 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer); | 118 LayerTreeHostCommon::PreCalculateMetaInformationForTesting(root_layer); |
| 128 | 119 |
| 129 gfx::Transform identity_transform; | 120 gfx::Transform identity_transform; |
| 130 | |
| 131 bool can_render_to_separate_surface = true; | 121 bool can_render_to_separate_surface = true; |
| 132 | |
| 133 LayerImpl* page_scale_layer = nullptr; | 122 LayerImpl* page_scale_layer = nullptr; |
| 134 LayerImpl* inner_viewport_scroll_layer = | 123 LayerImpl* inner_viewport_scroll_layer = |
| 135 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); | 124 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); |
| 136 LayerImpl* outer_viewport_scroll_layer = | 125 LayerImpl* outer_viewport_scroll_layer = |
| 137 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); | 126 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); |
| 138 LayerImpl* overscroll_elasticity_layer = | 127 LayerImpl* overscroll_elasticity_layer = |
| 139 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); | 128 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); |
| 140 gfx::Vector2dF elastic_overscroll = | 129 gfx::Vector2dF elastic_overscroll = |
| 141 root_layer->layer_tree_impl()->elastic_overscroll()->Current( | 130 root_layer->layer_tree_impl()->elastic_overscroll()->Current( |
| 142 root_layer->layer_tree_impl()->IsActiveTree()); | 131 root_layer->layer_tree_impl()->IsActiveTree()); |
| 143 float page_scale_factor = 1.f; | 132 float page_scale_factor = 1.f; |
| 144 float device_scale_factor = 1.f; | 133 float device_scale_factor = 1.f; |
| 145 gfx::Size device_viewport_size = | 134 gfx::Size device_viewport_size = |
| 146 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 135 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
| 147 root_layer->bounds().height() * device_scale_factor); | 136 root_layer->bounds().height() * device_scale_factor); |
| 148 update_layer_list_impl_.reset(new LayerImplList); | 137 std::vector<LayerImpl*> update_layer_list; |
| 149 BuildPropertyTreesAndComputeVisibleRects( | 138 BuildPropertyTreesAndComputeVisibleRects( |
| 150 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 139 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
| 151 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 140 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
| 152 elastic_overscroll, page_scale_factor, device_scale_factor, | 141 elastic_overscroll, page_scale_factor, device_scale_factor, |
| 153 gfx::Rect(device_viewport_size), identity_transform, | 142 gfx::Rect(device_viewport_size), identity_transform, |
| 154 can_render_to_separate_surface, | 143 can_render_to_separate_surface, |
| 155 root_layer->layer_tree_impl()->property_trees(), | 144 root_layer->layer_tree_impl()->property_trees(), &update_layer_list); |
| 156 update_layer_list_impl_.get()); | |
| 157 } | 145 } |
| 158 | 146 |
| 159 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( | 147 void LayerTreeHostCommonTestBase::ExecuteCalculateDrawProperties( |
| 160 LayerImpl* root_layer, | 148 LayerImpl* root_layer, |
| 161 float device_scale_factor, | 149 float device_scale_factor, |
| 162 float page_scale_factor, | 150 float page_scale_factor, |
| 163 LayerImpl* page_scale_layer, | 151 LayerImpl* page_scale_layer, |
| 164 bool can_use_lcd_text, | 152 bool can_use_lcd_text, |
| 165 bool layers_always_allowed_lcd_text) { | 153 bool layers_always_allowed_lcd_text) { |
| 166 host_impl()->active_tree()->SetDeviceScaleFactor(device_scale_factor); | 154 host_impl()->active_tree()->SetDeviceScaleFactor(device_scale_factor); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 LayerTreeHostCommonTest::LayerTreeHostCommonTest() | 214 LayerTreeHostCommonTest::LayerTreeHostCommonTest() |
| 227 : LayerTreeHostCommonTestBase(LayerTreeSettings()) { | 215 : LayerTreeHostCommonTestBase(LayerTreeSettings()) { |
| 228 } | 216 } |
| 229 | 217 |
| 230 LayerTreeHostCommonTest::LayerTreeHostCommonTest( | 218 LayerTreeHostCommonTest::LayerTreeHostCommonTest( |
| 231 const LayerTreeSettings& settings) | 219 const LayerTreeSettings& settings) |
| 232 : LayerTreeHostCommonTestBase(settings) { | 220 : LayerTreeHostCommonTestBase(settings) { |
| 233 } | 221 } |
| 234 | 222 |
| 235 } // namespace cc | 223 } // namespace cc |
| OLD | NEW |