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 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 float device_scale_factor = 1.5f; | 1284 float device_scale_factor = 1.5f; |
1285 | 1285 |
1286 { | 1286 { |
1287 LayerImplList render_surface_layer_list_impl; | 1287 LayerImplList render_surface_layer_list_impl; |
1288 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1288 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1289 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1289 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1290 inputs.device_scale_factor = device_scale_factor; | 1290 inputs.device_scale_factor = device_scale_factor; |
1291 inputs.property_trees->needs_rebuild = true; | 1291 inputs.property_trees->needs_rebuild = true; |
1292 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1292 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1293 gfx::Transform device_scaled_translate = translate; | 1293 gfx::Transform device_scaled_translate = translate; |
1294 device_scaled_translate.matrix().postScale(device_scale_factor, | 1294 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); |
1295 device_scale_factor, 1.f); | |
1296 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1295 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1297 device_scaled_translate, | 1296 device_scaled_translate, |
1298 root->draw_properties().target_space_transform); | 1297 root->draw_properties().target_space_transform); |
1299 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1298 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1300 device_scaled_translate, | 1299 device_scaled_translate, |
1301 child->draw_properties().target_space_transform); | 1300 child->draw_properties().target_space_transform); |
1302 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1301 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1303 root->render_surface()->draw_transform()); | 1302 root->render_surface()->draw_transform()); |
1304 } | 1303 } |
1305 | 1304 |
1306 // Verify it composes correctly with page scale. | 1305 // Verify it composes correctly with page scale. |
1307 float page_scale_factor = 2.f; | 1306 float page_scale_factor = 2.f; |
1308 | 1307 |
1309 { | 1308 { |
1310 LayerImplList render_surface_layer_list_impl; | 1309 LayerImplList render_surface_layer_list_impl; |
1311 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1310 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1312 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1311 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1313 inputs.page_scale_factor = page_scale_factor; | 1312 inputs.page_scale_factor = page_scale_factor; |
1314 inputs.page_scale_layer = root; | 1313 inputs.page_scale_layer = root; |
1315 inputs.property_trees->needs_rebuild = true; | 1314 inputs.property_trees->needs_rebuild = true; |
1316 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1315 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1317 gfx::Transform page_scaled_translate = translate; | 1316 gfx::Transform page_scaled_translate = translate; |
1318 page_scaled_translate.matrix().postScale(page_scale_factor, | 1317 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); |
1319 page_scale_factor, 1.f); | |
1320 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1318 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1321 page_scaled_translate, root->draw_properties().target_space_transform); | 1319 page_scaled_translate, root->draw_properties().target_space_transform); |
1322 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1320 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1323 page_scaled_translate, child->draw_properties().target_space_transform); | 1321 page_scaled_translate, child->draw_properties().target_space_transform); |
1324 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1322 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1325 root->render_surface()->draw_transform()); | 1323 root->render_surface()->draw_transform()); |
1326 } | 1324 } |
1327 | 1325 |
1328 // Verify that it composes correctly with transforms directly on root layer. | 1326 // Verify that it composes correctly with transforms directly on root layer. |
1329 root->test_properties()->transform = composite; | 1327 root->test_properties()->transform = composite; |
(...skipping 8403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9733 test_layer->SetBounds(gfx::Size(20, 20)); | 9731 test_layer->SetBounds(gfx::Size(20, 20)); |
9734 test_layer->SetDrawsContent(true); | 9732 test_layer->SetDrawsContent(true); |
9735 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | 9733 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
9736 test_layer->test_properties()->opacity = 0.f; | 9734 test_layer->test_properties()->opacity = 0.f; |
9737 | 9735 |
9738 ExecuteCalculateDrawProperties(root); | 9736 ExecuteCalculateDrawProperties(root); |
9739 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 9737 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
9740 test_layer->ScreenSpaceTransform()); | 9738 test_layer->ScreenSpaceTransform()); |
9741 } | 9739 } |
9742 | 9740 |
9743 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) { | |
9744 LayerImpl* root = root_layer_for_testing(); | |
9745 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | |
9746 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | |
9747 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | |
9748 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | |
9749 | |
9750 root->SetBounds(gfx::Size(100, 100)); | |
9751 clip_layer->SetBounds(gfx::Size(20, 20)); | |
9752 clip_layer->SetMasksToBounds(true); | |
9753 clip_parent->SetBounds(gfx::Size(50, 50)); | |
9754 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | |
9755 unclipped_desc_surface->SetDrawsContent(true); | |
9756 unclipped_desc_surface->test_properties()->force_render_surface = true; | |
9757 clip_child->SetBounds(gfx::Size(100, 100)); | |
9758 clip_child->SetDrawsContent(true); | |
9759 | |
9760 clip_child->test_properties()->clip_parent = clip_parent; | |
9761 clip_parent->test_properties()->clip_children = | |
9762 base::MakeUnique<std::set<LayerImpl*>>(); | |
9763 clip_parent->test_properties()->clip_children->insert(clip_child); | |
9764 | |
9765 float device_scale_factor = 1.f; | |
9766 ExecuteCalculateDrawProperties(root, device_scale_factor); | |
9767 EXPECT_EQ(gfx::Rect(20, 20), clip_child->clip_rect()); | |
9768 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | |
9769 | |
9770 device_scale_factor = 2.f; | |
9771 ExecuteCalculateDrawProperties(root, device_scale_factor); | |
9772 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect()); | |
9773 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | |
9774 } | |
9775 | |
9776 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9741 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9777 LayerImpl* root = root_layer_for_testing(); | 9742 LayerImpl* root = root_layer_for_testing(); |
9778 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9743 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9779 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9744 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
9780 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9745 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
9781 | 9746 |
9782 root->SetBounds(gfx::Size(30, 30)); | 9747 root->SetBounds(gfx::Size(30, 30)); |
9783 clip_parent->SetBounds(gfx::Size(40, 40)); | 9748 clip_parent->SetBounds(gfx::Size(40, 40)); |
9784 clip_parent->SetMasksToBounds(true); | 9749 clip_parent->SetMasksToBounds(true); |
9785 render_surface->SetBounds(gfx::Size(50, 50)); | 9750 render_surface->SetBounds(gfx::Size(50, 50)); |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10415 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10380 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10416 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10381 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10417 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10382 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10418 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10383 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10419 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10384 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10420 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10385 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10421 } | 10386 } |
10422 | 10387 |
10423 } // namespace | 10388 } // namespace |
10424 } // namespace cc | 10389 } // namespace cc |
OLD | NEW |