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 <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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3171 expected_push_properties_child_ = 0; | 3175 expected_push_properties_child_ = 0; |
3172 expected_push_properties_grandchild_ = 0; | 3176 expected_push_properties_grandchild_ = 0; |
3173 expected_push_properties_child2_ = 0; | 3177 expected_push_properties_child2_ = 0; |
3174 expected_push_properties_other_root_ = 0; | 3178 expected_push_properties_other_root_ = 0; |
3175 expected_push_properties_leaf_layer_ = 0; | 3179 expected_push_properties_leaf_layer_ = 0; |
3176 PostSetNeedsCommitToMainThread(); | 3180 PostSetNeedsCommitToMainThread(); |
3177 } | 3181 } |
3178 | 3182 |
3179 void SetupTree() override { | 3183 void SetupTree() override { |
3180 root_ = PushPropertiesCountingLayer::Create(); | 3184 root_ = PushPropertiesCountingLayer::Create(); |
| 3185 root_->CreateRenderSurface(); |
3181 child_ = PushPropertiesCountingLayer::Create(); | 3186 child_ = PushPropertiesCountingLayer::Create(); |
3182 child2_ = PushPropertiesCountingLayer::Create(); | 3187 child2_ = PushPropertiesCountingLayer::Create(); |
3183 grandchild_ = PushPropertiesCountingLayer::Create(); | 3188 grandchild_ = PushPropertiesCountingLayer::Create(); |
3184 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); | 3189 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); |
3185 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); | 3190 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); |
3186 | 3191 |
3187 root_->AddChild(child_); | 3192 root_->AddChild(child_); |
3188 root_->AddChild(child2_); | 3193 root_->AddChild(child2_); |
3189 child_->AddChild(grandchild_); | 3194 child_->AddChild(grandchild_); |
3190 child2_->AddChild(leaf_always_pushing_layer_); | 3195 child2_->AddChild(leaf_always_pushing_layer_); |
3191 | 3196 |
3192 other_root_ = PushPropertiesCountingLayer::Create(); | 3197 other_root_ = PushPropertiesCountingLayer::Create(); |
| 3198 other_root_->CreateRenderSurface(); |
3193 | 3199 |
3194 // Don't set the root layer here. | 3200 // Don't set the root layer here. |
3195 LayerTreeHostTest::SetupTree(); | 3201 LayerTreeHostTest::SetupTree(); |
3196 } | 3202 } |
3197 | 3203 |
3198 void DidCommitAndDrawFrame() override { | 3204 void DidCommitAndDrawFrame() override { |
3199 ++num_commits_; | 3205 ++num_commits_; |
3200 | 3206 |
3201 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); | 3207 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); |
3202 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); | 3208 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3555 RunTestWithImplSidePainting(); | 3561 RunTestWithImplSidePainting(); |
3556 } | 3562 } |
3557 | 3563 |
3558 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed | 3564 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed |
3559 : public LayerTreeHostTest { | 3565 : public LayerTreeHostTest { |
3560 protected: | 3566 protected: |
3561 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3567 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3562 | 3568 |
3563 void SetupTree() override { | 3569 void SetupTree() override { |
3564 root_ = Layer::Create(); | 3570 root_ = Layer::Create(); |
| 3571 root_->CreateRenderSurface(); |
3565 root_->SetBounds(gfx::Size(1, 1)); | 3572 root_->SetBounds(gfx::Size(1, 1)); |
3566 | 3573 |
3567 bool paint_scrollbar = true; | 3574 bool paint_scrollbar = true; |
3568 bool has_thumb = false; | 3575 bool has_thumb = false; |
3569 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3576 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3570 paint_scrollbar, has_thumb, root_->id()); | 3577 paint_scrollbar, has_thumb, root_->id()); |
3571 | 3578 |
3572 root_->AddChild(scrollbar_layer_); | 3579 root_->AddChild(scrollbar_layer_); |
3573 | 3580 |
3574 layer_tree_host()->SetRootLayer(root_); | 3581 layer_tree_host()->SetRootLayer(root_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3611 }; | 3618 }; |
3612 | 3619 |
3613 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); | 3620 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); |
3614 | 3621 |
3615 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { | 3622 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { |
3616 protected: | 3623 protected: |
3617 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3624 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3618 | 3625 |
3619 void SetupTree() override { | 3626 void SetupTree() override { |
3620 root_ = PushPropertiesCountingLayer::Create(); | 3627 root_ = PushPropertiesCountingLayer::Create(); |
| 3628 root_->CreateRenderSurface(); |
3621 child_ = PushPropertiesCountingLayer::Create(); | 3629 child_ = PushPropertiesCountingLayer::Create(); |
3622 root_->AddChild(child_); | 3630 root_->AddChild(child_); |
3623 | 3631 |
3624 layer_tree_host()->SetRootLayer(root_); | 3632 layer_tree_host()->SetRootLayer(root_); |
3625 LayerTreeHostTest::SetupTree(); | 3633 LayerTreeHostTest::SetupTree(); |
3626 } | 3634 } |
3627 | 3635 |
3628 void DidCommitAndDrawFrame() override { | 3636 void DidCommitAndDrawFrame() override { |
3629 switch (layer_tree_host()->source_frame_number()) { | 3637 switch (layer_tree_host()->source_frame_number()) { |
3630 case 0: | 3638 case 0: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3672 expected_push_properties_root_ = 0; | 3680 expected_push_properties_root_ = 0; |
3673 expected_push_properties_child_ = 0; | 3681 expected_push_properties_child_ = 0; |
3674 expected_push_properties_grandchild1_ = 0; | 3682 expected_push_properties_grandchild1_ = 0; |
3675 expected_push_properties_grandchild2_ = 0; | 3683 expected_push_properties_grandchild2_ = 0; |
3676 expected_push_properties_grandchild3_ = 0; | 3684 expected_push_properties_grandchild3_ = 0; |
3677 PostSetNeedsCommitToMainThread(); | 3685 PostSetNeedsCommitToMainThread(); |
3678 } | 3686 } |
3679 | 3687 |
3680 void SetupTree() override { | 3688 void SetupTree() override { |
3681 root_ = PushPropertiesCountingLayer::Create(); | 3689 root_ = PushPropertiesCountingLayer::Create(); |
| 3690 root_->CreateRenderSurface(); |
3682 child_ = PushPropertiesCountingLayer::Create(); | 3691 child_ = PushPropertiesCountingLayer::Create(); |
3683 grandchild1_ = PushPropertiesCountingLayer::Create(); | 3692 grandchild1_ = PushPropertiesCountingLayer::Create(); |
3684 grandchild2_ = PushPropertiesCountingLayer::Create(); | 3693 grandchild2_ = PushPropertiesCountingLayer::Create(); |
3685 grandchild3_ = PushPropertiesCountingLayer::Create(); | 3694 grandchild3_ = PushPropertiesCountingLayer::Create(); |
3686 | 3695 |
3687 root_->AddChild(child_); | 3696 root_->AddChild(child_); |
3688 child_->AddChild(grandchild1_); | 3697 child_->AddChild(grandchild1_); |
3689 child_->AddChild(grandchild2_); | 3698 child_->AddChild(grandchild2_); |
3690 child_->AddChild(grandchild3_); | 3699 child_->AddChild(grandchild3_); |
3691 | 3700 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4225 }; | 4234 }; |
4226 | 4235 |
4227 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 | 4236 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 |
4228 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 4237 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
4229 LayerTreeHostTestIOSurfaceLayerInvalidate); | 4238 LayerTreeHostTestIOSurfaceLayerInvalidate); |
4230 | 4239 |
4231 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { | 4240 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { |
4232 protected: | 4241 protected: |
4233 void SetupTree() override { | 4242 void SetupTree() override { |
4234 root_layer_ = Layer::Create(); | 4243 root_layer_ = Layer::Create(); |
| 4244 root_layer_->CreateRenderSurface(); |
4235 root_layer_->SetPosition(gfx::Point()); | 4245 root_layer_->SetPosition(gfx::Point()); |
4236 root_layer_->SetBounds(gfx::Size(10, 10)); | 4246 root_layer_->SetBounds(gfx::Size(10, 10)); |
4237 | 4247 |
4238 parent_layer_ = SolidColorLayer::Create(); | 4248 parent_layer_ = SolidColorLayer::Create(); |
4239 parent_layer_->SetPosition(gfx::Point()); | 4249 parent_layer_->SetPosition(gfx::Point()); |
4240 parent_layer_->SetBounds(gfx::Size(10, 10)); | 4250 parent_layer_->SetBounds(gfx::Size(10, 10)); |
4241 parent_layer_->SetIsDrawable(true); | 4251 parent_layer_->SetIsDrawable(true); |
4242 root_layer_->AddChild(parent_layer_); | 4252 root_layer_->AddChild(parent_layer_); |
4243 | 4253 |
4244 child_layer_ = SolidColorLayer::Create(); | 4254 child_layer_ = SolidColorLayer::Create(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4333 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { | 4343 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { |
4334 public: | 4344 public: |
4335 LayerTreeHostTestAbortEvictedTextures() | 4345 LayerTreeHostTestAbortEvictedTextures() |
4336 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} | 4346 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} |
4337 | 4347 |
4338 protected: | 4348 protected: |
4339 void SetupTree() override { | 4349 void SetupTree() override { |
4340 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); | 4350 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); |
4341 root_layer->SetBounds(gfx::Size(200, 200)); | 4351 root_layer->SetBounds(gfx::Size(200, 200)); |
4342 root_layer->SetIsDrawable(true); | 4352 root_layer->SetIsDrawable(true); |
| 4353 root_layer->CreateRenderSurface(); |
4343 | 4354 |
4344 layer_tree_host()->SetRootLayer(root_layer); | 4355 layer_tree_host()->SetRootLayer(root_layer); |
4345 LayerTreeHostTest::SetupTree(); | 4356 LayerTreeHostTest::SetupTree(); |
4346 } | 4357 } |
4347 | 4358 |
4348 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4359 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
4349 | 4360 |
4350 void WillBeginMainFrame() override { | 4361 void WillBeginMainFrame() override { |
4351 num_will_begin_main_frames_++; | 4362 num_will_begin_main_frames_++; |
4352 switch (num_will_begin_main_frames_) { | 4363 switch (num_will_begin_main_frames_) { |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5192 public: | 5203 public: |
5193 LayerTreeHostTestContinuousPainting() | 5204 LayerTreeHostTestContinuousPainting() |
5194 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 5205 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} |
5195 | 5206 |
5196 protected: | 5207 protected: |
5197 enum { kExpectedNumCommits = 10 }; | 5208 enum { kExpectedNumCommits = 10 }; |
5198 | 5209 |
5199 void SetupTree() override { | 5210 void SetupTree() override { |
5200 scoped_refptr<Layer> root_layer = Layer::Create(); | 5211 scoped_refptr<Layer> root_layer = Layer::Create(); |
5201 root_layer->SetBounds(bounds_); | 5212 root_layer->SetBounds(bounds_); |
| 5213 root_layer->CreateRenderSurface(); |
5202 | 5214 |
5203 if (layer_tree_host()->settings().impl_side_painting) { | 5215 if (layer_tree_host()->settings().impl_side_painting) { |
5204 picture_layer_ = FakePictureLayer::Create(&client_); | 5216 picture_layer_ = FakePictureLayer::Create(&client_); |
5205 child_layer_ = picture_layer_.get(); | 5217 child_layer_ = picture_layer_.get(); |
5206 } else { | 5218 } else { |
5207 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); | 5219 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); |
5208 child_layer_ = content_layer_.get(); | 5220 child_layer_ = content_layer_.get(); |
5209 } | 5221 } |
5210 child_layer_->SetBounds(bounds_); | 5222 child_layer_->SetBounds(bounds_); |
5211 child_layer_->SetIsDrawable(true); | 5223 child_layer_->SetIsDrawable(true); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6013 | 6025 |
6014 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6026 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
6015 | 6027 |
6016 private: | 6028 private: |
6017 bool did_commit_; | 6029 bool did_commit_; |
6018 }; | 6030 }; |
6019 | 6031 |
6020 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6032 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
6021 | 6033 |
6022 } // namespace cc | 6034 } // namespace cc |
OLD | NEW |