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 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3517 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), | 3517 Occlusion expected_occlusion(translate, SimpleEnclosedRegion(gfx::Rect()), |
3518 SimpleEnclosedRegion(gfx::Rect(200, 200))); | 3518 SimpleEnclosedRegion(gfx::Rect(200, 200))); |
3519 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3519 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
3520 | 3520 |
3521 // Mask layer should have the same occlusion. | 3521 // Mask layer should have the same occlusion. |
3522 actual_occlusion = | 3522 actual_occlusion = |
3523 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; | 3523 surface_child_mask_ptr->draw_properties().occlusion_in_content_space; |
3524 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); | 3524 EXPECT_TRUE(expected_occlusion.IsEqual(actual_occlusion)); |
3525 } | 3525 } |
3526 | 3526 |
| 3527 TEST_F(LayerTreeHostCommonTest, TextureLayerSnapping) { |
| 3528 FakeImplTaskRunnerProvider task_runner_provider; |
| 3529 TestSharedBitmapManager shared_bitmap_manager; |
| 3530 TestTaskGraphRunner task_graph_runner; |
| 3531 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
| 3532 FakeCompositorFrameSink::Create3d(); |
| 3533 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
| 3534 &task_graph_runner); |
| 3535 |
| 3536 std::unique_ptr<LayerImpl> root = |
| 3537 LayerImpl::Create(host_impl.active_tree(), 1); |
| 3538 std::unique_ptr<TextureLayerImpl> child = |
| 3539 TextureLayerImpl::Create(host_impl.active_tree(), 2); |
| 3540 |
| 3541 LayerImpl* child_ptr = child.get(); |
| 3542 |
| 3543 root->SetBounds(gfx::Size(100, 100)); |
| 3544 child->SetBounds(gfx::Size(100, 100)); |
| 3545 child->SetDrawsContent(true); |
| 3546 gfx::Transform fractional_translate; |
| 3547 fractional_translate.Translate(10.5f, 20.3f); |
| 3548 child->test_properties()->transform = fractional_translate; |
| 3549 |
| 3550 host_impl.SetViewportSize(root->bounds()); |
| 3551 |
| 3552 root->test_properties()->AddChild(std::move(child)); |
| 3553 host_impl.active_tree()->SetRootLayerForTesting(std::move(root)); |
| 3554 host_impl.SetVisible(true); |
| 3555 host_impl.InitializeRenderer(compositor_frame_sink.get()); |
| 3556 host_impl.active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 3557 bool update_lcd_text = false; |
| 3558 host_impl.active_tree()->UpdateDrawProperties(update_lcd_text); |
| 3559 |
| 3560 EXPECT_NE(child_ptr->ScreenSpaceTransform(), fractional_translate); |
| 3561 fractional_translate.RoundTranslationComponents(); |
| 3562 EXPECT_TRANSFORMATION_MATRIX_EQ(child_ptr->ScreenSpaceTransform(), |
| 3563 fractional_translate); |
| 3564 gfx::RectF layer_bounds_in_screen_space = |
| 3565 MathUtil::MapClippedRect(child_ptr->ScreenSpaceTransform(), |
| 3566 gfx::RectF(gfx::SizeF(child_ptr->bounds()))); |
| 3567 EXPECT_EQ(layer_bounds_in_screen_space, gfx::RectF(11.f, 20.f, 100.f, 100.f)); |
| 3568 } |
| 3569 |
3527 TEST_F(LayerTreeHostCommonTest, | 3570 TEST_F(LayerTreeHostCommonTest, |
3528 OcclusionForLayerWithUninvertibleDrawTransform) { | 3571 OcclusionForLayerWithUninvertibleDrawTransform) { |
3529 FakeImplTaskRunnerProvider task_runner_provider; | 3572 FakeImplTaskRunnerProvider task_runner_provider; |
3530 TestSharedBitmapManager shared_bitmap_manager; | 3573 TestSharedBitmapManager shared_bitmap_manager; |
3531 TestTaskGraphRunner task_graph_runner; | 3574 TestTaskGraphRunner task_graph_runner; |
3532 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = | 3575 std::unique_ptr<CompositorFrameSink> compositor_frame_sink = |
3533 FakeCompositorFrameSink::Create3d(); | 3576 FakeCompositorFrameSink::Create3d(); |
3534 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, | 3577 FakeLayerTreeHostImpl host_impl(&task_runner_provider, &shared_bitmap_manager, |
3535 &task_graph_runner); | 3578 &task_graph_runner); |
3536 | 3579 |
(...skipping 6835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10372 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10415 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
10373 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10416 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
10374 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10417 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
10375 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10418 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
10376 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10419 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
10377 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10420 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
10378 } | 10421 } |
10379 | 10422 |
10380 } // namespace | 10423 } // namespace |
10381 } // namespace cc | 10424 } // namespace cc |
OLD | NEW |