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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 474 |
474 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { | 475 class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
475 public: | 476 public: |
476 void InitializeSettings(LayerTreeSettings* settings) override { | 477 void InitializeSettings(LayerTreeSettings* settings) override { |
477 settings->layer_transforms_should_scale_layer_contents = true; | 478 settings->layer_transforms_should_scale_layer_contents = true; |
478 } | 479 } |
479 | 480 |
480 void SetupTree() override { | 481 void SetupTree() override { |
481 root_layer_ = Layer::Create(); | 482 root_layer_ = Layer::Create(); |
482 root_layer_->SetBounds(gfx::Size(10, 20)); | 483 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 484 root_layer_->CreateRenderSurface(); |
483 | 485 |
484 scaled_layer_ = FakeContentLayer::Create(&client_); | 486 scaled_layer_ = FakeContentLayer::Create(&client_); |
485 scaled_layer_->SetBounds(gfx::Size(1, 1)); | 487 scaled_layer_->SetBounds(gfx::Size(1, 1)); |
486 root_layer_->AddChild(scaled_layer_); | 488 root_layer_->AddChild(scaled_layer_); |
487 | 489 |
488 layer_tree_host()->SetRootLayer(root_layer_); | 490 layer_tree_host()->SetRootLayer(root_layer_); |
489 LayerTreeHostTest::SetupTree(); | 491 LayerTreeHostTest::SetupTree(); |
490 } | 492 } |
491 | 493 |
492 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 494 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate | 528 class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
527 : public LayerTreeHostTest { | 529 : public LayerTreeHostTest { |
528 public: | 530 public: |
529 void InitializeSettings(LayerTreeSettings* settings) override { | 531 void InitializeSettings(LayerTreeSettings* settings) override { |
530 settings->layer_transforms_should_scale_layer_contents = true; | 532 settings->layer_transforms_should_scale_layer_contents = true; |
531 } | 533 } |
532 | 534 |
533 void SetupTree() override { | 535 void SetupTree() override { |
534 root_layer_ = Layer::Create(); | 536 root_layer_ = Layer::Create(); |
535 root_layer_->SetBounds(gfx::Size(10, 20)); | 537 root_layer_->SetBounds(gfx::Size(10, 20)); |
| 538 root_layer_->CreateRenderSurface(); |
536 | 539 |
537 bool paint_scrollbar = true; | 540 bool paint_scrollbar = true; |
538 bool has_thumb = false; | 541 bool has_thumb = false; |
539 scrollbar_ = FakePaintedScrollbarLayer::Create( | 542 scrollbar_ = FakePaintedScrollbarLayer::Create( |
540 paint_scrollbar, has_thumb, root_layer_->id()); | 543 paint_scrollbar, has_thumb, root_layer_->id()); |
541 scrollbar_->SetPosition(gfx::Point(0, 10)); | 544 scrollbar_->SetPosition(gfx::Point(0, 10)); |
542 scrollbar_->SetBounds(gfx::Size(10, 10)); | 545 scrollbar_->SetBounds(gfx::Size(10, 10)); |
543 | 546 |
544 root_layer_->AddChild(scrollbar_); | 547 root_layer_->AddChild(scrollbar_); |
545 | 548 |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // Tests that if a layer is not drawn because of some reason in the parent, | 770 // Tests that if a layer is not drawn because of some reason in the parent, |
768 // causing its content bounds to not be computed, then when it is later drawn, | 771 // causing its content bounds to not be computed, then when it is later drawn, |
769 // its content bounds get pushed. | 772 // its content bounds get pushed. |
770 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater | 773 class LayerTreeHostTestUndrawnLayersPushContentBoundsLater |
771 : public LayerTreeHostTest { | 774 : public LayerTreeHostTest { |
772 public: | 775 public: |
773 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() | 776 LayerTreeHostTestUndrawnLayersPushContentBoundsLater() |
774 : root_layer_(Layer::Create()) {} | 777 : root_layer_(Layer::Create()) {} |
775 | 778 |
776 void SetupTree() override { | 779 void SetupTree() override { |
| 780 root_layer_->CreateRenderSurface(); |
777 root_layer_->SetIsDrawable(true); | 781 root_layer_->SetIsDrawable(true); |
778 root_layer_->SetBounds(gfx::Size(20, 20)); | 782 root_layer_->SetBounds(gfx::Size(20, 20)); |
779 layer_tree_host()->SetRootLayer(root_layer_); | 783 layer_tree_host()->SetRootLayer(root_layer_); |
780 | 784 |
781 parent_layer_ = Layer::Create(); | 785 parent_layer_ = Layer::Create(); |
782 parent_layer_->SetBounds(gfx::Size(20, 20)); | 786 parent_layer_->SetBounds(gfx::Size(20, 20)); |
783 parent_layer_->SetOpacity(0.0f); | 787 parent_layer_->SetOpacity(0.0f); |
784 root_layer_->AddChild(parent_layer_); | 788 root_layer_->AddChild(parent_layer_); |
785 | 789 |
786 child_layer_ = Layer::Create(); | 790 child_layer_ = Layer::Create(); |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3109 expected_push_properties_child_ = 0; | 3113 expected_push_properties_child_ = 0; |
3110 expected_push_properties_grandchild_ = 0; | 3114 expected_push_properties_grandchild_ = 0; |
3111 expected_push_properties_child2_ = 0; | 3115 expected_push_properties_child2_ = 0; |
3112 expected_push_properties_other_root_ = 0; | 3116 expected_push_properties_other_root_ = 0; |
3113 expected_push_properties_leaf_layer_ = 0; | 3117 expected_push_properties_leaf_layer_ = 0; |
3114 PostSetNeedsCommitToMainThread(); | 3118 PostSetNeedsCommitToMainThread(); |
3115 } | 3119 } |
3116 | 3120 |
3117 void SetupTree() override { | 3121 void SetupTree() override { |
3118 root_ = PushPropertiesCountingLayer::Create(); | 3122 root_ = PushPropertiesCountingLayer::Create(); |
| 3123 root_->CreateRenderSurface(); |
3119 child_ = PushPropertiesCountingLayer::Create(); | 3124 child_ = PushPropertiesCountingLayer::Create(); |
3120 child2_ = PushPropertiesCountingLayer::Create(); | 3125 child2_ = PushPropertiesCountingLayer::Create(); |
3121 grandchild_ = PushPropertiesCountingLayer::Create(); | 3126 grandchild_ = PushPropertiesCountingLayer::Create(); |
3122 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); | 3127 leaf_always_pushing_layer_ = PushPropertiesCountingLayer::Create(); |
3123 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); | 3128 leaf_always_pushing_layer_->set_persist_needs_push_properties(true); |
3124 | 3129 |
3125 root_->AddChild(child_); | 3130 root_->AddChild(child_); |
3126 root_->AddChild(child2_); | 3131 root_->AddChild(child2_); |
3127 child_->AddChild(grandchild_); | 3132 child_->AddChild(grandchild_); |
3128 child2_->AddChild(leaf_always_pushing_layer_); | 3133 child2_->AddChild(leaf_always_pushing_layer_); |
3129 | 3134 |
3130 other_root_ = PushPropertiesCountingLayer::Create(); | 3135 other_root_ = PushPropertiesCountingLayer::Create(); |
| 3136 other_root_->CreateRenderSurface(); |
3131 | 3137 |
3132 // Don't set the root layer here. | 3138 // Don't set the root layer here. |
3133 LayerTreeHostTest::SetupTree(); | 3139 LayerTreeHostTest::SetupTree(); |
3134 } | 3140 } |
3135 | 3141 |
3136 void DidCommitAndDrawFrame() override { | 3142 void DidCommitAndDrawFrame() override { |
3137 ++num_commits_; | 3143 ++num_commits_; |
3138 | 3144 |
3139 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); | 3145 EXPECT_EQ(expected_push_properties_root_, root_->push_properties_count()); |
3140 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); | 3146 EXPECT_EQ(expected_push_properties_child_, child_->push_properties_count()); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3493 RunTestWithImplSidePainting(); | 3499 RunTestWithImplSidePainting(); |
3494 } | 3500 } |
3495 | 3501 |
3496 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed | 3502 class LayerTreeHostTestPropertyChangesDuringUpdateArePushed |
3497 : public LayerTreeHostTest { | 3503 : public LayerTreeHostTest { |
3498 protected: | 3504 protected: |
3499 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3505 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3500 | 3506 |
3501 void SetupTree() override { | 3507 void SetupTree() override { |
3502 root_ = Layer::Create(); | 3508 root_ = Layer::Create(); |
| 3509 root_->CreateRenderSurface(); |
3503 root_->SetBounds(gfx::Size(1, 1)); | 3510 root_->SetBounds(gfx::Size(1, 1)); |
3504 | 3511 |
3505 bool paint_scrollbar = true; | 3512 bool paint_scrollbar = true; |
3506 bool has_thumb = false; | 3513 bool has_thumb = false; |
3507 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( | 3514 scrollbar_layer_ = FakePaintedScrollbarLayer::Create( |
3508 paint_scrollbar, has_thumb, root_->id()); | 3515 paint_scrollbar, has_thumb, root_->id()); |
3509 | 3516 |
3510 root_->AddChild(scrollbar_layer_); | 3517 root_->AddChild(scrollbar_layer_); |
3511 | 3518 |
3512 layer_tree_host()->SetRootLayer(root_); | 3519 layer_tree_host()->SetRootLayer(root_); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 }; | 3556 }; |
3550 | 3557 |
3551 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); | 3558 MULTI_THREAD_TEST_F(LayerTreeHostTestPropertyChangesDuringUpdateArePushed); |
3552 | 3559 |
3553 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { | 3560 class LayerTreeHostTestSetDrawableCausesCommit : public LayerTreeHostTest { |
3554 protected: | 3561 protected: |
3555 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 3562 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
3556 | 3563 |
3557 void SetupTree() override { | 3564 void SetupTree() override { |
3558 root_ = PushPropertiesCountingLayer::Create(); | 3565 root_ = PushPropertiesCountingLayer::Create(); |
| 3566 root_->CreateRenderSurface(); |
3559 child_ = PushPropertiesCountingLayer::Create(); | 3567 child_ = PushPropertiesCountingLayer::Create(); |
3560 root_->AddChild(child_); | 3568 root_->AddChild(child_); |
3561 | 3569 |
3562 layer_tree_host()->SetRootLayer(root_); | 3570 layer_tree_host()->SetRootLayer(root_); |
3563 LayerTreeHostTest::SetupTree(); | 3571 LayerTreeHostTest::SetupTree(); |
3564 } | 3572 } |
3565 | 3573 |
3566 void DidCommitAndDrawFrame() override { | 3574 void DidCommitAndDrawFrame() override { |
3567 switch (layer_tree_host()->source_frame_number()) { | 3575 switch (layer_tree_host()->source_frame_number()) { |
3568 case 0: | 3576 case 0: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3610 expected_push_properties_root_ = 0; | 3618 expected_push_properties_root_ = 0; |
3611 expected_push_properties_child_ = 0; | 3619 expected_push_properties_child_ = 0; |
3612 expected_push_properties_grandchild1_ = 0; | 3620 expected_push_properties_grandchild1_ = 0; |
3613 expected_push_properties_grandchild2_ = 0; | 3621 expected_push_properties_grandchild2_ = 0; |
3614 expected_push_properties_grandchild3_ = 0; | 3622 expected_push_properties_grandchild3_ = 0; |
3615 PostSetNeedsCommitToMainThread(); | 3623 PostSetNeedsCommitToMainThread(); |
3616 } | 3624 } |
3617 | 3625 |
3618 void SetupTree() override { | 3626 void SetupTree() override { |
3619 root_ = PushPropertiesCountingLayer::Create(); | 3627 root_ = PushPropertiesCountingLayer::Create(); |
| 3628 root_->CreateRenderSurface(); |
3620 child_ = PushPropertiesCountingLayer::Create(); | 3629 child_ = PushPropertiesCountingLayer::Create(); |
3621 grandchild1_ = PushPropertiesCountingLayer::Create(); | 3630 grandchild1_ = PushPropertiesCountingLayer::Create(); |
3622 grandchild2_ = PushPropertiesCountingLayer::Create(); | 3631 grandchild2_ = PushPropertiesCountingLayer::Create(); |
3623 grandchild3_ = PushPropertiesCountingLayer::Create(); | 3632 grandchild3_ = PushPropertiesCountingLayer::Create(); |
3624 | 3633 |
3625 root_->AddChild(child_); | 3634 root_->AddChild(child_); |
3626 child_->AddChild(grandchild1_); | 3635 child_->AddChild(grandchild1_); |
3627 child_->AddChild(grandchild2_); | 3636 child_->AddChild(grandchild2_); |
3628 child_->AddChild(grandchild3_); | 3637 child_->AddChild(grandchild3_); |
3629 | 3638 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4163 }; | 4172 }; |
4164 | 4173 |
4165 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 | 4174 // TODO(danakj): IOSurface layer can not be transported. crbug.com/239335 |
4166 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 4175 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
4167 LayerTreeHostTestIOSurfaceLayerInvalidate); | 4176 LayerTreeHostTestIOSurfaceLayerInvalidate); |
4168 | 4177 |
4169 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { | 4178 class LayerTreeHostTestPushHiddenLayer : public LayerTreeHostTest { |
4170 protected: | 4179 protected: |
4171 void SetupTree() override { | 4180 void SetupTree() override { |
4172 root_layer_ = Layer::Create(); | 4181 root_layer_ = Layer::Create(); |
| 4182 root_layer_->CreateRenderSurface(); |
4173 root_layer_->SetPosition(gfx::Point()); | 4183 root_layer_->SetPosition(gfx::Point()); |
4174 root_layer_->SetBounds(gfx::Size(10, 10)); | 4184 root_layer_->SetBounds(gfx::Size(10, 10)); |
4175 | 4185 |
4176 parent_layer_ = SolidColorLayer::Create(); | 4186 parent_layer_ = SolidColorLayer::Create(); |
4177 parent_layer_->SetPosition(gfx::Point()); | 4187 parent_layer_->SetPosition(gfx::Point()); |
4178 parent_layer_->SetBounds(gfx::Size(10, 10)); | 4188 parent_layer_->SetBounds(gfx::Size(10, 10)); |
4179 parent_layer_->SetIsDrawable(true); | 4189 parent_layer_->SetIsDrawable(true); |
4180 root_layer_->AddChild(parent_layer_); | 4190 root_layer_->AddChild(parent_layer_); |
4181 | 4191 |
4182 child_layer_ = SolidColorLayer::Create(); | 4192 child_layer_ = SolidColorLayer::Create(); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4271 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { | 4281 class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { |
4272 public: | 4282 public: |
4273 LayerTreeHostTestAbortEvictedTextures() | 4283 LayerTreeHostTestAbortEvictedTextures() |
4274 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} | 4284 : num_will_begin_main_frames_(0), num_impl_commits_(0) {} |
4275 | 4285 |
4276 protected: | 4286 protected: |
4277 void SetupTree() override { | 4287 void SetupTree() override { |
4278 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); | 4288 scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); |
4279 root_layer->SetBounds(gfx::Size(200, 200)); | 4289 root_layer->SetBounds(gfx::Size(200, 200)); |
4280 root_layer->SetIsDrawable(true); | 4290 root_layer->SetIsDrawable(true); |
| 4291 root_layer->CreateRenderSurface(); |
4281 | 4292 |
4282 layer_tree_host()->SetRootLayer(root_layer); | 4293 layer_tree_host()->SetRootLayer(root_layer); |
4283 LayerTreeHostTest::SetupTree(); | 4294 LayerTreeHostTest::SetupTree(); |
4284 } | 4295 } |
4285 | 4296 |
4286 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4297 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
4287 | 4298 |
4288 void WillBeginMainFrame() override { | 4299 void WillBeginMainFrame() override { |
4289 num_will_begin_main_frames_++; | 4300 num_will_begin_main_frames_++; |
4290 switch (num_will_begin_main_frames_) { | 4301 switch (num_will_begin_main_frames_) { |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5081 public: | 5092 public: |
5082 LayerTreeHostTestContinuousPainting() | 5093 LayerTreeHostTestContinuousPainting() |
5083 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} | 5094 : num_commits_(0), num_draws_(0), bounds_(20, 20), child_layer_(NULL) {} |
5084 | 5095 |
5085 protected: | 5096 protected: |
5086 enum { kExpectedNumCommits = 10 }; | 5097 enum { kExpectedNumCommits = 10 }; |
5087 | 5098 |
5088 void SetupTree() override { | 5099 void SetupTree() override { |
5089 scoped_refptr<Layer> root_layer = Layer::Create(); | 5100 scoped_refptr<Layer> root_layer = Layer::Create(); |
5090 root_layer->SetBounds(bounds_); | 5101 root_layer->SetBounds(bounds_); |
| 5102 root_layer->CreateRenderSurface(); |
5091 | 5103 |
5092 if (layer_tree_host()->settings().impl_side_painting) { | 5104 if (layer_tree_host()->settings().impl_side_painting) { |
5093 picture_layer_ = FakePictureLayer::Create(&client_); | 5105 picture_layer_ = FakePictureLayer::Create(&client_); |
5094 child_layer_ = picture_layer_.get(); | 5106 child_layer_ = picture_layer_.get(); |
5095 } else { | 5107 } else { |
5096 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); | 5108 content_layer_ = ContentLayerWithUpdateTracking::Create(&client_); |
5097 child_layer_ = content_layer_.get(); | 5109 child_layer_ = content_layer_.get(); |
5098 } | 5110 } |
5099 child_layer_->SetBounds(bounds_); | 5111 child_layer_->SetBounds(bounds_); |
5100 child_layer_->SetIsDrawable(true); | 5112 child_layer_->SetIsDrawable(true); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5348 void AfterTest() override { | 5360 void AfterTest() override { |
5349 EXPECT_TRUE(deltas_sent_to_client_); | 5361 EXPECT_TRUE(deltas_sent_to_client_); |
5350 } | 5362 } |
5351 | 5363 |
5352 ScrollAndScaleSet info_; | 5364 ScrollAndScaleSet info_; |
5353 bool deltas_sent_to_client_; | 5365 bool deltas_sent_to_client_; |
5354 }; | 5366 }; |
5355 | 5367 |
5356 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); | 5368 MULTI_THREAD_TEST_F(LayerTreeHostAcceptsDeltasFromImplWithoutRootLayer); |
5357 } // namespace cc | 5369 } // namespace cc |
OLD | NEW |