| 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 1722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 | 1733 |
| 1734 // Both layers are on impl. | 1734 // Both layers are on impl. |
| 1735 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); | 1735 ASSERT_EQ(1u, impl->active_tree()->root_layer()->children().size()); |
| 1736 | 1736 |
| 1737 // Device viewport is scaled. | 1737 // Device viewport is scaled. |
| 1738 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); | 1738 EXPECT_EQ(gfx::Size(60, 60), impl->DrawViewportSize()); |
| 1739 | 1739 |
| 1740 FakePictureLayerImpl* root = | 1740 FakePictureLayerImpl* root = |
| 1741 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); | 1741 static_cast<FakePictureLayerImpl*>(impl->active_tree()->root_layer()); |
| 1742 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( | 1742 FakePictureLayerImpl* child = static_cast<FakePictureLayerImpl*>( |
| 1743 impl->active_tree()->root_layer()->children()[0].get()); | 1743 impl->active_tree()->root_layer()->children()[0]); |
| 1744 | 1744 |
| 1745 // Positions remain in layout pixels. | 1745 // Positions remain in layout pixels. |
| 1746 EXPECT_EQ(gfx::PointF(), root->position()); | 1746 EXPECT_EQ(gfx::PointF(), root->position()); |
| 1747 EXPECT_EQ(gfx::PointF(2.f, 2.f), child->position()); | 1747 EXPECT_EQ(gfx::PointF(2.f, 2.f), child->position()); |
| 1748 | 1748 |
| 1749 // Compute all the layer transforms for the frame. | 1749 // Compute all the layer transforms for the frame. |
| 1750 LayerTreeHostImpl::FrameData frame_data; | 1750 LayerTreeHostImpl::FrameData frame_data; |
| 1751 impl->PrepareToDraw(&frame_data); | 1751 impl->PrepareToDraw(&frame_data); |
| 1752 impl->DidDrawAllLayers(frame_data); | 1752 impl->DidDrawAllLayers(frame_data); |
| 1753 | 1753 |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; | 3118 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; |
| 3119 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; | 3119 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; |
| 3120 | 3120 |
| 3121 // Pull the layers that we need from the tree assuming the same structure | 3121 // Pull the layers that we need from the tree assuming the same structure |
| 3122 // as LayerTreeHostTestLayersPushProperties | 3122 // as LayerTreeHostTestLayersPushProperties |
| 3123 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3123 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 3124 host_impl->RootLayer()); | 3124 host_impl->RootLayer()); |
| 3125 | 3125 |
| 3126 if (root_impl_ && root_impl_->children().size() > 0) { | 3126 if (root_impl_ && root_impl_->children().size() > 0) { |
| 3127 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3127 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 3128 root_impl_->children()[0].get()); | 3128 root_impl_->children()[0]); |
| 3129 | 3129 |
| 3130 if (child_impl_ && child_impl_->children().size() > 0) | 3130 if (child_impl_ && child_impl_->children().size() > 0) |
| 3131 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3131 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 3132 child_impl_->children()[0].get()); | 3132 child_impl_->children()[0]); |
| 3133 } | 3133 } |
| 3134 | 3134 |
| 3135 if (root_impl_ && root_impl_->children().size() > 1) { | 3135 if (root_impl_ && root_impl_->children().size() > 1) { |
| 3136 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( | 3136 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( |
| 3137 root_impl_->children()[1].get()); | 3137 root_impl_->children()[1]); |
| 3138 | 3138 |
| 3139 if (child2_impl_ && child2_impl_->children().size() > 0) | 3139 if (child2_impl_ && child2_impl_->children().size() > 0) |
| 3140 leaf_always_pushing_layer_impl_ = | 3140 leaf_always_pushing_layer_impl_ = |
| 3141 static_cast<PushPropertiesCountingLayerImpl*>( | 3141 static_cast<PushPropertiesCountingLayerImpl*>( |
| 3142 child2_impl_->children()[0].get()); | 3142 child2_impl_->children()[0]); |
| 3143 } | 3143 } |
| 3144 | 3144 |
| 3145 if (root_impl_) | 3145 if (root_impl_) |
| 3146 EXPECT_EQ(expected_push_properties_root_impl_, | 3146 EXPECT_EQ(expected_push_properties_root_impl_, |
| 3147 root_impl_->push_properties_count()); | 3147 root_impl_->push_properties_count()); |
| 3148 if (child_impl_) | 3148 if (child_impl_) |
| 3149 EXPECT_EQ(expected_push_properties_child_impl_, | 3149 EXPECT_EQ(expected_push_properties_child_impl_, |
| 3150 child_impl_->push_properties_count()); | 3150 child_impl_->push_properties_count()); |
| 3151 if (grandchild_impl_) | 3151 if (grandchild_impl_) |
| 3152 EXPECT_EQ(expected_push_properties_grandchild_impl_, | 3152 EXPECT_EQ(expected_push_properties_grandchild_impl_, |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3869 // The bounds of the child layer were pushed to the impl side. | 3869 // The bounds of the child layer were pushed to the impl side. |
| 3870 EXPECT_FALSE(child_layer_->needs_push_properties()); | 3870 EXPECT_FALSE(child_layer_->needs_push_properties()); |
| 3871 | 3871 |
| 3872 EndTest(); | 3872 EndTest(); |
| 3873 break; | 3873 break; |
| 3874 } | 3874 } |
| 3875 } | 3875 } |
| 3876 | 3876 |
| 3877 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 3877 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 3878 LayerImpl* root = impl->active_tree()->root_layer(); | 3878 LayerImpl* root = impl->active_tree()->root_layer(); |
| 3879 LayerImpl* parent = root->children()[0].get(); | 3879 LayerImpl* parent = root->children()[0]; |
| 3880 LayerImpl* child = parent->children()[0].get(); | 3880 LayerImpl* child = parent->children()[0]; |
| 3881 | 3881 |
| 3882 switch (impl->active_tree()->source_frame_number()) { | 3882 switch (impl->active_tree()->source_frame_number()) { |
| 3883 case 1: | 3883 case 1: |
| 3884 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); | 3884 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); |
| 3885 break; | 3885 break; |
| 3886 } | 3886 } |
| 3887 } | 3887 } |
| 3888 | 3888 |
| 3889 void AfterTest() override {} | 3889 void AfterTest() override {} |
| 3890 | 3890 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3970 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3970 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 3971 | 3971 |
| 3972 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { | 3972 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| 3973 if (host_impl->sync_tree()->source_frame_number() == 0) { | 3973 if (host_impl->sync_tree()->source_frame_number() == 0) { |
| 3974 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper(); | 3974 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper(); |
| 3975 } | 3975 } |
| 3976 } | 3976 } |
| 3977 | 3977 |
| 3978 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { | 3978 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { |
| 3979 num_draws_++; | 3979 num_draws_++; |
| 3980 LayerImpl* content_layer_impl = host_impl->active_tree() | 3980 LayerImpl* content_layer_impl = |
| 3981 ->InnerViewportScrollLayer() | 3981 host_impl->active_tree()->InnerViewportScrollLayer()->children()[0]; |
| 3982 ->children()[0] | |
| 3983 .get(); | |
| 3984 gfx::Transform expected_draw_transform; | 3982 gfx::Transform expected_draw_transform; |
| 3985 switch (num_draws_) { | 3983 switch (num_draws_) { |
| 3986 case 1: | 3984 case 1: |
| 3987 // Initially, there's no overscroll. | 3985 // Initially, there's no overscroll. |
| 3988 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform()); | 3986 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform()); |
| 3989 | 3987 |
| 3990 // Begin overscrolling. This should be reflected in the draw transform | 3988 // Begin overscrolling. This should be reflected in the draw transform |
| 3991 // the next time we draw. | 3989 // the next time we draw. |
| 3992 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f)); | 3990 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f)); |
| 3993 break; | 3991 break; |
| (...skipping 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6647 EndTest(); | 6645 EndTest(); |
| 6648 } | 6646 } |
| 6649 | 6647 |
| 6650 void AfterTest() override {} | 6648 void AfterTest() override {} |
| 6651 }; | 6649 }; |
| 6652 | 6650 |
| 6653 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6651 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6654 | 6652 |
| 6655 } // namespace | 6653 } // namespace |
| 6656 } // namespace cc | 6654 } // namespace cc |
| OLD | NEW |