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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 int num_draws_; | 281 int num_draws_; |
282 }; | 282 }; |
283 | 283 |
284 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); | 284 MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit2); |
285 | 285 |
286 // Verify that we pass property values in PushPropertiesTo. | 286 // Verify that we pass property values in PushPropertiesTo. |
287 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { | 287 class LayerTreeHostTestPushPropertiesTo : public LayerTreeHostTest { |
288 protected: | 288 protected: |
289 void SetupTree() override { | 289 void SetupTree() override { |
290 scoped_refptr<Layer> root = Layer::Create(); | 290 scoped_refptr<Layer> root = Layer::Create(); |
| 291 root->CreateRenderSurface(); |
291 root->SetBounds(gfx::Size(10, 10)); | 292 root->SetBounds(gfx::Size(10, 10)); |
292 layer_tree_host()->SetRootLayer(root); | 293 layer_tree_host()->SetRootLayer(root); |
293 LayerTreeHostTest::SetupTree(); | 294 LayerTreeHostTest::SetupTree(); |
294 } | 295 } |
295 | 296 |
296 enum Properties { | 297 enum Properties { |
297 STARTUP, | 298 STARTUP, |
298 BOUNDS, | 299 BOUNDS, |
299 HIDE_LAYER_AND_SUBTREE, | 300 HIDE_LAYER_AND_SUBTREE, |
300 DRAWS_CONTENT, | 301 DRAWS_CONTENT, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 | 475 |
475 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 476 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
476 public: | 477 public: |
477 void InitializeSettings(LayerTreeSettings* settings) override { | 478 void InitializeSettings(LayerTreeSettings* settings) override { |
478 settings->layer_transforms_should_scale_layer_contents = true; | 479 settings->layer_transforms_should_scale_layer_contents = true; |
479 } | 480 } |
480 | 481 |
481 void SetupTree() override { | 482 void SetupTree() override { |
482 root_layer_ = Layer::Create(); | 483 root_layer_ = Layer::Create(); |
483 root_layer_->SetBounds(gfx::Size(10, 20)); | 484 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 485 root_layer_->CreateRenderSurface(); |
484 | 486 |
485 if (layer_tree_host()->settings().impl_side_painting) | 487 if (layer_tree_host()->settings().impl_side_painting) |
486 scaled_layer_ = FakePictureLayer::Create(&client_); | 488 scaled_layer_ = FakePictureLayer::Create(&client_); |
487 else | 489 else |
488 scaled_layer_ = FakeContentLayer::Create(&client_); | 490 scaled_layer_ = FakeContentLayer::Create(&client_); |
489 scaled_layer_->SetBounds(gfx::Size(1, 1)); | 491 scaled_layer_->SetBounds(gfx::Size(1, 1)); |
490 root_layer_->AddChild(scaled_layer_); | 492 root_layer_->AddChild(scaled_layer_); |
491 | 493 |
492 layer_tree_host()->SetRootLayer(root_layer_); | 494 layer_tree_host()->SetRootLayer(root_layer_); |
493 LayerTreeHostTest::SetupTree(); | 495 LayerTreeHostTest::SetupTree(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate | 537 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
536 : public LayerTreeHostTest { | 538 : public LayerTreeHostTest { |
537 public: | 539 public: |
538 void InitializeSettings(LayerTreeSettings* settings) override { | 540 void InitializeSettings(LayerTreeSettings* settings) override { |
539 settings->layer_transforms_should_scale_layer_contents = true; | 541 settings->layer_transforms_should_scale_layer_contents = true; |
540 } | 542 } |
541 | 543 |
542 void SetupTree() override { | 544 void SetupTree() override { |
543 root_layer_ = Layer::Create(); | 545 root_layer_ = Layer::Create(); |
544 root_layer_->SetBounds(gfx::Size(10, 20)); | 546 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 547 root_layer_->CreateRenderSurface(); |
545 | 548 |
546 bool paint_scrollbar = true; | 549 bool paint_scrollbar = true; |
547 bool has_thumb = false; | 550 bool has_thumb = false; |
548 scrollbar_ = FakePaintedScrollbarLayer::Create( | 551 scrollbar_ = FakePaintedScrollbarLayer::Create( |
549 paint_scrollbar, has_thumb, root_layer_->id()); | 552 paint_scrollbar, has_thumb, root_layer_->id()); |
550 scrollbar_->SetPosition(gfx::Point(0, 10)); | 553 scrollbar_->SetPosition(gfx::Point(0, 10)); |
551 scrollbar_->SetBounds(gfx::Size(10, 10)); | 554 scrollbar_->SetBounds(gfx::Size(10, 10)); |
552 | 555 |
553 root_layer_->AddChild(scrollbar_); | 556 root_layer_->AddChild(scrollbar_); |
554 | 557 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 // Tests that if a layer is not drawn because of some reason in the parent, | 789 // Tests that if a layer is not drawn because of some reason in the parent, |
787 // causing its content bounds to not be computed, then when it is later drawn, | 790 // causing its content bounds to not be computed, then when it is later drawn, |
788 // its content bounds get pushed. | 791 // its content bounds get pushed. |
789 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater | 792 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater |
790 : public LayerTreeHostTest { | 793 : public LayerTreeHostTest { |
791 public: | 794 public: |
792 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() | 795 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() |
793 : root_layer_(Layer::Create()) {} | 796 : root_layer_(Layer::Create()) {} |
794 | 797 |
795 void SetupTree() override { | 798 void SetupTree() override { |
| 799 root_layer_->CreateRenderSurface(); |
796 root_layer_->SetIsDrawable(true); | 800 root_layer_->SetIsDrawable(true); |
797 root_layer_->SetBounds(gfx::Size(20, 20)); | 801 root_layer_->SetBounds(gfx::Size(20, 20)); |
798 layer_tree_host()->SetRootLayer(root_layer_); | 802 layer_tree_host()->SetRootLayer(root_layer_); |
799 | 803 |
800 parent_layer_ = Layer::Create(); | 804 parent_layer_ = Layer::Create(); |
801 parent_layer_->SetBounds(gfx::Size(20, 20)); | 805 parent_layer_->SetBounds(gfx::Size(20, 20)); |
802 parent_layer_->SetOpacity(0.0f); | 806 parent_layer_->SetOpacity(0.0f); |
803 root_layer_->AddChild(parent_layer_); | 807 root_layer_->AddChild(parent_layer_); |
804 | 808 |
805 child_layer_ = Layer::Create(); | 809 child_layer_ = Layer::Create(); |
(...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3169 expected_push_properties_child_ = 0; | 3173 expected_push_properties_child_ = 0; |
3170 expected_push_properties_grandchild_ = 0; | 3174 expected_push_properties_grandchild_ = 0; |
3171 expected_push_properties_child2_ = 0; | 3175 expected_push_properties_child2_ = 0; |
3172 expected_push_properties_other_root_ = 0; | 3176 expected_push_properties_other_root_ = 0; |
3173 expected_push_properties_leaf_layer_ = 0; | 3177 expected_push_properties_leaf_layer_ = 0; |
3174 PostSetNeedsCommitToMainThread(); | 3178 PostSetNeedsCommitToMainThread(); |
3175 } | 3179 } |
3176 | 3180 |
3177 void SetupTree() override { | 3181 void SetupTree() override { |
3178 root_ = PushPropertiesCountingLayer::Create(); | 3182 root_ = PushPropertiesCountingLayer::Create(); |
| 3183 root_->CreateRenderSurface(); |
3179 child_ = PushPropertiesCountingLayer::Create(); | 3184 child_ = PushPropertiesCountingLayer::Create(); |
3180 child2_ = PushPropertiesCountingLayer::Create(); | 3185 child2_ = PushPropertiesCountingLayer::Create(); |
3181 grandchild_ = PushPropertiesCountingLayer::Create(); | 3186 grandchild_ = PushPropertiesCountingLayer::Create(); |
3182 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); | 3187 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); |
3183 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); | 3188 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); |
3184 | 3189 |
3185 root_->AddChild(child_); | 3190 root_->AddChild(child_); |
3186 root_->AddChild(child2_); | 3191 root_->AddChild(child2_); |
3187 child_->AddChild(grandchild_); | 3192 child_->AddChild(grandchild_); |
3188 child2_->AddChild(leaf_always_pushing_layer_); | 3193 child2_->AddChild(leaf_always_pushing_layer_); |
3189 | 3194 |
3190 other_root_ = PushPropertiesCountingLayer::Create(); | 3195 other_root_ = PushPropertiesCountingLayer::Create(); |
| 3196 other_root_->CreateRenderSurface(); |
3191 | 3197 |
3192 // Don't set the root layer here. | 3198 // Don't set the root layer here. |
3193 LayerTreeHostTest::SetupTree(); | 3199 LayerTreeHostTest::SetupTree(); |
3194 } | 3200 } |
3195 | 3201 |
3196 void DidCommitAndDrawFrame() override { | 3202 void DidCommitAndDrawFrame() override { |
3197 ++num_commits_; | 3203 ++num_commits_; |
3198 | 3204 |
3199 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); | 3205 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); |
3200 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); | 3206 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3553 RunTestWithImplSidePainting(); | 3559 RunTestWithImplSidePainting(); |
3554 } | 3560 } |
3555 | 3561 |
3556 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed | 3562 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed |
3557 : public LayerTreeHostTest { | 3563 : public LayerTreeHostTest { |
3558 protected: | 3564 protected: |
3559 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3565 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3560 | 3566 |
3561 void SetupTree() override { | 3567 void SetupTree() override { |
3562 root_ = Layer::Create(); | 3568 root_ = Layer::Create(); |
| 3569 root_->CreateRenderSurface(); |
3563 root_->SetBounds(gfx::Size(1, 1)); | 3570 root_->SetBounds(gfx::Size(1, 1)); |
3564 | 3571 |
3565 bool paint_scrollbar = true; | 3572 bool paint_scrollbar = true; |
3566 bool has_thumb = false; | 3573 bool has_thumb = false; |
3567 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3574 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3568 paint_scrollbar, has_thumb, root_->id()); | 3575 paint_scrollbar, has_thumb, root_->id()); |
3569 | 3576 |
3570 root_->AddChild(scrollbar_layer_); | 3577 root_->AddChild(scrollbar_layer_); |
3571 | 3578 |
3572 layer_tree_host()->SetRootLayer(root_); | 3579 layer_tree_host()->SetRootLayer(root_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3609 }; | 3616 }; |
3610 | 3617 |
3611 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); | 3618 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); |
3612 | 3619 |
3613 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { | 3620 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { |
3614 protected: | 3621 protected: |
3615 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3622 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3616 | 3623 |
3617 void SetupTree() override { | 3624 void SetupTree() override { |
3618 root_ = PushPropertiesCountingLayer::Create(); | 3625 root_ = PushPropertiesCountingLayer::Create(); |
| 3626 root_->CreateRenderSurface(); |
3619 child_ = PushPropertiesCountingLayer::Create(); | 3627 child_ = PushPropertiesCountingLayer::Create(); |
3620 root_->AddChild(child_); | 3628 root_->AddChild(child_); |
3621 | 3629 |
3622 layer_tree_host()->SetRootLayer(root_); | 3630 layer_tree_host()->SetRootLayer(root_); |
3623 LayerTreeHostTest::SetupTree(); | 3631 LayerTreeHostTest::SetupTree(); |
3624 } | 3632 } |
3625 | 3633 |
3626 void DidCommitAndDrawFrame() override { | 3634 void DidCommitAndDrawFrame() override { |
3627 switch (layer_tree_host()->source_frame_number()) { | 3635 switch (layer_tree_host()->source_frame_number()) { |
3628 case 0: | 3636 case 0: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3670 expected_push_properties_root_ = 0; | 3678 expected_push_properties_root_ = 0; |
3671 expected_push_properties_child_ = 0; | 3679 expected_push_properties_child_ = 0; |
3672 expected_push_properties_grandchild1_ = 0; | 3680 expected_push_properties_grandchild1_ = 0; |
3673 expected_push_properties_grandchild2_ = 0; | 3681 expected_push_properties_grandchild2_ = 0; |
3674 expected_push_properties_grandchild3_ = 0; | 3682 expected_push_properties_grandchild3_ = 0; |
3675 PostSetNeedsCommitToMainThread(); | 3683 PostSetNeedsCommitToMainThread(); |
3676 } | 3684 } |
3677 | 3685 |
3678 void SetupTree() override { | 3686 void SetupTree() override { |
3679 root_ = PushPropertiesCountingLayer::Create(); | 3687 root_ = PushPropertiesCountingLayer::Create(); |
| 3688 root_->CreateRenderSurface(); |
3680 child_ = PushPropertiesCountingLayer::Create(); | 3689 child_ = PushPropertiesCountingLayer::Create(); |
3681 grandchild1_ = PushPropertiesCountingLayer::Create(); | 3690 grandchild1_ = PushPropertiesCountingLayer::Create(); |
3682 grandchild2_ = PushPropertiesCountingLayer::Create(); | 3691 grandchild2_ = PushPropertiesCountingLayer::Create(); |
3683 grandchild3_ = PushPropertiesCountingLayer::Create(); | 3692 grandchild3_ = PushPropertiesCountingLayer::Create(); |
3684 | 3693 |
3685 root_->AddChild(child_); | 3694 root_->AddChild(child_); |
3686 child_->AddChild(grandchild1_); | 3695 child_->AddChild(grandchild1_); |
3687 child_->AddChild(grandchild2_); | 3696 child_->AddChild(grandchild2_); |
3688 child_->AddChild(grandchild3_); | 3697 child_->AddChild(grandchild3_); |
3689 | 3698 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4201 }; | 4210 }; |
4202 | 4211 |
4203 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 | 4212 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 |
4204 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 4213 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
4205 LayerTreeHostTestIOSurfaceLayerInvalidate); | 4214 LayerTreeHostTestIOSurfaceLayerInvalidate); |
4206 | 4215 |
4207 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { | 4216 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { |
4208 protected: | 4217 protected: |
4209 void SetupTree() override { | 4218 void SetupTree() override { |
4210 root_layer_ = Layer::Create(); | 4219 root_layer_ = Layer::Create(); |
| 4220 root_layer_->CreateRenderSurface(); |
4211 root_layer_->SetPosition(gfx::Point()); | 4221 root_layer_->SetPosition(gfx::Point()); |
4212 root_layer_->SetBounds(gfx::Size(10, 10)); | 4222 root_layer_->SetBounds(gfx::Size(10, 10)); |
4213 | 4223 |
4214 parent_layer_ = SolidColorLayer::Create(); | 4224 parent_layer_ = SolidColorLayer::Create(); |
4215 parent_layer_->SetPosition(gfx::Point()); | 4225 parent_layer_->SetPosition(gfx::Point()); |
4216 parent_layer_->SetBounds(gfx::Size(10, 10)); | 4226 parent_layer_->SetBounds(gfx::Size(10, 10)); |
4217 parent_layer_->SetIsDrawable(true); | 4227 parent_layer_->SetIsDrawable(true); |
4218 root_layer_->AddChild(parent_layer_); | 4228 root_layer_->AddChild(parent_layer_); |
4219 | 4229 |
4220 child_layer_ = SolidColorLayer::Create(); | 4230 child_layer_ = SolidColorLayer::Create(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4309 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { | 4319 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { |
4310 public: | 4320 public: |
4311 LayerTreeHostTestAbortEvictedTextures() | 4321 LayerTreeHostTestAbortEvictedTextures() |
4312 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} | 4322 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} |
4313 | 4323 |
4314 protected: | 4324 protected: |
4315 void SetupTree() override { | 4325 void SetupTree() override { |
4316 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); | 4326 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); |
4317 root_layer->SetBounds(gfx::Size(200, 200)); | 4327 root_layer->SetBounds(gfx::Size(200, 200)); |
4318 root_layer->SetIsDrawable(true); | 4328 root_layer->SetIsDrawable(true); |
| 4329 root_layer->CreateRenderSurface(); |
4319 | 4330 |
4320 layer_tree_host()->SetRootLayer(root_layer); | 4331 layer_tree_host()->SetRootLayer(root_layer); |
4321 LayerTreeHostTest::SetupTree(); | 4332 LayerTreeHostTest::SetupTree(); |
4322 } | 4333 } |
4323 | 4334 |
4324 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4335 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
4325 | 4336 |
4326 void WillBeginMainFrame() override { | 4337 void WillBeginMainFrame() override { |
4327 num_will_begin_main_frames_++; | 4338 num_will_begin_main_frames_++; |
4328 switch (num_will_begin_main_frames_) { | 4339 switch (num_will_begin_main_frames_) { |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5168 public: | 5179 public: |
5169 LayerTreeHostTestContinuousPainting() | 5180 LayerTreeHostTestContinuousPainting() |
5170 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 5181 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} |
5171 | 5182 |
5172 protected: | 5183 protected: |
5173 enum { kExpectedNumCommits = 10 }; | 5184 enum { kExpectedNumCommits = 10 }; |
5174 | 5185 |
5175 void SetupTree() override { | 5186 void SetupTree() override { |
5176 scoped_refptr<Layer> root_layer = Layer::Create(); | 5187 scoped_refptr<Layer> root_layer = Layer::Create(); |
5177 root_layer->SetBounds(bounds_); | 5188 root_layer->SetBounds(bounds_); |
| 5189 root_layer->CreateRenderSurface(); |
5178 | 5190 |
5179 if (layer_tree_host()->settings().impl_side_painting) { | 5191 if (layer_tree_host()->settings().impl_side_painting) { |
5180 picture_layer_ = FakePictureLayer::Create(&client_); | 5192 picture_layer_ = FakePictureLayer::Create(&client_); |
5181 child_layer_ = picture_layer_.get(); | 5193 child_layer_ = picture_layer_.get(); |
5182 } else { | 5194 } else { |
5183 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); | 5195 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); |
5184 child_layer_ = content_layer_.get(); | 5196 child_layer_ = content_layer_.get(); |
5185 } | 5197 } |
5186 child_layer_->SetBounds(bounds_); | 5198 child_layer_->SetBounds(bounds_); |
5187 child_layer_->SetIsDrawable(true); | 5199 child_layer_->SetIsDrawable(true); |
(...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5989 | 6001 |
5990 void AfterTest() override { EXPECT_TRUE(did_commit_); } | 6002 void AfterTest() override { EXPECT_TRUE(did_commit_); } |
5991 | 6003 |
5992 private: | 6004 private: |
5993 bool did_commit_; | 6005 bool did_commit_; |
5994 }; | 6006 }; |
5995 | 6007 |
5996 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); | 6008 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
5997 | 6009 |
5998 } // namespace cc | 6010 } // namespace cc |
OLD | NEW |