Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1801853002: Transfer LayerImpl ownership to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more asan. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3123 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL; 3123 PushPropertiesCountingLayerImpl* grandchild_impl_ = NULL;
3124 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL; 3124 PushPropertiesCountingLayerImpl* leaf_always_pushing_layer_impl_ = NULL;
3125 3125
3126 // Pull the layers that we need from the tree assuming the same structure 3126 // Pull the layers that we need from the tree assuming the same structure
3127 // as LayerTreeHostTestLayersPushProperties 3127 // as LayerTreeHostTestLayersPushProperties
3128 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( 3128 root_impl_ = static_cast<PushPropertiesCountingLayerImpl*>(
3129 host_impl->RootLayer()); 3129 host_impl->RootLayer());
3130 3130
3131 if (root_impl_ && root_impl_->children().size() > 0) { 3131 if (root_impl_ && root_impl_->children().size() > 0) {
3132 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( 3132 child_impl_ = static_cast<PushPropertiesCountingLayerImpl*>(
3133 root_impl_->children()[0].get()); 3133 root_impl_->children()[0]);
3134 3134
3135 if (child_impl_ && child_impl_->children().size() > 0) 3135 if (child_impl_ && child_impl_->children().size() > 0)
3136 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( 3136 grandchild_impl_ = static_cast<PushPropertiesCountingLayerImpl*>(
3137 child_impl_->children()[0].get()); 3137 child_impl_->children()[0]);
3138 } 3138 }
3139 3139
3140 if (root_impl_ && root_impl_->children().size() > 1) { 3140 if (root_impl_ && root_impl_->children().size() > 1) {
3141 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>( 3141 child2_impl_ = static_cast<PushPropertiesCountingLayerImpl*>(
3142 root_impl_->children()[1].get()); 3142 root_impl_->children()[1]);
3143 3143
3144 if (child2_impl_ && child2_impl_->children().size() > 0) 3144 if (child2_impl_ && child2_impl_->children().size() > 0)
3145 leaf_always_pushing_layer_impl_ = 3145 leaf_always_pushing_layer_impl_ =
3146 static_cast<PushPropertiesCountingLayerImpl*>( 3146 static_cast<PushPropertiesCountingLayerImpl*>(
3147 child2_impl_->children()[0].get()); 3147 child2_impl_->children()[0]);
3148 } 3148 }
3149 3149
3150 if (root_impl_) 3150 if (root_impl_)
3151 EXPECT_EQ(expected_push_properties_root_impl_, 3151 EXPECT_EQ(expected_push_properties_root_impl_,
3152 root_impl_->push_properties_count()); 3152 root_impl_->push_properties_count());
3153 if (child_impl_) 3153 if (child_impl_)
3154 EXPECT_EQ(expected_push_properties_child_impl_, 3154 EXPECT_EQ(expected_push_properties_child_impl_,
3155 child_impl_->push_properties_count()); 3155 child_impl_->push_properties_count());
3156 if (grandchild_impl_) 3156 if (grandchild_impl_)
3157 EXPECT_EQ(expected_push_properties_grandchild_impl_, 3157 EXPECT_EQ(expected_push_properties_grandchild_impl_,
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after
3876 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting( 3876 EXPECT_FALSE(layer_tree_host()->LayerNeedsPushPropertiesForTesting(
3877 child_layer_.get())); 3877 child_layer_.get()));
3878 3878
3879 EndTest(); 3879 EndTest();
3880 break; 3880 break;
3881 } 3881 }
3882 } 3882 }
3883 3883
3884 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { 3884 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
3885 LayerImpl* root = impl->active_tree()->root_layer(); 3885 LayerImpl* root = impl->active_tree()->root_layer();
3886 LayerImpl* parent = root->children()[0].get(); 3886 LayerImpl* parent = root->children()[0];
3887 LayerImpl* child = parent->children()[0].get(); 3887 LayerImpl* child = parent->children()[0];
3888 3888
3889 switch (impl->active_tree()->source_frame_number()) { 3889 switch (impl->active_tree()->source_frame_number()) {
3890 case 1: 3890 case 1:
3891 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString()); 3891 EXPECT_EQ(gfx::Size(5, 5).ToString(), child->bounds().ToString());
3892 break; 3892 break;
3893 } 3893 }
3894 } 3894 }
3895 3895
3896 void AfterTest() override {} 3896 void AfterTest() override {}
3897 3897
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3977 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 3977 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
3978 3978
3979 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { 3979 void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
3980 if (host_impl->sync_tree()->source_frame_number() == 0) { 3980 if (host_impl->sync_tree()->source_frame_number() == 0) {
3981 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper(); 3981 scroll_elasticity_helper_ = host_impl->CreateScrollElasticityHelper();
3982 } 3982 }
3983 } 3983 }
3984 3984
3985 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { 3985 void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
3986 num_draws_++; 3986 num_draws_++;
3987 LayerImpl* content_layer_impl = host_impl->active_tree() 3987 LayerImpl* content_layer_impl =
3988 ->InnerViewportScrollLayer() 3988 host_impl->active_tree()->InnerViewportScrollLayer()->children()[0];
3989 ->children()[0]
3990 .get();
3991 gfx::Transform expected_draw_transform; 3989 gfx::Transform expected_draw_transform;
3992 switch (num_draws_) { 3990 switch (num_draws_) {
3993 case 1: 3991 case 1:
3994 // Initially, there's no overscroll. 3992 // Initially, there's no overscroll.
3995 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform()); 3993 EXPECT_EQ(expected_draw_transform, content_layer_impl->DrawTransform());
3996 3994
3997 // Begin overscrolling. This should be reflected in the draw transform 3995 // Begin overscrolling. This should be reflected in the draw transform
3998 // the next time we draw. 3996 // the next time we draw.
3999 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f)); 3997 scroll_elasticity_helper_->SetStretchAmount(gfx::Vector2dF(5.f, 6.f));
4000 break; 3998 break;
(...skipping 2653 matching lines...) Expand 10 before | Expand all | Expand 10 after
6654 EndTest(); 6652 EndTest();
6655 } 6653 }
6656 6654
6657 void AfterTest() override {} 6655 void AfterTest() override {}
6658 }; 6656 };
6659 6657
6660 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); 6658 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor);
6661 6659
6662 } // namespace 6660 } // namespace
6663 } // namespace cc 6661 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698