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

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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 626
624 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater); 627 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestUndrawnLayersDamageLater);
625 628
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()) {
637 root_layer_->CreateRenderSurface();
danakj 2014/09/03 19:30:35 nit: can you do this in SetupTree?
awoloszyn 2014/09/09 15:31:37 Done.
638 }
634 639
635 virtual void SetupTree() OVERRIDE { 640 virtual void SetupTree() OVERRIDE {
636 root_layer_->SetIsDrawable(true); 641 root_layer_->SetIsDrawable(true);
637 root_layer_->SetBounds(gfx::Size(20, 20)); 642 root_layer_->SetBounds(gfx::Size(20, 20));
638 layer_tree_host()->SetRootLayer(root_layer_); 643 layer_tree_host()->SetRootLayer(root_layer_);
639 644
640 parent_layer_ = Layer::Create(); 645 parent_layer_ = Layer::Create();
641 parent_layer_->SetBounds(gfx::Size(20, 20)); 646 parent_layer_->SetBounds(gfx::Size(20, 20));
642 parent_layer_->SetOpacity(0.0f); 647 parent_layer_->SetOpacity(0.0f);
643 root_layer_->AddChild(parent_layer_); 648 root_layer_->AddChild(parent_layer_);
(...skipping 2318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2962 expected_push_properties_child_ = 0; 2967 expected_push_properties_child_ = 0;
2963 expected_push_properties_grandchild_ = 0; 2968 expected_push_properties_grandchild_ = 0;
2964 expected_push_properties_child2_ = 0; 2969 expected_push_properties_child2_ = 0;
2965 expected_push_properties_other_root_ = 0; 2970 expected_push_properties_other_root_ = 0;
2966 expected_push_properties_leaf_layer_ = 0; 2971 expected_push_properties_leaf_layer_ = 0;
2967 PostSetNeedsCommitToMainThread(); 2972 PostSetNeedsCommitToMainThread();
2968 } 2973 }
2969 2974
2970 virtual void SetupTree() OVERRIDE { 2975 virtual void SetupTree() OVERRIDE {
2971 root_ = PushPropertiesCountingLayer::Create(); 2976 root_ = PushPropertiesCountingLayer::Create();
2977 root_->CreateRenderSurface();
2972 child_ = PushPropertiesCountingLayer::Create(); 2978 child_ = PushPropertiesCountingLayer::Create();
2973 child2_ = PushPropertiesCountingLayer::Create(); 2979 child2_ = PushPropertiesCountingLayer::Create();
2974 grandchild_ = PushPropertiesCountingLayer::Create(); 2980 grandchild_ = PushPropertiesCountingLayer::Create();
2975 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); 2981 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create();
2976 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); 2982 leaf_always_pushing_layer_->set_persist_needs_push_properties(true);
2977 2983
2978 root_->AddChild(child_); 2984 root_->AddChild(child_);
2979 root_->AddChild(child2_); 2985 root_->AddChild(child2_);
2980 child_->AddChild(grandchild_); 2986 child_->AddChild(grandchild_);
2981 child2_->AddChild(leaf_always_pushing_layer_); 2987 child2_->AddChild(leaf_always_pushing_layer_);
2982 2988
2983 other_root_ = PushPropertiesCountingLayer::Create(); 2989 other_root_ = PushPropertiesCountingLayer::Create();
2990 other_root_->CreateRenderSurface();
2984 2991
2985 // Don't set the root layer here. 2992 // Don't set the root layer here.
2986 LayerTreeHostTest::SetupTree(); 2993 LayerTreeHostTest::SetupTree();
2987 } 2994 }
2988 2995
2989 virtual void DidCommitAndDrawFrame() OVERRIDE { 2996 virtual void DidCommitAndDrawFrame() OVERRIDE {
2990 ++num_commits_; 2997 ++num_commits_;
2991 2998
2992 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); 2999 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count());
2993 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); 3000 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count());
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3346 RunTestWithImplSidePainting(); 3353 RunTestWithImplSidePainting();
3347 } 3354 }
3348 3355
3349 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed 3356 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed
3350 : public LayerTreeHostTest { 3357 : public LayerTreeHostTest {
3351 protected: 3358 protected:
3352 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3359 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
3353 3360
3354 virtual void SetupTree() OVERRIDE { 3361 virtual void SetupTree() OVERRIDE {
3355 root_ = Layer::Create(); 3362 root_ = Layer::Create();
3363 root_->CreateRenderSurface();
3356 root_->SetBounds(gfx::Size(1, 1)); 3364 root_->SetBounds(gfx::Size(1, 1));
3357 3365
3358 bool paint_scrollbar = true; 3366 bool paint_scrollbar = true;
3359 bool has_thumb = false; 3367 bool has_thumb = false;
3360 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( 3368 scrollbar_layer_ = FakePaintedScrollbarLayer::Create(
3361 paint_scrollbar, has_thumb, root_->id()); 3369 paint_scrollbar, has_thumb, root_->id());
3362 3370
3363 root_->AddChild(scrollbar_layer_); 3371 root_->AddChild(scrollbar_layer_);
3364 3372
3365 layer_tree_host()->SetRootLayer(root_); 3373 layer_tree_host()->SetRootLayer(root_);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
3402 }; 3410 };
3403 3411
3404 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); 3412 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed);
3405 3413
3406 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { 3414 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest {
3407 protected: 3415 protected:
3408 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 3416 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
3409 3417
3410 virtual void SetupTree() OVERRIDE { 3418 virtual void SetupTree() OVERRIDE {
3411 root_ = PushPropertiesCountingLayer::Create(); 3419 root_ = PushPropertiesCountingLayer::Create();
3420 root_->CreateRenderSurface();
3412 child_ = PushPropertiesCountingLayer::Create(); 3421 child_ = PushPropertiesCountingLayer::Create();
3413 root_->AddChild(child_); 3422 root_->AddChild(child_);
3414 3423
3415 layer_tree_host()->SetRootLayer(root_); 3424 layer_tree_host()->SetRootLayer(root_);
3416 LayerTreeHostTest::SetupTree(); 3425 LayerTreeHostTest::SetupTree();
3417 } 3426 }
3418 3427
3419 virtual void DidCommitAndDrawFrame() OVERRIDE { 3428 virtual void DidCommitAndDrawFrame() OVERRIDE {
3420 switch (layer_tree_host()->source_frame_number()) { 3429 switch (layer_tree_host()->source_frame_number()) {
3421 case 0: 3430 case 0:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3463 expected_push_properties_root_ = 0; 3472 expected_push_properties_root_ = 0;
3464 expected_push_properties_child_ = 0; 3473 expected_push_properties_child_ = 0;
3465 expected_push_properties_grandchild1_ = 0; 3474 expected_push_properties_grandchild1_ = 0;
3466 expected_push_properties_grandchild2_ = 0; 3475 expected_push_properties_grandchild2_ = 0;
3467 expected_push_properties_grandchild3_ = 0; 3476 expected_push_properties_grandchild3_ = 0;
3468 PostSetNeedsCommitToMainThread(); 3477 PostSetNeedsCommitToMainThread();
3469 } 3478 }
3470 3479
3471 virtual void SetupTree() OVERRIDE { 3480 virtual void SetupTree() OVERRIDE {
3472 root_ = PushPropertiesCountingLayer::Create(); 3481 root_ = PushPropertiesCountingLayer::Create();
3482 root_->CreateRenderSurface();
3473 child_ = PushPropertiesCountingLayer::Create(); 3483 child_ = PushPropertiesCountingLayer::Create();
3474 grandchild1_ = PushPropertiesCountingLayer::Create(); 3484 grandchild1_ = PushPropertiesCountingLayer::Create();
3475 grandchild2_ = PushPropertiesCountingLayer::Create(); 3485 grandchild2_ = PushPropertiesCountingLayer::Create();
3476 grandchild3_ = PushPropertiesCountingLayer::Create(); 3486 grandchild3_ = PushPropertiesCountingLayer::Create();
3477 3487
3478 root_->AddChild(child_); 3488 root_->AddChild(child_);
3479 child_->AddChild(grandchild1_); 3489 child_->AddChild(grandchild1_);
3480 child_->AddChild(grandchild2_); 3490 child_->AddChild(grandchild2_);
3481 child_->AddChild(grandchild3_); 3491 child_->AddChild(grandchild3_);
3482 3492
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
4017 }; 4027 };
4018 4028
4019 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 4029 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335
4020 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( 4030 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F(
4021 LayerTreeHostTestIOSurfaceLayerInvalidate); 4031 LayerTreeHostTestIOSurfaceLayerInvalidate);
4022 4032
4023 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { 4033 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest {
4024 protected: 4034 protected:
4025 virtual void SetupTree() OVERRIDE { 4035 virtual void SetupTree() OVERRIDE {
4026 root_layer_ = Layer::Create(); 4036 root_layer_ = Layer::Create();
4037 root_layer_->CreateRenderSurface();
4027 root_layer_->SetPosition(gfx::Point()); 4038 root_layer_->SetPosition(gfx::Point());
4028 root_layer_->SetBounds(gfx::Size(10, 10)); 4039 root_layer_->SetBounds(gfx::Size(10, 10));
4029 4040
4030 parent_layer_ = SolidColorLayer::Create(); 4041 parent_layer_ = SolidColorLayer::Create();
4031 parent_layer_->SetPosition(gfx::Point()); 4042 parent_layer_->SetPosition(gfx::Point());
4032 parent_layer_->SetBounds(gfx::Size(10, 10)); 4043 parent_layer_->SetBounds(gfx::Size(10, 10));
4033 parent_layer_->SetIsDrawable(true); 4044 parent_layer_->SetIsDrawable(true);
4034 root_layer_->AddChild(parent_layer_); 4045 root_layer_->AddChild(parent_layer_);
4035 4046
4036 child_layer_ = SolidColorLayer::Create(); 4047 child_layer_ = SolidColorLayer::Create();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
4125 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { 4136 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest {
4126 public: 4137 public:
4127 LayerTreeHostTestAbortEvictedTextures() 4138 LayerTreeHostTestAbortEvictedTextures()
4128 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} 4139 : num_will_begin_main_frames_(0), num_impl_commits_(0) {}
4129 4140
4130 protected: 4141 protected:
4131 virtual void SetupTree() OVERRIDE { 4142 virtual void SetupTree() OVERRIDE {
4132 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); 4143 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create();
4133 root_layer->SetBounds(gfx::Size(200, 200)); 4144 root_layer->SetBounds(gfx::Size(200, 200));
4134 root_layer->SetIsDrawable(true); 4145 root_layer->SetIsDrawable(true);
4146 root_layer->CreateRenderSurface();
4135 4147
4136 layer_tree_host()->SetRootLayer(root_layer); 4148 layer_tree_host()->SetRootLayer(root_layer);
4137 LayerTreeHostTest::SetupTree(); 4149 LayerTreeHostTest::SetupTree();
4138 } 4150 }
4139 4151
4140 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } 4152 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
4141 4153
4142 virtual void WillBeginMainFrame() OVERRIDE { 4154 virtual void WillBeginMainFrame() OVERRIDE {
4143 num_will_begin_main_frames_++; 4155 num_will_begin_main_frames_++;
4144 switch (num_will_begin_main_frames_) { 4156 switch (num_will_begin_main_frames_) {
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
4950 public: 4962 public:
4951 LayerTreeHostTestContinuousPainting() 4963 LayerTreeHostTestContinuousPainting()
4952 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} 4964 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {}
4953 4965
4954 protected: 4966 protected:
4955 enum { kExpectedNumCommits = 10 }; 4967 enum { kExpectedNumCommits = 10 };
4956 4968
4957 virtual void SetupTree() OVERRIDE { 4969 virtual void SetupTree() OVERRIDE {
4958 scoped_refptr<Layer> root_layer = Layer::Create(); 4970 scoped_refptr<Layer> root_layer = Layer::Create();
4959 root_layer->SetBounds(bounds_); 4971 root_layer->SetBounds(bounds_);
4972 root_layer->CreateRenderSurface();
4960 4973
4961 if (layer_tree_host()->settings().impl_side_painting) { 4974 if (layer_tree_host()->settings().impl_side_painting) {
4962 picture_layer_ = FakePictureLayer::Create(&client_); 4975 picture_layer_ = FakePictureLayer::Create(&client_);
4963 child_layer_ = picture_layer_.get(); 4976 child_layer_ = picture_layer_.get();
4964 } else { 4977 } else {
4965 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); 4978 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_);
4966 child_layer_ = content_layer_.get(); 4979 child_layer_ = content_layer_.get();
4967 } 4980 }
4968 child_layer_->SetBounds(bounds_); 4981 child_layer_->SetBounds(bounds_);
4969 child_layer_->SetIsDrawable(true); 4982 child_layer_->SetIsDrawable(true);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 const gfx::Size bounds_; 5046 const gfx::Size bounds_;
5034 FakeContentLayerClient client_; 5047 FakeContentLayerClient client_;
5035 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_; 5048 scoped_refptr<ContentLayerWithUpdateTracking> content_layer_;
5036 scoped_refptr<FakePictureLayer> picture_layer_; 5049 scoped_refptr<FakePictureLayer> picture_layer_;
5037 Layer* child_layer_; 5050 Layer* child_layer_;
5038 }; 5051 };
5039 5052
5040 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting); 5053 MULTI_THREAD_TEST_F(LayerTreeHostTestContinuousPainting);
5041 5054
5042 } // namespace cc 5055 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698