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

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

Issue 465853004: Moving RenderSurface creation outside of CalcDrawProps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 int num_draws_; 283 int num_draws_;
284 }; 284 };
285 285
286 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); 286 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
287 287
288 // Verify that we pass property values in PushPropertiesTo. 288 // Verify that we pass property values in PushPropertiesTo.
289 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { 289 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
290 protected: 290 protected:
291 void SetupTree() override { 291 void SetupTree() override {
292 scoped_refptr<Layer> root = Layer::Create(); 292 scoped_refptr<Layer> root = Layer::Create();
293 root->CreateRenderSurface();
293 root->SetBounds(gfx::Size(10, 10)); 294 root->SetBounds(gfx::Size(10, 10));
294 layer_tree_host()->SetRootLayer(root); 295 layer_tree_host()->SetRootLayer(root);
295 LayerTreeHostTest::SetupTree(); 296 LayerTreeHostTest::SetupTree();
296 } 297 }
297 298
298 enum Properties { 299 enum Properties {
299 STARTUP, 300 STARTUP,
300 BOUNDS, 301 BOUNDS,
301 HIDE_LAYER_AND_SUBTREE, 302 HIDE_LAYER_AND_SUBTREE,
302 DRAWS_CONTENT, 303 DRAWS_CONTENT,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 477
477 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { 478 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
478 public: 479 public:
479 void InitializeSettings(LayerTreeSettings* settings) override { 480 void InitializeSettings(LayerTreeSettings* settings) override {
480 settings->layer_transforms_should_scale_layer_contents = true; 481 settings->layer_transforms_should_scale_layer_contents = true;
481 } 482 }
482 483
483 void SetupTree() override { 484 void SetupTree() override {
484 root_layer_ = Layer::Create(); 485 root_layer_ = Layer::Create();
485 root_layer_->SetBounds(gfx::Size(10, 20)); 486 root_layer_->SetBounds(gfx::Size(10, 20));
487 root_layer_->CreateRenderSurface();
486 488
487 if (layer_tree_host()->settings().impl_side_painting) 489 if (layer_tree_host()->settings().impl_side_painting)
488 scaled_layer_ = FakePictureLayer::Create(&client_); 490 scaled_layer_ = FakePictureLayer::Create(&client_);
489 else 491 else
490 scaled_layer_ = FakeContentLayer::Create(&client_); 492 scaled_layer_ = FakeContentLayer::Create(&client_);
491 scaled_layer_->SetBounds(gfx::Size(1, 1)); 493 scaled_layer_->SetBounds(gfx::Size(1, 1));
492 root_layer_->AddChild(scaled_layer_); 494 root_layer_->AddChild(scaled_layer_);
493 495
494 layer_tree_host()->SetRootLayer(root_layer_); 496 layer_tree_host()->SetRootLayer(root_layer_);
495 LayerTreeHostTest::SetupTree(); 497 LayerTreeHostTest::SetupTree();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate 539 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate
538 : public LayerTreeHostTest { 540 : public LayerTreeHostTest {
539 public: 541 public:
540 void InitializeSettings(LayerTreeSettings* settings) override { 542 void InitializeSettings(LayerTreeSettings* settings) override {
541 settings->layer_transforms_should_scale_layer_contents = true; 543 settings->layer_transforms_should_scale_layer_contents = true;
542 } 544 }
543 545
544 void SetupTree() override { 546 void SetupTree() override {
545 root_layer_ = Layer::Create(); 547 root_layer_ = Layer::Create();
546 root_layer_->SetBounds(gfx::Size(10, 20)); 548 root_layer_->SetBounds(gfx::Size(10, 20));
549 root_layer_->CreateRenderSurface();
547 550
548 bool paint_scrollbar = true; 551 bool paint_scrollbar = true;
549 bool has_thumb = false; 552 bool has_thumb = false;
550 scrollbar_ = FakePaintedScrollbarLayer::Create( 553 scrollbar_ = FakePaintedScrollbarLayer::Create(
551 paint_scrollbar, has_thumb, root_layer_->id()); 554 paint_scrollbar, has_thumb, root_layer_->id());
552 scrollbar_->SetPosition(gfx::Point(0, 10)); 555 scrollbar_->SetPosition(gfx::Point(0, 10));
553 scrollbar_->SetBounds(gfx::Size(10, 10)); 556 scrollbar_->SetBounds(gfx::Size(10, 10));
554 557
555 root_layer_->AddChild(scrollbar_); 558 root_layer_->AddChild(scrollbar_);
556 559
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 // Tests that if a layer is not drawn because of some reason in the parent, 791 // Tests that if a layer is not drawn because of some reason in the parent,
789 // causing its content bounds to not be computed, then when it is later drawn, 792 // causing its content bounds to not be computed, then when it is later drawn,
790 // its content bounds get pushed. 793 // its content bounds get pushed.
791 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater 794 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater
792 : public LayerTreeHostTest { 795 : public LayerTreeHostTest {
793 public: 796 public:
794 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() 797 LayerTreeHostTestUndrawnLayersPushContentBoundsLater()
795 : root_layer_(Layer::Create()) {} 798 : root_layer_(Layer::Create()) {}
796 799
797 void SetupTree() override { 800 void SetupTree() override {
801 root_layer_->CreateRenderSurface();
798 root_layer_->SetIsDrawable(true); 802 root_layer_->SetIsDrawable(true);
799 root_layer_->SetBounds(gfx::Size(20, 20)); 803 root_layer_->SetBounds(gfx::Size(20, 20));
800 layer_tree_host()->SetRootLayer(root_layer_); 804 layer_tree_host()->SetRootLayer(root_layer_);
801 805
802 parent_layer_ = Layer::Create(); 806 parent_layer_ = Layer::Create();
803 parent_layer_->SetBounds(gfx::Size(20, 20)); 807 parent_layer_->SetBounds(gfx::Size(20, 20));
804 parent_layer_->SetOpacity(0.0f); 808 parent_layer_->SetOpacity(0.0f);
805 root_layer_->AddChild(parent_layer_); 809 root_layer_->AddChild(parent_layer_);
806 810
807 child_layer_ = Layer::Create(); 811 child_layer_ = Layer::Create();
(...skipping 2369 matching lines...) Expand 10 before | Expand all | Expand 10 after
3177 expected_push_properties_child_ = 0; 3181 expected_push_properties_child_ = 0;
3178 expected_push_properties_grandchild_ = 0; 3182 expected_push_properties_grandchild_ = 0;
3179 expected_push_properties_child2_ = 0; 3183 expected_push_properties_child2_ = 0;
3180 expected_push_properties_other_root_ = 0; 3184 expected_push_properties_other_root_ = 0;
3181 expected_push_properties_leaf_layer_ = 0; 3185 expected_push_properties_leaf_layer_ = 0;
3182 PostSetNeedsCommitToMainThread(); 3186 PostSetNeedsCommitToMainThread();
3183 } 3187 }
3184 3188
3185 void SetupTree() override { 3189 void SetupTree() override {
3186 root_ = PushPropertiesCountingLayer::Create(); 3190 root_ = PushPropertiesCountingLayer::Create();
3191 root_->CreateRenderSurface();
3187 child_ = PushPropertiesCountingLayer::Create(); 3192 child_ = PushPropertiesCountingLayer::Create();
3188 child2_ = PushPropertiesCountingLayer::Create(); 3193 child2_ = PushPropertiesCountingLayer::Create();
3189 grandchild_ = PushPropertiesCountingLayer::Create(); 3194 grandchild_ = PushPropertiesCountingLayer::Create();
3190 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); 3195 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create();
3191 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); 3196 leaf_always_pushing_layer_->set_persist_needs_push_properties(true);
3192 3197
3193 root_->AddChild(child_); 3198 root_->AddChild(child_);
3194 root_->AddChild(child2_); 3199 root_->AddChild(child2_);
3195 child_->AddChild(grandchild_); 3200 child_->AddChild(grandchild_);
3196 child2_->AddChild(leaf_always_pushing_layer_); 3201 child2_->AddChild(leaf_always_pushing_layer_);
3197 3202
3198 other_root_ = PushPropertiesCountingLayer::Create(); 3203 other_root_ = PushPropertiesCountingLayer::Create();
3204 other_root_->CreateRenderSurface();
3199 3205
3200 // Don't set the root layer here. 3206 // Don't set the root layer here.
3201 LayerTreeHostTest::SetupTree(); 3207 LayerTreeHostTest::SetupTree();
3202 } 3208 }
3203 3209
3204 void DidCommitAndDrawFrame() override { 3210 void DidCommitAndDrawFrame() override {
3205 ++num_commits_; 3211 ++num_commits_;
3206 3212
3207 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 3213 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
3208 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 3214 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 RunTestWithImplSidePainting(); 3567 RunTestWithImplSidePainting();
3562 } 3568 }
3563 3569
3564 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed 3570 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
3565 : public LayerTreeHostTest { 3571 : public LayerTreeHostTest {
3566 protected: 3572 protected:
3567 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 3573 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
3568 3574
3569 void SetupTree() override { 3575 void SetupTree() override {
3570 root_ = Layer::Create(); 3576 root_ = Layer::Create();
3577 root_->CreateRenderSurface();
3571 root_->SetBounds(gfx::Size(1, 1)); 3578 root_->SetBounds(gfx::Size(1, 1));
3572 3579
3573 bool paint_scrollbar = true; 3580 bool paint_scrollbar = true;
3574 bool has_thumb = false; 3581 bool has_thumb = false;
3575 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( 3582 scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
3576 paint_scrollbar, has_thumb, root_->id()); 3583 paint_scrollbar, has_thumb, root_->id());
3577 3584
3578 root_->AddChild(scrollbar_layer_); 3585 root_->AddChild(scrollbar_layer_);
3579 3586
3580 layer_tree_host()->SetRootLayer(root_); 3587 layer_tree_host()->SetRootLayer(root_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3617 }; 3624 };
3618 3625
3619 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); 3626 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
3620 3627
3621 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { 3628 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
3622 protected: 3629 protected:
3623 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 3630 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
3624 3631
3625 void SetupTree() override { 3632 void SetupTree() override {
3626 root_ = PushPropertiesCountingLayer::Create(); 3633 root_ = PushPropertiesCountingLayer::Create();
3634 root_->CreateRenderSurface();
3627 child_ = PushPropertiesCountingLayer::Create(); 3635 child_ = PushPropertiesCountingLayer::Create();
3628 root_->AddChild(child_); 3636 root_->AddChild(child_);
3629 3637
3630 layer_tree_host()->SetRootLayer(root_); 3638 layer_tree_host()->SetRootLayer(root_);
3631 LayerTreeHostTest::SetupTree(); 3639 LayerTreeHostTest::SetupTree();
3632 } 3640 }
3633 3641
3634 void DidCommitAndDrawFrame() override { 3642 void DidCommitAndDrawFrame() override {
3635 switch (layer_tree_host()->source_frame_number()) { 3643 switch (layer_tree_host()->source_frame_number()) {
3636 case 0: 3644 case 0:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 expected_push_properties_root_ = 0; 3686 expected_push_properties_root_ = 0;
3679 expected_push_properties_child_ = 0; 3687 expected_push_properties_child_ = 0;
3680 expected_push_properties_grandchild1_ = 0; 3688 expected_push_properties_grandchild1_ = 0;
3681 expected_push_properties_grandchild2_ = 0; 3689 expected_push_properties_grandchild2_ = 0;
3682 expected_push_properties_grandchild3_ = 0; 3690 expected_push_properties_grandchild3_ = 0;
3683 PostSetNeedsCommitToMainThread(); 3691 PostSetNeedsCommitToMainThread();
3684 } 3692 }
3685 3693
3686 void SetupTree() override { 3694 void SetupTree() override {
3687 root_ = PushPropertiesCountingLayer::Create(); 3695 root_ = PushPropertiesCountingLayer::Create();
3696 root_->CreateRenderSurface();
3688 child_ = PushPropertiesCountingLayer::Create(); 3697 child_ = PushPropertiesCountingLayer::Create();
3689 grandchild1_ = PushPropertiesCountingLayer::Create(); 3698 grandchild1_ = PushPropertiesCountingLayer::Create();
3690 grandchild2_ = PushPropertiesCountingLayer::Create(); 3699 grandchild2_ = PushPropertiesCountingLayer::Create();
3691 grandchild3_ = PushPropertiesCountingLayer::Create(); 3700 grandchild3_ = PushPropertiesCountingLayer::Create();
3692 3701
3693 root_->AddChild(child_); 3702 root_->AddChild(child_);
3694 child_->AddChild(grandchild1_); 3703 child_->AddChild(grandchild1_);
3695 child_->AddChild(grandchild2_); 3704 child_->AddChild(grandchild2_);
3696 child_->AddChild(grandchild3_); 3705 child_->AddChild(grandchild3_);
3697 3706
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
4231 }; 4240 };
4232 4241
4233 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 4242 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4234 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 4243 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4235 LayerTreeHostTestIOSurfaceLayerInvalidate); 4244 LayerTreeHostTestIOSurfaceLayerInvalidate);
4236 4245
4237 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4246 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4238 protected: 4247 protected:
4239 void SetupTree() override { 4248 void SetupTree() override {
4240 root_layer_ = Layer::Create(); 4249 root_layer_ = Layer::Create();
4250 root_layer_->CreateRenderSurface();
4241 root_layer_->SetPosition(gfx::Point()); 4251 root_layer_->SetPosition(gfx::Point());
4242 root_layer_->SetBounds(gfx::Size(10, 10)); 4252 root_layer_->SetBounds(gfx::Size(10, 10));
4243 4253
4244 parent_layer_ = SolidColorLayer::Create(); 4254 parent_layer_ = SolidColorLayer::Create();
4245 parent_layer_->SetPosition(gfx::Point()); 4255 parent_layer_->SetPosition(gfx::Point());
4246 parent_layer_->SetBounds(gfx::Size(10, 10)); 4256 parent_layer_->SetBounds(gfx::Size(10, 10));
4247 parent_layer_->SetIsDrawable(true); 4257 parent_layer_->SetIsDrawable(true);
4248 root_layer_->AddChild(parent_layer_); 4258 root_layer_->AddChild(parent_layer_);
4249 4259
4250 child_layer_ = SolidColorLayer::Create(); 4260 child_layer_ = SolidColorLayer::Create();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4339 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { 4349 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
4340 public: 4350 public:
4341 LayerTreeHostTestAbortEvictedTextures() 4351 LayerTreeHostTestAbortEvictedTextures()
4342 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} 4352 : num_will_begin_main_frames_(0), num_impl_commits_(0) {}
4343 4353
4344 protected: 4354 protected:
4345 void SetupTree() override { 4355 void SetupTree() override {
4346 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); 4356 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
4347 root_layer->SetBounds(gfx::Size(200, 200)); 4357 root_layer->SetBounds(gfx::Size(200, 200));
4348 root_layer->SetIsDrawable(true); 4358 root_layer->SetIsDrawable(true);
4359 root_layer->CreateRenderSurface();
4349 4360
4350 layer_tree_host()->SetRootLayer(root_layer); 4361 layer_tree_host()->SetRootLayer(root_layer);
4351 LayerTreeHostTest::SetupTree(); 4362 LayerTreeHostTest::SetupTree();
4352 } 4363 }
4353 4364
4354 void BeginTest() override { PostSetNeedsCommitToMainThread(); } 4365 void BeginTest() override { PostSetNeedsCommitToMainThread(); }
4355 4366
4356 void WillBeginMainFrame() override { 4367 void WillBeginMainFrame() override {
4357 num_will_begin_main_frames_++; 4368 num_will_begin_main_frames_++;
4358 switch (num_will_begin_main_frames_) { 4369 switch (num_will_begin_main_frames_) {
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
5152 public: 5163 public:
5153 LayerTreeHostTestContinuousPainting() 5164 LayerTreeHostTestContinuousPainting()
5154 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} 5165 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {}
5155 5166
5156 protected: 5167 protected:
5157 enum { kExpectedNumCommits = 10 }; 5168 enum { kExpectedNumCommits = 10 };
5158 5169
5159 void SetupTree() override { 5170 void SetupTree() override {
5160 scoped_refptr<Layer> root_layer = Layer::Create(); 5171 scoped_refptr<Layer> root_layer = Layer::Create();
5161 root_layer->SetBounds(bounds_); 5172 root_layer->SetBounds(bounds_);
5173 root_layer->CreateRenderSurface();
5162 5174
5163 if (layer_tree_host()->settings().impl_side_painting) { 5175 if (layer_tree_host()->settings().impl_side_painting) {
5164 picture_layer_ = FakePictureLayer::Create(&client_); 5176 picture_layer_ = FakePictureLayer::Create(&client_);
5165 child_layer_ = picture_layer_.get(); 5177 child_layer_ = picture_layer_.get();
5166 } else { 5178 } else {
5167 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); 5179 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_);
5168 child_layer_ = content_layer_.get(); 5180 child_layer_ = content_layer_.get();
5169 } 5181 }
5170 child_layer_->SetBounds(bounds_); 5182 child_layer_->SetBounds(bounds_);
5171 child_layer_->SetIsDrawable(true); 5183 child_layer_->SetIsDrawable(true);
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
5881 5893
5882 FakeContentLayerClient client_; 5894 FakeContentLayerClient client_;
5883 int step_; 5895 int step_;
5884 int continuous_draws_; 5896 int continuous_draws_;
5885 base::WaitableEvent playback_allowed_event_; 5897 base::WaitableEvent playback_allowed_event_;
5886 }; 5898 };
5887 5899
5888 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles); 5900 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousDrawWhenCreatingVisibleTiles);
5889 5901
5890 } // namespace cc 5902 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698