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

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, 3 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 <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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 int num_draws_; 138 int num_draws_;
139 }; 139 };
140 140
141 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); 141 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2);
142 142
143 // Verify that we pass property values in PushPropertiesTo. 143 // Verify that we pass property values in PushPropertiesTo.
144 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { 144 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest {
145 protected: 145 protected:
146 virtual void SetupTree() OVERRIDE { 146 virtual void SetupTree() OVERRIDE {
147 scoped_refptr<Layer> root = Layer::Create(); 147 scoped_refptr<Layer> root = Layer::Create();
148 root->CreateRenderSurface();
148 root->SetBounds(gfx::Size(10, 10)); 149 root->SetBounds(gfx::Size(10, 10));
149 layer_tree_host()->SetRootLayer(root); 150 layer_tree_host()->SetRootLayer(root);
150 LayerTreeHostTest::SetupTree(); 151 LayerTreeHostTest::SetupTree();
151 } 152 }
152 153
153 enum Properties { 154 enum Properties {
154 STARTUP, 155 STARTUP,
155 BOUNDS, 156 BOUNDS,
156 HIDE_LAYER_AND_SUBTREE, 157 HIDE_LAYER_AND_SUBTREE,
157 DRAWS_CONTENT, 158 DRAWS_CONTENT,
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 332
332 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { 333 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest {
333 public: 334 public:
334 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 335 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
335 settings->layer_transforms_should_scale_layer_contents = true; 336 settings->layer_transforms_should_scale_layer_contents = true;
336 } 337 }
337 338
338 virtual void SetupTree() OVERRIDE { 339 virtual void SetupTree() OVERRIDE {
339 root_layer_ = Layer::Create(); 340 root_layer_ = Layer::Create();
340 root_layer_->SetBounds(gfx::Size(10, 20)); 341 root_layer_->SetBounds(gfx::Size(10, 20));
342 root_layer_->CreateRenderSurface();
341 343
342 scaled_layer_ = FakeContentLayer::Create(&client_); 344 scaled_layer_ = FakeContentLayer::Create(&client_);
343 scaled_layer_->SetBounds(gfx::Size(1, 1)); 345 scaled_layer_->SetBounds(gfx::Size(1, 1));
344 root_layer_->AddChild(scaled_layer_); 346 root_layer_->AddChild(scaled_layer_);
345 347
346 layer_tree_host()->SetRootLayer(root_layer_); 348 layer_tree_host()->SetRootLayer(root_layer_);
347 LayerTreeHostTest::SetupTree(); 349 LayerTreeHostTest::SetupTree();
348 } 350 }
349 351
350 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 352 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate 386 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate
385 : public LayerTreeHostTest { 387 : public LayerTreeHostTest {
386 public: 388 public:
387 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { 389 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
388 settings->layer_transforms_should_scale_layer_contents = true; 390 settings->layer_transforms_should_scale_layer_contents = true;
389 } 391 }
390 392
391 virtual void SetupTree() OVERRIDE { 393 virtual void SetupTree() OVERRIDE {
392 root_layer_ = Layer::Create(); 394 root_layer_ = Layer::Create();
393 root_layer_->SetBounds(gfx::Size(10, 20)); 395 root_layer_->SetBounds(gfx::Size(10, 20));
396 root_layer_->CreateRenderSurface();
394 397
395 bool paint_scrollbar = true; 398 bool paint_scrollbar = true;
396 bool has_thumb = false; 399 bool has_thumb = false;
397 scrollbar_ = FakePaintedScrollbarLayer::Create( 400 scrollbar_ = FakePaintedScrollbarLayer::Create(
398 paint_scrollbar, has_thumb, root_layer_->id()); 401 paint_scrollbar, has_thumb, root_layer_->id());
399 scrollbar_->SetPosition(gfx::Point(0, 10)); 402 scrollbar_->SetPosition(gfx::Point(0, 10));
400 scrollbar_->SetBounds(gfx::Size(10, 10)); 403 scrollbar_->SetBounds(gfx::Size(10, 10));
401 404
402 root_layer_->AddChild(scrollbar_); 405 root_layer_->AddChild(scrollbar_);
403 406
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // Tests that if a layer is not drawn because of some reason in the parent, 629 // Tests that if a layer is not drawn because of some reason in the parent,
627 // causing its content bounds to not be computed, then when it is later drawn, 630 // causing its content bounds to not be computed, then when it is later drawn,
628 // its content bounds get pushed. 631 // its content bounds get pushed.
629 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater 632 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater
630 : public LayerTreeHostTest { 633 : public LayerTreeHostTest {
631 public: 634 public:
632 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() 635 LayerTreeHostTestUndrawnLayersPushContentBoundsLater()
633 : root_layer_(Layer::Create()) {} 636 : root_layer_(Layer::Create()) {}
634 637
635 virtual void SetupTree() OVERRIDE { 638 virtual void SetupTree() OVERRIDE {
639 root_layer_->CreateRenderSurface();
636 root_layer_->SetIsDrawable(true); 640 root_layer_->SetIsDrawable(true);
637 root_layer_->SetBounds(gfx::Size(20, 20)); 641 root_layer_->SetBounds(gfx::Size(20, 20));
638 layer_tree_host()->SetRootLayer(root_layer_); 642 layer_tree_host()->SetRootLayer(root_layer_);
639 643
640 parent_layer_ = Layer::Create(); 644 parent_layer_ = Layer::Create();
641 parent_layer_->SetBounds(gfx::Size(20, 20)); 645 parent_layer_->SetBounds(gfx::Size(20, 20));
642 parent_layer_->SetOpacity(0.0f); 646 parent_layer_->SetOpacity(0.0f);
643 root_layer_->AddChild(parent_layer_); 647 root_layer_->AddChild(parent_layer_);
644 648
645 child_layer_ = Layer::Create(); 649 child_layer_ = Layer::Create();
(...skipping 2316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 expected_push_properties_child_ = 0; 2966 expected_push_properties_child_ = 0;
2963 expected_push_properties_grandchild_ = 0; 2967 expected_push_properties_grandchild_ = 0;
2964 expected_push_properties_child2_ = 0; 2968 expected_push_properties_child2_ = 0;
2965 expected_push_properties_other_root_ = 0; 2969 expected_push_properties_other_root_ = 0;
2966 expected_push_properties_leaf_layer_ = 0; 2970 expected_push_properties_leaf_layer_ = 0;
2967 PostSetNeedsCommitToMainThread(); 2971 PostSetNeedsCommitToMainThread();
2968 } 2972 }
2969 2973
2970 virtual void SetupTree() OVERRIDE { 2974 virtual void SetupTree() OVERRIDE {
2971 root_ = PushPropertiesCountingLayer::Create(); 2975 root_ = PushPropertiesCountingLayer::Create();
2976 root_->CreateRenderSurface();
2972 child_ = PushPropertiesCountingLayer::Create(); 2977 child_ = PushPropertiesCountingLayer::Create();
2973 child2_ = PushPropertiesCountingLayer::Create(); 2978 child2_ = PushPropertiesCountingLayer::Create();
2974 grandchild_ = PushPropertiesCountingLayer::Create(); 2979 grandchild_ = PushPropertiesCountingLayer::Create();
2975 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); 2980 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create();
2976 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); 2981 leaf_always_pushing_layer_->set_persist_needs_push_properties(true);
2977 2982
2978 root_->AddChild(child_); 2983 root_->AddChild(child_);
2979 root_->AddChild(child2_); 2984 root_->AddChild(child2_);
2980 child_->AddChild(grandchild_); 2985 child_->AddChild(grandchild_);
2981 child2_->AddChild(leaf_always_pushing_layer_); 2986 child2_->AddChild(leaf_always_pushing_layer_);
2982 2987
2983 other_root_ = PushPropertiesCountingLayer::Create(); 2988 other_root_ = PushPropertiesCountingLayer::Create();
2989 other_root_->CreateRenderSurface();
2984 2990
2985 // Don't set the root layer here. 2991 // Don't set the root layer here.
2986 LayerTreeHostTest::SetupTree(); 2992 LayerTreeHostTest::SetupTree();
2987 } 2993 }
2988 2994
2989 virtual void DidCommitAndDrawFrame() OVERRIDE { 2995 virtual void DidCommitAndDrawFrame() OVERRIDE {
2990 ++num_commits_; 2996 ++num_commits_;
2991 2997
2992 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 2998 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
2993 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 2999 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 RunTestWithImplSidePainting(); 3352 RunTestWithImplSidePainting();
3347 } 3353 }
3348 3354
3349 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed 3355 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
3350 : public LayerTreeHostTest { 3356 : public LayerTreeHostTest {
3351 protected: 3357 protected:
3352 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3358 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
3353 3359
3354 virtual void SetupTree() OVERRIDE { 3360 virtual void SetupTree() OVERRIDE {
3355 root_ = Layer::Create(); 3361 root_ = Layer::Create();
3362 root_->CreateRenderSurface();
3356 root_->SetBounds(gfx::Size(1, 1)); 3363 root_->SetBounds(gfx::Size(1, 1));
3357 3364
3358 bool paint_scrollbar = true; 3365 bool paint_scrollbar = true;
3359 bool has_thumb = false; 3366 bool has_thumb = false;
3360 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( 3367 scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
3361 paint_scrollbar, has_thumb, root_->id()); 3368 paint_scrollbar, has_thumb, root_->id());
3362 3369
3363 root_->AddChild(scrollbar_layer_); 3370 root_->AddChild(scrollbar_layer_);
3364 3371
3365 layer_tree_host()->SetRootLayer(root_); 3372 layer_tree_host()->SetRootLayer(root_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 }; 3409 };
3403 3410
3404 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); 3411 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
3405 3412
3406 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { 3413 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
3407 protected: 3414 protected:
3408 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3415 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
3409 3416
3410 virtual void SetupTree() OVERRIDE { 3417 virtual void SetupTree() OVERRIDE {
3411 root_ = PushPropertiesCountingLayer::Create(); 3418 root_ = PushPropertiesCountingLayer::Create();
3419 root_->CreateRenderSurface();
3412 child_ = PushPropertiesCountingLayer::Create(); 3420 child_ = PushPropertiesCountingLayer::Create();
3413 root_->AddChild(child_); 3421 root_->AddChild(child_);
3414 3422
3415 layer_tree_host()->SetRootLayer(root_); 3423 layer_tree_host()->SetRootLayer(root_);
3416 LayerTreeHostTest::SetupTree(); 3424 LayerTreeHostTest::SetupTree();
3417 } 3425 }
3418 3426
3419 virtual void DidCommitAndDrawFrame() OVERRIDE { 3427 virtual void DidCommitAndDrawFrame() OVERRIDE {
3420 switch (layer_tree_host()->source_frame_number()) { 3428 switch (layer_tree_host()->source_frame_number()) {
3421 case 0: 3429 case 0:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 expected_push_properties_root_ = 0; 3471 expected_push_properties_root_ = 0;
3464 expected_push_properties_child_ = 0; 3472 expected_push_properties_child_ = 0;
3465 expected_push_properties_grandchild1_ = 0; 3473 expected_push_properties_grandchild1_ = 0;
3466 expected_push_properties_grandchild2_ = 0; 3474 expected_push_properties_grandchild2_ = 0;
3467 expected_push_properties_grandchild3_ = 0; 3475 expected_push_properties_grandchild3_ = 0;
3468 PostSetNeedsCommitToMainThread(); 3476 PostSetNeedsCommitToMainThread();
3469 } 3477 }
3470 3478
3471 virtual void SetupTree() OVERRIDE { 3479 virtual void SetupTree() OVERRIDE {
3472 root_ = PushPropertiesCountingLayer::Create(); 3480 root_ = PushPropertiesCountingLayer::Create();
3481 root_->CreateRenderSurface();
3473 child_ = PushPropertiesCountingLayer::Create(); 3482 child_ = PushPropertiesCountingLayer::Create();
3474 grandchild1_ = PushPropertiesCountingLayer::Create(); 3483 grandchild1_ = PushPropertiesCountingLayer::Create();
3475 grandchild2_ = PushPropertiesCountingLayer::Create(); 3484 grandchild2_ = PushPropertiesCountingLayer::Create();
3476 grandchild3_ = PushPropertiesCountingLayer::Create(); 3485 grandchild3_ = PushPropertiesCountingLayer::Create();
3477 3486
3478 root_->AddChild(child_); 3487 root_->AddChild(child_);
3479 child_->AddChild(grandchild1_); 3488 child_->AddChild(grandchild1_);
3480 child_->AddChild(grandchild2_); 3489 child_->AddChild(grandchild2_);
3481 child_->AddChild(grandchild3_); 3490 child_->AddChild(grandchild3_);
3482 3491
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4017 }; 4026 };
4018 4027
4019 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 4028 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4020 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 4029 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4021 LayerTreeHostTestIOSurfaceLayerInvalidate); 4030 LayerTreeHostTestIOSurfaceLayerInvalidate);
4022 4031
4023 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4032 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4024 protected: 4033 protected:
4025 virtual void SetupTree() OVERRIDE { 4034 virtual void SetupTree() OVERRIDE {
4026 root_layer_ = Layer::Create(); 4035 root_layer_ = Layer::Create();
4036 root_layer_->CreateRenderSurface();
4027 root_layer_->SetPosition(gfx::Point()); 4037 root_layer_->SetPosition(gfx::Point());
4028 root_layer_->SetBounds(gfx::Size(10, 10)); 4038 root_layer_->SetBounds(gfx::Size(10, 10));
4029 4039
4030 parent_layer_ = SolidColorLayer::Create(); 4040 parent_layer_ = SolidColorLayer::Create();
4031 parent_layer_->SetPosition(gfx::Point()); 4041 parent_layer_->SetPosition(gfx::Point());
4032 parent_layer_->SetBounds(gfx::Size(10, 10)); 4042 parent_layer_->SetBounds(gfx::Size(10, 10));
4033 parent_layer_->SetIsDrawable(true); 4043 parent_layer_->SetIsDrawable(true);
4034 root_layer_->AddChild(parent_layer_); 4044 root_layer_->AddChild(parent_layer_);
4035 4045
4036 child_layer_ = SolidColorLayer::Create(); 4046 child_layer_ = SolidColorLayer::Create();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { 4135 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
4126 public: 4136 public:
4127 LayerTreeHostTestAbortEvictedTextures() 4137 LayerTreeHostTestAbortEvictedTextures()
4128 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} 4138 : num_will_begin_main_frames_(0), num_impl_commits_(0) {}
4129 4139
4130 protected: 4140 protected:
4131 virtual void SetupTree() OVERRIDE { 4141 virtual void SetupTree() OVERRIDE {
4132 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); 4142 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
4133 root_layer->SetBounds(gfx::Size(200, 200)); 4143 root_layer->SetBounds(gfx::Size(200, 200));
4134 root_layer->SetIsDrawable(true); 4144 root_layer->SetIsDrawable(true);
4145 root_layer->CreateRenderSurface();
4135 4146
4136 layer_tree_host()->SetRootLayer(root_layer); 4147 layer_tree_host()->SetRootLayer(root_layer);
4137 LayerTreeHostTest::SetupTree(); 4148 LayerTreeHostTest::SetupTree();
4138 } 4149 }
4139 4150
4140 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4151 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4141 4152
4142 virtual void WillBeginMainFrame() OVERRIDE { 4153 virtual void WillBeginMainFrame() OVERRIDE {
4143 num_will_begin_main_frames_++; 4154 num_will_begin_main_frames_++;
4144 switch (num_will_begin_main_frames_) { 4155 switch (num_will_begin_main_frames_) {
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
4950 public: 4961 public:
4951 LayerTreeHostTestContinuousPainting() 4962 LayerTreeHostTestContinuousPainting()
4952 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} 4963 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {}
4953 4964
4954 protected: 4965 protected:
4955 enum { kExpectedNumCommits = 10 }; 4966 enum { kExpectedNumCommits = 10 };
4956 4967
4957 virtual void SetupTree() OVERRIDE { 4968 virtual void SetupTree() OVERRIDE {
4958 scoped_refptr<Layer> root_layer = Layer::Create(); 4969 scoped_refptr<Layer> root_layer = Layer::Create();
4959 root_layer->SetBounds(bounds_); 4970 root_layer->SetBounds(bounds_);
4971 root_layer->CreateRenderSurface();
4960 4972
4961 if (layer_tree_host()->settings().impl_side_painting) { 4973 if (layer_tree_host()->settings().impl_side_painting) {
4962 picture_layer_ = FakePictureLayer::Create(&client_); 4974 picture_layer_ = FakePictureLayer::Create(&client_);
4963 child_layer_ = picture_layer_.get(); 4975 child_layer_ = picture_layer_.get();
4964 } else { 4976 } else {
4965 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); 4977 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_);
4966 child_layer_ = content_layer_.get(); 4978 child_layer_ = content_layer_.get();
4967 } 4979 }
4968 child_layer_->SetBounds(bounds_); 4980 child_layer_->SetBounds(bounds_);
4969 child_layer_->SetIsDrawable(true); 4981 child_layer_->SetIsDrawable(true);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 const gfx::Size bounds_; 5045 const gfx::Size bounds_;
5034 FakeContentLayerClient client_; 5046 FakeContentLayerClient client_;
5035 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5047 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5036 scoped_refptr<FakePictureLayer> picture_layer_; 5048 scoped_refptr<FakePictureLayer> picture_layer_;
5037 Layer* child_layer_; 5049 Layer* child_layer_;
5038 }; 5050 };
5039 5051
5040 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5052 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5041 5053
5042 } // namespace cc 5054 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698