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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 float device_scale_factor = 1.5f; | 1285 float device_scale_factor = 1.5f; |
1286 | 1286 |
1287 { | 1287 { |
1288 LayerImplList render_surface_layer_list_impl; | 1288 LayerImplList render_surface_layer_list_impl; |
1289 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1289 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1290 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1290 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1291 inputs.device_scale_factor = device_scale_factor; | 1291 inputs.device_scale_factor = device_scale_factor; |
1292 inputs.property_trees->needs_rebuild = true; | 1292 inputs.property_trees->needs_rebuild = true; |
1293 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1293 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1294 gfx::Transform device_scaled_translate = translate; | 1294 gfx::Transform device_scaled_translate = translate; |
1295 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); | 1295 device_scaled_translate.matrix().postScale(device_scale_factor, |
| 1296 device_scale_factor, 1.f); |
1296 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1297 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1297 device_scaled_translate, | 1298 device_scaled_translate, |
1298 root->draw_properties().target_space_transform); | 1299 root->draw_properties().target_space_transform); |
1299 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1300 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1300 device_scaled_translate, | 1301 device_scaled_translate, |
1301 child->draw_properties().target_space_transform); | 1302 child->draw_properties().target_space_transform); |
1302 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1303 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1303 root->render_surface()->draw_transform()); | 1304 root->render_surface()->draw_transform()); |
1304 } | 1305 } |
1305 | 1306 |
1306 // Verify it composes correctly with page scale. | 1307 // Verify it composes correctly with page scale. |
1307 float page_scale_factor = 2.f; | 1308 float page_scale_factor = 2.f; |
1308 | 1309 |
1309 { | 1310 { |
1310 LayerImplList render_surface_layer_list_impl; | 1311 LayerImplList render_surface_layer_list_impl; |
1311 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1312 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1312 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1313 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1313 inputs.page_scale_factor = page_scale_factor; | 1314 inputs.page_scale_factor = page_scale_factor; |
1314 inputs.page_scale_layer = root; | 1315 inputs.page_scale_layer = root; |
1315 inputs.property_trees->needs_rebuild = true; | 1316 inputs.property_trees->needs_rebuild = true; |
1316 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1317 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1317 gfx::Transform page_scaled_translate = translate; | 1318 gfx::Transform page_scaled_translate = translate; |
1318 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1319 page_scaled_translate.matrix().postScale(page_scale_factor, |
| 1320 page_scale_factor, 1.f); |
1319 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1321 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1320 page_scaled_translate, root->draw_properties().target_space_transform); | 1322 page_scaled_translate, root->draw_properties().target_space_transform); |
1321 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1323 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1322 page_scaled_translate, child->draw_properties().target_space_transform); | 1324 page_scaled_translate, child->draw_properties().target_space_transform); |
1323 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1325 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1324 root->render_surface()->draw_transform()); | 1326 root->render_surface()->draw_transform()); |
1325 } | 1327 } |
1326 | 1328 |
1327 // Verify that it composes correctly with transforms directly on root layer. | 1329 // Verify that it composes correctly with transforms directly on root layer. |
1328 root->test_properties()->transform = composite; | 1330 root->test_properties()->transform = composite; |
(...skipping 8314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9643 test_layer->SetBounds(gfx::Size(20, 20)); | 9645 test_layer->SetBounds(gfx::Size(20, 20)); |
9644 test_layer->SetDrawsContent(true); | 9646 test_layer->SetDrawsContent(true); |
9645 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | 9647 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
9646 test_layer->test_properties()->opacity = 0.f; | 9648 test_layer->test_properties()->opacity = 0.f; |
9647 | 9649 |
9648 ExecuteCalculateDrawProperties(root); | 9650 ExecuteCalculateDrawProperties(root); |
9649 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 9651 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
9650 test_layer->ScreenSpaceTransform()); | 9652 test_layer->ScreenSpaceTransform()); |
9651 } | 9653 } |
9652 | 9654 |
| 9655 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) { |
| 9656 LayerImpl* root = root_layer_for_testing(); |
| 9657 LayerImpl* clip_layer = AddChild<LayerImpl>(root); |
| 9658 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); |
| 9659 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); |
| 9660 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); |
| 9661 |
| 9662 root->SetBounds(gfx::Size(100, 100)); |
| 9663 clip_layer->SetBounds(gfx::Size(20, 20)); |
| 9664 clip_layer->SetMasksToBounds(true); |
| 9665 clip_parent->SetBounds(gfx::Size(50, 50)); |
| 9666 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); |
| 9667 unclipped_desc_surface->SetDrawsContent(true); |
| 9668 unclipped_desc_surface->test_properties()->force_render_surface = true; |
| 9669 clip_child->SetBounds(gfx::Size(100, 100)); |
| 9670 clip_child->SetDrawsContent(true); |
| 9671 |
| 9672 clip_child->test_properties()->clip_parent = clip_parent; |
| 9673 clip_parent->test_properties()->clip_children = |
| 9674 base::MakeUnique<std::set<LayerImpl*>>(); |
| 9675 clip_parent->test_properties()->clip_children->insert(clip_child); |
| 9676 |
| 9677 float device_scale_factor = 1.f; |
| 9678 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 9679 EXPECT_EQ(gfx::Rect(20, 20), clip_child->clip_rect()); |
| 9680 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); |
| 9681 |
| 9682 device_scale_factor = 2.f; |
| 9683 ExecuteCalculateDrawProperties(root, device_scale_factor); |
| 9684 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect()); |
| 9685 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); |
| 9686 } |
| 9687 |
9653 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9688 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9654 LayerImpl* root = root_layer_for_testing(); | 9689 LayerImpl* root = root_layer_for_testing(); |
9655 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9690 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9656 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9691 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
9657 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9692 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
9658 | 9693 |
9659 root->SetBounds(gfx::Size(30, 30)); | 9694 root->SetBounds(gfx::Size(30, 30)); |
9660 clip_parent->SetBounds(gfx::Size(40, 40)); | 9695 clip_parent->SetBounds(gfx::Size(40, 40)); |
9661 clip_parent->SetMasksToBounds(true); | 9696 clip_parent->SetMasksToBounds(true); |
9662 render_surface->SetBounds(gfx::Size(50, 50)); | 9697 render_surface->SetBounds(gfx::Size(50, 50)); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10293 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10328 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10294 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10329 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10295 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10330 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10296 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10331 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10297 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10332 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10298 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10333 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10299 } | 10334 } |
10300 | 10335 |
10301 } // namespace | 10336 } // namespace |
10302 } // namespace cc | 10337 } // namespace cc |
OLD | NEW |