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 1263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1274 float device_scale_factor = 1.5f; | 1274 float device_scale_factor = 1.5f; |
1275 | 1275 |
1276 { | 1276 { |
1277 LayerImplList render_surface_layer_list_impl; | 1277 LayerImplList render_surface_layer_list_impl; |
1278 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1278 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1279 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1279 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1280 inputs.device_scale_factor = device_scale_factor; | 1280 inputs.device_scale_factor = device_scale_factor; |
1281 inputs.property_trees->needs_rebuild = true; | 1281 inputs.property_trees->needs_rebuild = true; |
1282 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1282 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1283 gfx::Transform device_scaled_translate = translate; | 1283 gfx::Transform device_scaled_translate = translate; |
1284 device_scaled_translate.Scale(device_scale_factor, device_scale_factor); | 1284 device_scaled_translate.matrix().postScale(device_scale_factor, |
1285 device_scale_factor, 1.f); | |
1285 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1286 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1286 device_scaled_translate, | 1287 device_scaled_translate, |
1287 root->draw_properties().target_space_transform); | 1288 root->draw_properties().target_space_transform); |
1288 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1289 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1289 device_scaled_translate, | 1290 device_scaled_translate, |
1290 child->draw_properties().target_space_transform); | 1291 child->draw_properties().target_space_transform); |
1291 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1292 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1292 root->render_surface()->draw_transform()); | 1293 root->render_surface()->draw_transform()); |
1293 } | 1294 } |
1294 | 1295 |
1295 // Verify it composes correctly with page scale. | 1296 // Verify it composes correctly with page scale. |
1296 float page_scale_factor = 2.f; | 1297 float page_scale_factor = 2.f; |
1297 | 1298 |
1298 { | 1299 { |
1299 LayerImplList render_surface_layer_list_impl; | 1300 LayerImplList render_surface_layer_list_impl; |
1300 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( | 1301 LayerTreeHostCommon::CalcDrawPropsImplInputsForTesting inputs( |
1301 root, root->bounds(), translate, &render_surface_layer_list_impl); | 1302 root, root->bounds(), translate, &render_surface_layer_list_impl); |
1302 inputs.page_scale_factor = page_scale_factor; | 1303 inputs.page_scale_factor = page_scale_factor; |
1303 inputs.page_scale_layer = root; | 1304 inputs.page_scale_layer = root; |
1304 inputs.property_trees->needs_rebuild = true; | 1305 inputs.property_trees->needs_rebuild = true; |
1305 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); | 1306 LayerTreeHostCommon::CalculateDrawPropertiesForTesting(&inputs); |
1306 gfx::Transform page_scaled_translate = translate; | 1307 gfx::Transform page_scaled_translate = translate; |
1307 page_scaled_translate.Scale(page_scale_factor, page_scale_factor); | 1308 page_scaled_translate.matrix().postScale(page_scale_factor, |
1309 page_scale_factor, 1.f); | |
1308 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1310 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1309 page_scaled_translate, root->draw_properties().target_space_transform); | 1311 page_scaled_translate, root->draw_properties().target_space_transform); |
1310 EXPECT_TRANSFORMATION_MATRIX_EQ( | 1312 EXPECT_TRANSFORMATION_MATRIX_EQ( |
1311 page_scaled_translate, child->draw_properties().target_space_transform); | 1313 page_scaled_translate, child->draw_properties().target_space_transform); |
1312 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), | 1314 EXPECT_TRANSFORMATION_MATRIX_EQ(gfx::Transform(), |
1313 root->render_surface()->draw_transform()); | 1315 root->render_surface()->draw_transform()); |
1314 } | 1316 } |
1315 | 1317 |
1316 // Verify that it composes correctly with transforms directly on root layer. | 1318 // Verify that it composes correctly with transforms directly on root layer. |
1317 root->test_properties()->transform = composite; | 1319 root->test_properties()->transform = composite; |
(...skipping 8151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9469 test_layer->SetBounds(gfx::Size(20, 20)); | 9471 test_layer->SetBounds(gfx::Size(20, 20)); |
9470 test_layer->SetDrawsContent(true); | 9472 test_layer->SetDrawsContent(true); |
9471 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); | 9473 test_layer->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 20, 20)); |
9472 test_layer->test_properties()->opacity = 0.f; | 9474 test_layer->test_properties()->opacity = 0.f; |
9473 | 9475 |
9474 ExecuteCalculateDrawProperties(root); | 9476 ExecuteCalculateDrawProperties(root); |
9475 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, | 9477 EXPECT_TRANSFORMATION_MATRIX_EQ(translation, |
9476 test_layer->ScreenSpaceTransform()); | 9478 test_layer->ScreenSpaceTransform()); |
9477 } | 9479 } |
9478 | 9480 |
9481 TEST_F(LayerTreeHostCommonTest, ClipParentDrawsIntoScaledRootSurface) { | |
9482 LayerImpl* root = root_layer_for_testing(); | |
9483 LayerImpl* clip_layer = AddChild<LayerImpl>(root); | |
9484 LayerImpl* clip_parent = AddChild<LayerImpl>(clip_layer); | |
9485 LayerImpl* unclipped_desc_surface = AddChild<LayerImpl>(clip_parent); | |
9486 LayerImpl* clip_child = AddChild<LayerImpl>(unclipped_desc_surface); | |
9487 | |
9488 root->SetBounds(gfx::Size(100, 100)); | |
9489 clip_layer->SetBounds(gfx::Size(20, 20)); | |
9490 clip_layer->SetMasksToBounds(true); | |
9491 clip_parent->SetBounds(gfx::Size(50, 50)); | |
9492 unclipped_desc_surface->SetBounds(gfx::Size(100, 100)); | |
9493 unclipped_desc_surface->SetDrawsContent(true); | |
9494 unclipped_desc_surface->test_properties()->force_render_surface = true; | |
9495 clip_child->SetBounds(gfx::Size(100, 100)); | |
9496 clip_child->SetDrawsContent(true); | |
9497 | |
9498 clip_child->test_properties()->clip_parent = clip_parent; | |
9499 clip_parent->test_properties()->clip_children = | |
9500 base::MakeUnique<std::set<LayerImpl*>>(); | |
9501 clip_parent->test_properties()->clip_children->insert(clip_child); | |
9502 | |
9503 float device_scale_factor = 2.f; | |
weiliangc
2016/10/13 21:16:18
Could you add a case with device scale factor = 1.
jaydasika
2016/10/13 22:02:22
Done.
| |
9504 ExecuteCalculateDrawProperties(root, device_scale_factor); | |
9505 EXPECT_EQ(gfx::Rect(40, 40), clip_child->clip_rect()); | |
9506 EXPECT_EQ(gfx::Rect(20, 20), clip_child->visible_layer_rect()); | |
9507 } | |
9508 | |
9479 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { | 9509 TEST_F(LayerTreeHostCommonTest, ClipChildVisibleRect) { |
9480 LayerImpl* root = root_layer_for_testing(); | 9510 LayerImpl* root = root_layer_for_testing(); |
9481 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); | 9511 LayerImpl* clip_parent = AddChildToRoot<LayerImpl>(); |
9482 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); | 9512 LayerImpl* render_surface = AddChild<LayerImpl>(clip_parent); |
9483 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); | 9513 LayerImpl* clip_child = AddChild<LayerImpl>(render_surface); |
9484 | 9514 |
9485 root->SetBounds(gfx::Size(30, 30)); | 9515 root->SetBounds(gfx::Size(30, 30)); |
9486 clip_parent->SetBounds(gfx::Size(40, 40)); | 9516 clip_parent->SetBounds(gfx::Size(40, 40)); |
9487 clip_parent->SetMasksToBounds(true); | 9517 clip_parent->SetMasksToBounds(true); |
9488 render_surface->SetBounds(gfx::Size(50, 50)); | 9518 render_surface->SetBounds(gfx::Size(50, 50)); |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10119 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10149 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10120 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10150 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10121 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10151 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10122 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10152 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10123 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10153 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10124 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10154 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10125 } | 10155 } |
10126 | 10156 |
10127 } // namespace | 10157 } // namespace |
10128 } // namespace cc | 10158 } // namespace cc |
OLD | NEW |