Chromium Code Reviews| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 143 |
| 144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); | 144 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, child->draw_transform()); |
| 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 145 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 146 child->screen_space_transform()); | 146 child->screen_space_transform()); |
| 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 147 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 148 grand_child->draw_transform()); | 148 grand_child->draw_transform()); |
| 149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, | 149 EXPECT_TRANSFORMATION_MATRIX_EQ(identity_matrix, |
| 150 grand_child->screen_space_transform()); | 150 grand_child->screen_space_transform()); |
| 151 } | 151 } |
| 152 | 152 |
| 153 TEST_F(LayerTreeHostCommonTest, | |
| 154 ScreenSpaceTransformOfSkippedLayersWithHandlers) { | |
| 155 // Even for layers that are skipped, we need to compute the correct screen | |
| 156 // space transform because it is used during hit testing. | |
| 157 LayerImpl* parent = root_layer(); | |
| 158 LayerImpl* child = AddChild<LayerImpl>(parent); | |
| 159 LayerImpl* grand_child = AddChild<LayerImpl>(child); | |
| 160 child->SetDrawsContent(true); | |
| 161 grand_child->SetDrawsContent(true); | |
| 162 | |
| 163 gfx::Transform identity_matrix; | |
| 164 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | |
| 165 gfx::PointF(), gfx::Size(100, 100), true, false); | |
| 166 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | |
| 167 gfx::PointF(10, 10), gfx::Size(100, 100), true, | |
| 168 false); | |
| 169 // This will cause the subtree to be skipped. | |
| 170 child->SetOpacity(0.f); | |
| 171 SetLayerPropertiesForTesting(grand_child, identity_matrix, gfx::Point3F(), | |
| 172 gfx::PointF(10, 10), gfx::Size(100, 100), true, | |
| 173 false); | |
| 174 grand_child->SetTouchEventHandlerRegion(gfx::Rect(0, 0, 100, 100)); | |
| 175 | |
| 176 ExecuteCalculateDrawProperties(parent); | |
| 177 | |
| 178 EXPECT_TRUE(child->has_render_surface()); | |
| 179 EXPECT_FALSE(grand_child->has_render_surface()); | |
| 180 // Check that we've computed draw properties for the subtree rooted at | |
| 181 // |child|. | |
| 182 EXPECT_FALSE(child->render_surface()->screen_space_transform().IsIdentity()); | |
| 183 EXPECT_FALSE(grand_child->ScreenSpaceTransform().IsIdentity()); | |
| 184 } | |
| 185 | |
| 186 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { | 153 TEST_F(LayerTreeHostCommonTest, EffectTreeTransformIdTest) { |
| 187 // Tests that effect tree node gets a valid transform id when a layer | 154 // Tests that effect tree node gets a valid transform id when a layer |
| 188 // has opacity but doesn't create a render surface. | 155 // has opacity but doesn't create a render surface. |
| 189 LayerImpl* parent = root_layer(); | 156 LayerImpl* parent = root_layer(); |
| 190 LayerImpl* child = AddChild<LayerImpl>(parent); | 157 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 191 child->SetDrawsContent(true); | 158 child->SetDrawsContent(true); |
| 192 | 159 |
| 193 gfx::Transform identity_matrix; | 160 gfx::Transform identity_matrix; |
| 194 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | 161 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), |
| 195 gfx::PointF(), gfx::Size(100, 100), true, false); | 162 gfx::PointF(), gfx::Size(100, 100), true, false); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 parent_composite_transform, | 482 parent_composite_transform, |
| 516 draw_property_utils::ScreenSpaceTransform(child.get(), tree)); | 483 draw_property_utils::ScreenSpaceTransform(child.get(), tree)); |
| 517 EXPECT_TRANSFORMATION_MATRIX_EQ( | 484 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 518 parent_composite_transform, | 485 parent_composite_transform, |
| 519 draw_property_utils::DrawTransform(grand_child.get(), tree)); | 486 draw_property_utils::DrawTransform(grand_child.get(), tree)); |
| 520 EXPECT_TRANSFORMATION_MATRIX_EQ( | 487 EXPECT_TRANSFORMATION_MATRIX_EQ( |
| 521 parent_composite_transform, | 488 parent_composite_transform, |
| 522 draw_property_utils::ScreenSpaceTransform(grand_child.get(), tree)); | 489 draw_property_utils::ScreenSpaceTransform(grand_child.get(), tree)); |
| 523 } | 490 } |
| 524 | 491 |
| 492 // Render target should get cleared when subtree is skipped. | |
| 493 TEST_F(LayerTreeHostCommonTest, ClearRenderTargetForSkippedLayers) { | |
| 494 LayerImpl* root = root_layer(); | |
| 495 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | |
| 496 LayerImpl* child = AddChild<LayerImpl>(parent); | |
| 497 child->SetDrawsContent(true); | |
| 498 | |
| 499 gfx::Transform identity_matrix; | |
| 500 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | |
| 501 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 502 true); | |
| 503 SetLayerPropertiesForTesting(parent, identity_matrix, gfx::Point3F(), | |
| 504 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 505 true); | |
| 506 SetLayerPropertiesForTesting(child, identity_matrix, gfx::Point3F(), | |
| 507 gfx::PointF(), gfx::Size(1, 2), true, false, | |
| 508 false); | |
| 509 | |
| 510 ExecuteCalculateDrawProperties(root); | |
| 511 ASSERT_TRUE(parent->render_surface()); | |
| 512 EXPECT_EQ(parent, child->render_target()); | |
| 513 | |
| 514 // child is skipped when root's opacity is set to 0. So, its render target | |
| 515 // should e reset. | |
|
ajuma
2016/04/05 19:05:35
typo: 'be'
jaydasika
2016/04/05 19:19:03
Done.
| |
| 516 root->OnOpacityAnimated(0.0f); | |
| 517 ExecuteCalculateDrawProperties(root); | |
| 518 EXPECT_FALSE(child->render_target()); | |
| 519 } | |
| 520 | |
| 525 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { | 521 TEST_F(LayerTreeHostCommonTest, TransformsForSingleRenderSurface) { |
| 526 LayerImpl* root = root_layer(); | 522 LayerImpl* root = root_layer(); |
| 527 LayerImpl* parent = AddChildToRoot<LayerImpl>(); | 523 LayerImpl* parent = AddChildToRoot<LayerImpl>(); |
| 528 LayerImpl* child = AddChild<LayerImpl>(parent); | 524 LayerImpl* child = AddChild<LayerImpl>(parent); |
| 529 LayerImpl* grand_child = AddChild<LayerImpl>(child); | 525 LayerImpl* grand_child = AddChild<LayerImpl>(child); |
| 530 grand_child->SetDrawsContent(true); | 526 grand_child->SetDrawsContent(true); |
| 531 | 527 |
| 532 gfx::Transform identity_matrix; | 528 gfx::Transform identity_matrix; |
| 533 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), | 529 SetLayerPropertiesForTesting(root, identity_matrix, gfx::Point3F(), |
| 534 gfx::PointF(), gfx::Size(1, 2), true, false, | 530 gfx::PointF(), gfx::Size(1, 2), true, false, |
| (...skipping 9510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10045 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); | 10041 EXPECT_EQ(scroll_child6.id, grand_child10->scroll_tree_index()); |
| 10046 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); | 10042 EXPECT_EQ(scroll_root1.id, parent3->scroll_tree_index()); |
| 10047 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); | 10043 EXPECT_EQ(scroll_child7.id, child8->scroll_tree_index()); |
| 10048 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); | 10044 EXPECT_EQ(scroll_root1.id, parent4->scroll_tree_index()); |
| 10049 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); | 10045 EXPECT_EQ(scroll_root1.id, child9->scroll_tree_index()); |
| 10050 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); | 10046 EXPECT_EQ(scroll_root1.id, grand_child12->scroll_tree_index()); |
| 10051 } | 10047 } |
| 10052 | 10048 |
| 10053 } // namespace | 10049 } // namespace |
| 10054 } // namespace cc | 10050 } // namespace cc |
| OLD | NEW |