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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 property_trees, | 211 property_trees, |
212 can_render_to_separate_surface); | 212 can_render_to_separate_surface); |
213 draw_property_utils::FindLayersThatNeedUpdates( | 213 draw_property_utils::FindLayersThatNeedUpdates( |
214 root_layer->layer_tree_host(), property_trees, &update_layer_list_); | 214 root_layer->layer_tree_host(), property_trees, &update_layer_list_); |
215 } | 215 } |
216 | 216 |
217 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( | 217 void ExecuteCalculateDrawPropertiesAndSaveUpdateLayerList( |
218 LayerImpl* root_layer) { | 218 LayerImpl* root_layer) { |
219 DCHECK(root_layer->layer_tree_impl()); | 219 DCHECK(root_layer->layer_tree_impl()); |
220 bool can_render_to_separate_surface = true; | 220 bool can_render_to_separate_surface = true; |
| 221 bool can_adjust_raster_scales = true; |
221 | 222 |
222 const LayerImpl* page_scale_layer = nullptr; | 223 const LayerImpl* page_scale_layer = nullptr; |
223 LayerImpl* inner_viewport_scroll_layer = | 224 LayerImpl* inner_viewport_scroll_layer = |
224 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); | 225 root_layer->layer_tree_impl()->InnerViewportScrollLayer(); |
225 LayerImpl* outer_viewport_scroll_layer = | 226 LayerImpl* outer_viewport_scroll_layer = |
226 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); | 227 root_layer->layer_tree_impl()->OuterViewportScrollLayer(); |
227 const LayerImpl* overscroll_elasticity_layer = | 228 const LayerImpl* overscroll_elasticity_layer = |
228 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); | 229 root_layer->layer_tree_impl()->OverscrollElasticityLayer(); |
229 gfx::Vector2dF elastic_overscroll = | 230 gfx::Vector2dF elastic_overscroll = |
230 root_layer->layer_tree_impl()->elastic_overscroll()->Current( | 231 root_layer->layer_tree_impl()->elastic_overscroll()->Current( |
231 root_layer->layer_tree_impl()->IsActiveTree()); | 232 root_layer->layer_tree_impl()->IsActiveTree()); |
232 float page_scale_factor = 1.f; | 233 float page_scale_factor = 1.f; |
233 float device_scale_factor = 1.f; | 234 float device_scale_factor = 1.f; |
234 gfx::Size device_viewport_size = | 235 gfx::Size device_viewport_size = |
235 gfx::Size(root_layer->bounds().width() * device_scale_factor, | 236 gfx::Size(root_layer->bounds().width() * device_scale_factor, |
236 root_layer->bounds().height() * device_scale_factor); | 237 root_layer->bounds().height() * device_scale_factor); |
237 update_layer_list_impl_.reset(new LayerImplList); | 238 update_layer_list_impl_.reset(new LayerImplList); |
238 root_layer->layer_tree_impl()->BuildLayerListForTesting(); | 239 root_layer->layer_tree_impl()->BuildLayerListForTesting(); |
239 PropertyTrees* property_trees = | 240 PropertyTrees* property_trees = |
240 root_layer->layer_tree_impl()->property_trees(); | 241 root_layer->layer_tree_impl()->property_trees(); |
241 PropertyTreeBuilder::BuildPropertyTrees( | 242 PropertyTreeBuilder::BuildPropertyTrees( |
242 root_layer, page_scale_layer, inner_viewport_scroll_layer, | 243 root_layer, page_scale_layer, inner_viewport_scroll_layer, |
243 outer_viewport_scroll_layer, overscroll_elasticity_layer, | 244 outer_viewport_scroll_layer, overscroll_elasticity_layer, |
244 elastic_overscroll, page_scale_factor, device_scale_factor, | 245 elastic_overscroll, page_scale_factor, device_scale_factor, |
245 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); | 246 gfx::Rect(device_viewport_size), gfx::Transform(), property_trees); |
246 draw_property_utils::UpdatePropertyTreesAndRenderSurfaces( | 247 draw_property_utils::UpdatePropertyTreesAndRenderSurfaces( |
247 root_layer, property_trees, can_render_to_separate_surface); | 248 root_layer, property_trees, can_render_to_separate_surface, |
| 249 can_adjust_raster_scales); |
248 draw_property_utils::FindLayersThatNeedUpdates( | 250 draw_property_utils::FindLayersThatNeedUpdates( |
249 root_layer->layer_tree_impl(), property_trees, | 251 root_layer->layer_tree_impl(), property_trees, |
250 update_layer_list_impl_.get()); | 252 update_layer_list_impl_.get()); |
251 draw_property_utils::ComputeDrawPropertiesOfVisibleLayers( | 253 draw_property_utils::ComputeDrawPropertiesOfVisibleLayers( |
252 update_layer_list_impl(), property_trees); | 254 update_layer_list_impl(), property_trees); |
253 } | 255 } |
254 | 256 |
255 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces( | 257 void ExecuteCalculateDrawPropertiesWithoutSeparateSurfaces( |
256 LayerImpl* root_layer) { | 258 LayerImpl* root_layer) { |
257 gfx::Size device_viewport_size = | 259 gfx::Size device_viewport_size = |
258 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); | 260 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); |
259 render_surface_layer_list_impl_.reset(new LayerImplList); | 261 render_surface_layer_list_impl_.reset(new LayerImplList); |
260 | 262 |
261 DCHECK(!root_layer->bounds().IsEmpty()); | 263 DCHECK(!root_layer->bounds().IsEmpty()); |
262 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 264 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
263 root_layer, device_viewport_size, | 265 root_layer, device_viewport_size, |
264 render_surface_layer_list_impl_.get()); | 266 render_surface_layer_list_impl_.get()); |
265 inputs.can_adjust_raster_scales = true; | 267 inputs.can_adjust_raster_scales = true; |
266 inputs.can_render_to_separate_surface = false; | 268 inputs.can_render_to_separate_surface = false; |
267 | 269 |
268 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 270 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
269 } | 271 } |
270 | 272 |
| 273 void ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales( |
| 274 LayerImpl* root_layer) { |
| 275 gfx::Size device_viewport_size = |
| 276 gfx::Size(root_layer->bounds().width(), root_layer->bounds().height()); |
| 277 render_surface_layer_list_impl_.reset(new LayerImplList); |
| 278 |
| 279 DCHECK(!root_layer->bounds().IsEmpty()); |
| 280 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
| 281 root_layer, device_viewport_size, |
| 282 render_surface_layer_list_impl_.get()); |
| 283 inputs.can_render_to_separate_surface = true; |
| 284 inputs.can_adjust_raster_scales = false; |
| 285 |
| 286 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
| 287 } |
| 288 |
271 bool UpdateLayerListImplContains(int id) const { | 289 bool UpdateLayerListImplContains(int id) const { |
272 for (auto* layer : *update_layer_list_impl_) { | 290 for (auto* layer : *update_layer_list_impl_) { |
273 if (layer->id() == id) | 291 if (layer->id() == id) |
274 return true; | 292 return true; |
275 } | 293 } |
276 return false; | 294 return false; |
277 } | 295 } |
278 | 296 |
279 bool UpdateLayerListContains(int id) const { | 297 bool UpdateLayerListContains(int id) const { |
280 for (const auto& layer : update_layer_list_) { | 298 for (const auto& layer : update_layer_list_) { |
(...skipping 10535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10816 // Check other layers' scroll_tree_index | 10834 // Check other layers' scroll_tree_index |
10817 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); | 10835 EXPECT_EQ(scroll_root1.id, page_scale_layer->scroll_tree_index()); |
10818 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10836 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10819 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10837 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10820 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10838 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10821 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10839 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10822 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10840 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10823 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10841 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10824 } | 10842 } |
10825 | 10843 |
| 10844 TEST_F(LayerTreeHostCommonTest, CanAdjustRasterScaleTest) { |
| 10845 LayerImpl* root = root_layer_for_testing(); |
| 10846 LayerImpl* render_surface = AddChild<LayerImpl>(root); |
| 10847 LayerImpl* child = AddChild<LayerImpl>(render_surface); |
| 10848 |
| 10849 root->SetBounds(gfx::Size(50, 50)); |
| 10850 |
| 10851 render_surface->SetBounds(gfx::Size(10, 10)); |
| 10852 render_surface->test_properties()->force_render_surface = true; |
| 10853 gfx::Transform transform; |
| 10854 transform.Scale(5.f, 5.f); |
| 10855 render_surface->test_properties()->transform = transform; |
| 10856 |
| 10857 child->SetDrawsContent(true); |
| 10858 child->SetMasksToBounds(true); |
| 10859 child->SetBounds(gfx::Size(10, 10)); |
| 10860 |
| 10861 ExecuteCalculateDrawPropertiesWithoutAdjustingRasterScales(root); |
| 10862 |
| 10863 // Check surface draw properties. |
| 10864 EXPECT_EQ(gfx::Rect(10, 10), |
| 10865 render_surface->GetRenderSurface()->content_rect()); |
| 10866 EXPECT_EQ(transform, render_surface->GetRenderSurface()->draw_transform()); |
| 10867 EXPECT_EQ(gfx::RectF(50.0f, 50.0f), |
| 10868 render_surface->GetRenderSurface()->DrawableContentRect()); |
| 10869 |
| 10870 // Check child layer draw properties. |
| 10871 EXPECT_EQ(gfx::Rect(10, 10), child->visible_layer_rect()); |
| 10872 EXPECT_EQ(gfx::Transform(), child->DrawTransform()); |
| 10873 EXPECT_EQ(gfx::Rect(10, 10), child->clip_rect()); |
| 10874 EXPECT_EQ(gfx::Rect(10, 10), child->drawable_content_rect()); |
| 10875 } |
| 10876 |
10826 } // namespace | 10877 } // namespace |
10827 } // namespace cc | 10878 } // namespace cc |
OLD | NEW |