| 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 <set> | 10 #include <set> |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 | 124 |
| 125 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform()); | 125 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->DrawTransform()); |
| 126 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 126 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 127 child->ScreenSpaceTransform()); | 127 child->ScreenSpaceTransform()); |
| 128 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 128 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 129 grand_child->DrawTransform()); | 129 grand_child->DrawTransform()); |
| 130 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 130 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 131 grand_child->ScreenSpaceTransform()); | 131 grand_child->ScreenSpaceTransform()); |
| 132 } | 132 } |
| 133 | 133 |
| 134 TEST_F(LayerTreeHostCommonTest, | |
| 135 ScreenSpaceTransformOfSkippedLayersWithHandlers) { | |
| 136 // Even for layers that are skipped, we need to compute the correct screen | |
| 137 // space transform because it is used during hit testing. | |
| 138 LayerImpl* parent = root_layer(); | |
| 139 LayerImpl* child = AddChild<LayerImpl>(parent); | |
| 140 LayerImpl* grand_child = AddChild<LayerImpl>(child); | |
| 141 child->SetDrawsContent(true); | |
| 142 grand_child->SetDrawsContent(true); | |
| 143 | |
| 144 gfx::Transform identity_matrix; | |
| 145 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | |
| 146 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 147 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | |
| 148 gfx::PointF(10, 10), gfx::Size(100, 100), true, | |
| 149 false); | |
| 150 // This will cause the subtree to be skipped. | |
| 151 child->SetOpacity(0.f); | |
| 152 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | |
| 153 gfx::PointF(10, 10), gfx::Size(100, 100), true, | |
| 154 false); | |
| 155 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | |
| 156 | |
| 157 ExecuteCalculateDrawProperties(parent); | |
| 158 | |
| 159 EXPECT_TRUE(child->has_render_surface()); | |
| 160 EXPECT_FALSE(grand_child->has_render_surface()); | |
| 161 // Check that we've computed draw properties for the subtree rooted at | |
| 162 // |child|. | |
| 163 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity()); | |
| 164 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity()); | |
| 165 } | |
| 166 | |
| 167 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 134 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
| 168 // Tests that effect tree node gets a valid transform id when a layer | 135 // Tests that effect tree node gets a valid transform id when a layer |
| 169 // has opacity but doesn't create a render surface. | 136 // has opacity but doesn't create a render surface. |
| 170 LayerImpl* parent = root_layer(); | 137 LayerImpl* parent = root_layer(); |
| 171 LayerImpl* child = AddChild<LayerImpl>(parent); | 138 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 172 child->SetDrawsContent(true); | 139 child->SetDrawsContent(true); |
| 173 | 140 |
| 174 gfx::Transform identity_matrix; | 141 gfx::Transform identity_matrix; |
| 175 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 142 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 176 gfx::PointF(), gfx::Size(100, 100), true, false); | 143 gfx::PointF(), gfx::Size(100, 100), true, false); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 parent_composite_transform, | 453 parent_composite_transform, |
| 487 draw_property_utils::ScreenSpaceTransform(child, tree)); | 454 draw_property_utils::ScreenSpaceTransform(child, tree)); |
| 488 EXPECT_TRANSFORMATION_MATRIX_EQ( | 455 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 489 parent_composite_transform, | 456 parent_composite_transform, |
| 490 draw_property_utils::DrawTransform(grand_child, tree)); | 457 draw_property_utils::DrawTransform(grand_child, tree)); |
| 491 EXPECT_TRANSFORMATION_MATRIX_EQ( | 458 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 492 parent_composite_transform, | 459 parent_composite_transform, |
| 493 draw_property_utils::ScreenSpaceTransform(grand_child, tree)); | 460 draw_property_utils::ScreenSpaceTransform(grand_child, tree)); |
| 494 } | 461 } |
| 495 | 462 |
| 463 // Render target should get cleared when subtree is skipped. |
| 464 TEST_F(LayerTreeHostCommonTest, ClearRenderTargetForSkippedLayers) { |
| 465 LayerImpl* root = root_layer(); |
| 466 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 467 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 468 child->SetDrawsContent(true); |
| 469 |
| 470 gfx::Transform identity_matrix; |
| 471 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 472 gfx::PointF(), gfx::Size(1, 2), true, false, |
| 473 true); |
| 474 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 475 gfx::PointF(), gfx::Size(1, 2), true, false, |
| 476 true); |
| 477 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), |
| 478 gfx::PointF(), gfx::Size(1, 2), true, false, |
| 479 false); |
| 480 |
| 481 ExecuteCalculateDrawProperties(root); |
| 482 ASSERT_TRUE(parent->render_surface()); |
| 483 EXPECT_EQ(parent, child->render_target()); |
| 484 |
| 485 // child is skipped when root's opacity is set to 0. So, its render target |
| 486 // should be reset. |
| 487 root->OnOpacityAnimated(0.0f); |
| 488 ExecuteCalculateDrawProperties(root); |
| 489 EXPECT_FALSE(child->render_target()); |
| 490 } |
| 491 |
| 496 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { | 492 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { |
| 497 LayerImpl* root = root_layer(); | 493 LayerImpl* root = root_layer(); |
| 498 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 494 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 499 LayerImpl* child = AddChild<LayerImpl>(parent); | 495 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 500 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 496 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 501 grand_child->SetDrawsContent(true); | 497 grand_child->SetDrawsContent(true); |
| 502 | 498 |
| 503 gfx::Transform identity_matrix; | 499 gfx::Transform identity_matrix; |
| 504 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 500 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 505 gfx::PointF(), gfx::Size(1, 2), true, false, | 501 gfx::PointF(), gfx::Size(1, 2), true, false, |
| (...skipping 9506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10012 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10008 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10013 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10009 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10014 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10010 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10015 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10011 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10016 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10012 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10017 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10013 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10018 } | 10014 } |
| 10019 | 10015 |
| 10020 } // namespace | 10016 } // namespace |
| 10021 } // namespace cc | 10017 } // namespace cc |
| OLD | NEW |