| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 root->SetBounds(gfx::Size(20, 20)); | 36 root->SetBounds(gfx::Size(20, 20)); |
| 37 | 37 |
| 38 child = FakePictureLayer::Create(&client_); | 38 child = FakePictureLayer::Create(&client_); |
| 39 child->SetBounds(gfx::Size(10, 10)); | 39 child->SetBounds(gfx::Size(10, 10)); |
| 40 root->AddChild(child); | 40 root->AddChild(child); |
| 41 | 41 |
| 42 grand_child = FakePictureLayer::Create(&client_); | 42 grand_child = FakePictureLayer::Create(&client_); |
| 43 grand_child->SetBounds(gfx::Size(5, 5)); | 43 grand_child->SetBounds(gfx::Size(5, 5)); |
| 44 child->AddChild(grand_child); | 44 child->AddChild(grand_child); |
| 45 | 45 |
| 46 layer_tree()->SetRootLayer(root); | 46 layer_tree_host()->SetRootLayer(root); |
| 47 LayerTreeHostCopyRequestTest::SetupTree(); | 47 LayerTreeHostCopyRequestTest::SetupTree(); |
| 48 client_.set_bounds(root->bounds()); | 48 client_.set_bounds(root->bounds()); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 51 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 52 | 52 |
| 53 void DidCommit() override { WaitForCallback(); } | 53 void DidCommit() override { WaitForCallback(); } |
| 54 | 54 |
| 55 void WaitForCallback() { | 55 void WaitForCallback() { |
| 56 base::ThreadTaskRunnerHandle::Get()->PostTask( | 56 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 : public LayerTreeHostCopyRequestTest { | 197 : public LayerTreeHostCopyRequestTest { |
| 198 protected: | 198 protected: |
| 199 void SetupTree() override { | 199 void SetupTree() override { |
| 200 root_ = FakePictureLayer::Create(&client_); | 200 root_ = FakePictureLayer::Create(&client_); |
| 201 root_->SetBounds(gfx::Size(20, 20)); | 201 root_->SetBounds(gfx::Size(20, 20)); |
| 202 | 202 |
| 203 layer_ = FakePictureLayer::Create(&client_); | 203 layer_ = FakePictureLayer::Create(&client_); |
| 204 layer_->SetBounds(gfx::Size(15, 15)); | 204 layer_->SetBounds(gfx::Size(15, 15)); |
| 205 root_->AddChild(layer_); | 205 root_->AddChild(layer_); |
| 206 | 206 |
| 207 layer_tree()->SetRootLayer(root_); | 207 layer_tree_host()->SetRootLayer(root_); |
| 208 LayerTreeHostCopyRequestTest::SetupTree(); | 208 LayerTreeHostCopyRequestTest::SetupTree(); |
| 209 client_.set_bounds(root_->bounds()); | 209 client_.set_bounds(root_->bounds()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void BeginTest() override { | 212 void BeginTest() override { |
| 213 PostSetNeedsCommitToMainThread(); | 213 PostSetNeedsCommitToMainThread(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 void DidCommit() override { | 216 void DidCommit() override { |
| 217 int frame = layer_tree_host()->source_frame_number(); | 217 int frame = layer_tree_host()->source_frame_number(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 root_->SetBounds(gfx::Size(20, 20)); | 252 root_->SetBounds(gfx::Size(20, 20)); |
| 253 | 253 |
| 254 main_destroyed_ = FakePictureLayer::Create(&client_); | 254 main_destroyed_ = FakePictureLayer::Create(&client_); |
| 255 main_destroyed_->SetBounds(gfx::Size(15, 15)); | 255 main_destroyed_->SetBounds(gfx::Size(15, 15)); |
| 256 root_->AddChild(main_destroyed_); | 256 root_->AddChild(main_destroyed_); |
| 257 | 257 |
| 258 impl_destroyed_ = FakePictureLayer::Create(&client_); | 258 impl_destroyed_ = FakePictureLayer::Create(&client_); |
| 259 impl_destroyed_->SetBounds(gfx::Size(10, 10)); | 259 impl_destroyed_->SetBounds(gfx::Size(10, 10)); |
| 260 root_->AddChild(impl_destroyed_); | 260 root_->AddChild(impl_destroyed_); |
| 261 | 261 |
| 262 layer_tree()->SetRootLayer(root_); | 262 layer_tree_host()->SetRootLayer(root_); |
| 263 LayerTreeHostCopyRequestTest::SetupTree(); | 263 LayerTreeHostCopyRequestTest::SetupTree(); |
| 264 client_.set_bounds(root_->bounds()); | 264 client_.set_bounds(root_->bounds()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 void BeginTest() override { | 267 void BeginTest() override { |
| 268 callback_count_ = 0; | 268 callback_count_ = 0; |
| 269 PostSetNeedsCommitToMainThread(); | 269 PostSetNeedsCommitToMainThread(); |
| 270 } | 270 } |
| 271 | 271 |
| 272 void DidCommit() override { | 272 void DidCommit() override { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 284 EXPECT_EQ(0, callback_count_); | 284 EXPECT_EQ(0, callback_count_); |
| 285 | 285 |
| 286 // Destroy the main thread layer right away. | 286 // Destroy the main thread layer right away. |
| 287 main_destroyed_->RemoveFromParent(); | 287 main_destroyed_->RemoveFromParent(); |
| 288 main_destroyed_ = NULL; | 288 main_destroyed_ = NULL; |
| 289 | 289 |
| 290 // Should callback with a NULL bitmap. | 290 // Should callback with a NULL bitmap. |
| 291 EXPECT_EQ(1, callback_count_); | 291 EXPECT_EQ(1, callback_count_); |
| 292 | 292 |
| 293 // Prevent drawing so we can't make a copy of the impl_destroyed layer. | 293 // Prevent drawing so we can't make a copy of the impl_destroyed layer. |
| 294 layer_tree()->SetViewportSize(gfx::Size()); | 294 layer_tree_host()->SetViewportSize(gfx::Size()); |
| 295 break; | 295 break; |
| 296 case 2: | 296 case 2: |
| 297 // Flush the message loops and make sure the callbacks run. | 297 // Flush the message loops and make sure the callbacks run. |
| 298 layer_tree_host()->SetNeedsCommit(); | 298 layer_tree_host()->SetNeedsCommit(); |
| 299 break; | 299 break; |
| 300 case 3: | 300 case 3: |
| 301 // No drawing means no readback yet. | 301 // No drawing means no readback yet. |
| 302 EXPECT_EQ(1, callback_count_); | 302 EXPECT_EQ(1, callback_count_); |
| 303 | 303 |
| 304 // Destroy the impl thread layer. | 304 // Destroy the impl thread layer. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 // parent_layer_ owns a render surface. | 351 // parent_layer_ owns a render surface. |
| 352 parent_layer_ = FakePictureLayer::Create(&client_); | 352 parent_layer_ = FakePictureLayer::Create(&client_); |
| 353 parent_layer_->SetBounds(gfx::Size(15, 15)); | 353 parent_layer_->SetBounds(gfx::Size(15, 15)); |
| 354 parent_layer_->SetForceRenderSurfaceForTesting(true); | 354 parent_layer_->SetForceRenderSurfaceForTesting(true); |
| 355 grand_parent_layer_->AddChild(parent_layer_); | 355 grand_parent_layer_->AddChild(parent_layer_); |
| 356 | 356 |
| 357 copy_layer_ = FakePictureLayer::Create(&client_); | 357 copy_layer_ = FakePictureLayer::Create(&client_); |
| 358 copy_layer_->SetBounds(gfx::Size(10, 10)); | 358 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 359 parent_layer_->AddChild(copy_layer_); | 359 parent_layer_->AddChild(copy_layer_); |
| 360 | 360 |
| 361 layer_tree()->SetRootLayer(root_); | 361 layer_tree_host()->SetRootLayer(root_); |
| 362 LayerTreeHostCopyRequestTest::SetupTree(); | 362 LayerTreeHostCopyRequestTest::SetupTree(); |
| 363 client_.set_bounds(root_->bounds()); | 363 client_.set_bounds(root_->bounds()); |
| 364 } | 364 } |
| 365 | 365 |
| 366 void AddCopyRequest(Layer* layer) { | 366 void AddCopyRequest(Layer* layer) { |
| 367 layer->RequestCopyOfOutput( | 367 layer->RequestCopyOfOutput( |
| 368 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 368 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 369 &LayerTreeHostCopyRequestTestInHiddenSubtree::CopyOutputCallback, | 369 &LayerTreeHostCopyRequestTestInHiddenSubtree::CopyOutputCallback, |
| 370 base::Unretained(this)))); | 370 base::Unretained(this)))); |
| 371 } | 371 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 // parent_layer_ owns a render surface. | 451 // parent_layer_ owns a render surface. |
| 452 parent_layer_ = FakePictureLayer::Create(&client_); | 452 parent_layer_ = FakePictureLayer::Create(&client_); |
| 453 parent_layer_->SetBounds(gfx::Size(15, 15)); | 453 parent_layer_->SetBounds(gfx::Size(15, 15)); |
| 454 parent_layer_->SetForceRenderSurfaceForTesting(true); | 454 parent_layer_->SetForceRenderSurfaceForTesting(true); |
| 455 grand_parent_layer_->AddChild(parent_layer_); | 455 grand_parent_layer_->AddChild(parent_layer_); |
| 456 | 456 |
| 457 copy_layer_ = FakePictureLayer::Create(&client_); | 457 copy_layer_ = FakePictureLayer::Create(&client_); |
| 458 copy_layer_->SetBounds(gfx::Size(10, 10)); | 458 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 459 parent_layer_->AddChild(copy_layer_); | 459 parent_layer_->AddChild(copy_layer_); |
| 460 | 460 |
| 461 layer_tree()->SetRootLayer(root_); | 461 layer_tree_host()->SetRootLayer(root_); |
| 462 LayerTreeHostCopyRequestTest::SetupTree(); | 462 LayerTreeHostCopyRequestTest::SetupTree(); |
| 463 client_.set_bounds(root_->bounds()); | 463 client_.set_bounds(root_->bounds()); |
| 464 } | 464 } |
| 465 | 465 |
| 466 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( | 466 std::unique_ptr<TestDelegatingOutputSurface> CreateDelegatingOutputSurface( |
| 467 scoped_refptr<ContextProvider> compositor_context_provider, | 467 scoped_refptr<ContextProvider> compositor_context_provider, |
| 468 scoped_refptr<ContextProvider> worker_context_provider) override { | 468 scoped_refptr<ContextProvider> worker_context_provider) override { |
| 469 auto surface = LayerTreeHostCopyRequestTest::CreateDelegatingOutputSurface( | 469 auto surface = LayerTreeHostCopyRequestTest::CreateDelegatingOutputSurface( |
| 470 std::move(compositor_context_provider), | 470 std::move(compositor_context_provider), |
| 471 std::move(worker_context_provider)); | 471 std::move(worker_context_provider)); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 parent_layer_ = FakePictureLayer::Create(&client_); | 555 parent_layer_ = FakePictureLayer::Create(&client_); |
| 556 parent_layer_->SetBounds(gfx::Size(15, 15)); | 556 parent_layer_->SetBounds(gfx::Size(15, 15)); |
| 557 parent_layer_->SetMasksToBounds(true); | 557 parent_layer_->SetMasksToBounds(true); |
| 558 root_->AddChild(parent_layer_); | 558 root_->AddChild(parent_layer_); |
| 559 | 559 |
| 560 copy_layer_ = FakePictureLayer::Create(&client_); | 560 copy_layer_ = FakePictureLayer::Create(&client_); |
| 561 copy_layer_->SetPosition(gfx::PointF(15.f, 15.f)); | 561 copy_layer_->SetPosition(gfx::PointF(15.f, 15.f)); |
| 562 copy_layer_->SetBounds(gfx::Size(10, 10)); | 562 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 563 parent_layer_->AddChild(copy_layer_); | 563 parent_layer_->AddChild(copy_layer_); |
| 564 | 564 |
| 565 layer_tree()->SetRootLayer(root_); | 565 layer_tree_host()->SetRootLayer(root_); |
| 566 LayerTreeHostCopyRequestTest::SetupTree(); | 566 LayerTreeHostCopyRequestTest::SetupTree(); |
| 567 client_.set_bounds(root_->bounds()); | 567 client_.set_bounds(root_->bounds()); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void BeginTest() override { | 570 void BeginTest() override { |
| 571 PostSetNeedsCommitToMainThread(); | 571 PostSetNeedsCommitToMainThread(); |
| 572 | 572 |
| 573 copy_layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( | 573 copy_layer_->RequestCopyOfOutput(CopyOutputRequest::CreateBitmapRequest( |
| 574 base::Bind(&LayerTreeHostCopyRequestTestClippedOut::CopyOutputCallback, | 574 base::Bind(&LayerTreeHostCopyRequestTestClippedOut::CopyOutputCallback, |
| 575 base::Unretained(this)))); | 575 base::Unretained(this)))); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 605 | 605 |
| 606 copy_layer_ = Layer::Create(); | 606 copy_layer_ = Layer::Create(); |
| 607 copy_layer_->SetBounds(gfx::Size(10, 10)); | 607 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 608 copy_layer_->SetTransform(scale); | 608 copy_layer_->SetTransform(scale); |
| 609 root_->AddChild(copy_layer_); | 609 root_->AddChild(copy_layer_); |
| 610 | 610 |
| 611 child_layer_ = FakePictureLayer::Create(&client_); | 611 child_layer_ = FakePictureLayer::Create(&client_); |
| 612 child_layer_->SetBounds(gfx::Size(10, 10)); | 612 child_layer_->SetBounds(gfx::Size(10, 10)); |
| 613 copy_layer_->AddChild(child_layer_); | 613 copy_layer_->AddChild(child_layer_); |
| 614 | 614 |
| 615 layer_tree()->SetRootLayer(root_); | 615 layer_tree_host()->SetRootLayer(root_); |
| 616 LayerTreeHostCopyRequestTest::SetupTree(); | 616 LayerTreeHostCopyRequestTest::SetupTree(); |
| 617 client_.set_bounds(root_->bounds()); | 617 client_.set_bounds(root_->bounds()); |
| 618 } | 618 } |
| 619 | 619 |
| 620 void BeginTest() override { | 620 void BeginTest() override { |
| 621 PostSetNeedsCommitToMainThread(); | 621 PostSetNeedsCommitToMainThread(); |
| 622 | 622 |
| 623 std::unique_ptr<CopyOutputRequest> request = | 623 std::unique_ptr<CopyOutputRequest> request = |
| 624 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 624 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 625 &LayerTreeHostCopyRequestTestScaledLayer::CopyOutputCallback, | 625 &LayerTreeHostCopyRequestTestScaledLayer::CopyOutputCallback, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 649 : public LayerTreeHostCopyRequestTest { | 649 : public LayerTreeHostCopyRequestTest { |
| 650 protected: | 650 protected: |
| 651 void SetupTree() override { | 651 void SetupTree() override { |
| 652 root_ = FakePictureLayer::Create(&client_); | 652 root_ = FakePictureLayer::Create(&client_); |
| 653 root_->SetBounds(gfx::Size(20, 20)); | 653 root_->SetBounds(gfx::Size(20, 20)); |
| 654 | 654 |
| 655 copy_layer_ = FakePictureLayer::Create(&client_); | 655 copy_layer_ = FakePictureLayer::Create(&client_); |
| 656 copy_layer_->SetBounds(gfx::Size(10, 10)); | 656 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 657 root_->AddChild(copy_layer_); | 657 root_->AddChild(copy_layer_); |
| 658 | 658 |
| 659 layer_tree()->SetRootLayer(root_); | 659 layer_tree_host()->SetRootLayer(root_); |
| 660 LayerTreeHostCopyRequestTest::SetupTree(); | 660 LayerTreeHostCopyRequestTest::SetupTree(); |
| 661 client_.set_bounds(root_->bounds()); | 661 client_.set_bounds(root_->bounds()); |
| 662 } | 662 } |
| 663 | 663 |
| 664 void AddCopyRequest(Layer* layer) { | 664 void AddCopyRequest(Layer* layer) { |
| 665 layer->RequestCopyOfOutput( | 665 layer->RequestCopyOfOutput( |
| 666 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 666 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
| 667 &LayerTreeHostTestAsyncTwoReadbacksWithoutDraw::CopyOutputCallback, | 667 &LayerTreeHostTestAsyncTwoReadbacksWithoutDraw::CopyOutputCallback, |
| 668 base::Unretained(this)))); | 668 base::Unretained(this)))); |
| 669 } | 669 } |
| 670 | 670 |
| 671 void BeginTest() override { | 671 void BeginTest() override { |
| 672 saw_copy_request_ = false; | 672 saw_copy_request_ = false; |
| 673 callback_count_ = 0; | 673 callback_count_ = 0; |
| 674 PostSetNeedsCommitToMainThread(); | 674 PostSetNeedsCommitToMainThread(); |
| 675 | 675 |
| 676 // Prevent drawing. | 676 // Prevent drawing. |
| 677 layer_tree()->SetViewportSize(gfx::Size(0, 0)); | 677 layer_tree_host()->SetViewportSize(gfx::Size(0, 0)); |
| 678 | 678 |
| 679 AddCopyRequest(copy_layer_.get()); | 679 AddCopyRequest(copy_layer_.get()); |
| 680 } | 680 } |
| 681 | 681 |
| 682 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | 682 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { |
| 683 if (impl->active_tree()->source_frame_number() == 0) { | 683 if (impl->active_tree()->source_frame_number() == 0) { |
| 684 EXPECT_TRUE(impl->active_tree()->LayerById(copy_layer_->id())); | 684 EXPECT_TRUE(impl->active_tree()->LayerById(copy_layer_->id())); |
| 685 saw_copy_request_ = true; | 685 saw_copy_request_ = true; |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 | 688 |
| 689 void DidCommit() override { | 689 void DidCommit() override { |
| 690 if (layer_tree_host()->source_frame_number() == 1) { | 690 if (layer_tree_host()->source_frame_number() == 1) { |
| 691 // Allow drawing. | 691 // Allow drawing. |
| 692 layer_tree()->SetViewportSize(gfx::Size(root_->bounds())); | 692 layer_tree_host()->SetViewportSize(gfx::Size(root_->bounds())); |
| 693 | 693 |
| 694 AddCopyRequest(copy_layer_.get()); | 694 AddCopyRequest(copy_layer_.get()); |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 | 697 |
| 698 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { | 698 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { |
| 699 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); | 699 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); |
| 700 | 700 |
| 701 // The first frame can't be drawn. | 701 // The first frame can't be drawn. |
| 702 switch (callback_count_) { | 702 switch (callback_count_) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 } | 738 } |
| 739 | 739 |
| 740 void SetupTree() override { | 740 void SetupTree() override { |
| 741 root_ = FakePictureLayer::Create(&client_); | 741 root_ = FakePictureLayer::Create(&client_); |
| 742 root_->SetBounds(gfx::Size(20, 20)); | 742 root_->SetBounds(gfx::Size(20, 20)); |
| 743 | 743 |
| 744 copy_layer_ = FakePictureLayer::Create(&client_); | 744 copy_layer_ = FakePictureLayer::Create(&client_); |
| 745 copy_layer_->SetBounds(gfx::Size(10, 10)); | 745 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 746 root_->AddChild(copy_layer_); | 746 root_->AddChild(copy_layer_); |
| 747 | 747 |
| 748 layer_tree()->SetRootLayer(root_); | 748 layer_tree_host()->SetRootLayer(root_); |
| 749 LayerTreeHostCopyRequestTest::SetupTree(); | 749 LayerTreeHostCopyRequestTest::SetupTree(); |
| 750 client_.set_bounds(root_->bounds()); | 750 client_.set_bounds(root_->bounds()); |
| 751 } | 751 } |
| 752 | 752 |
| 753 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 753 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 754 | 754 |
| 755 void ReceiveCopyRequestOutputAndCommit( | 755 void ReceiveCopyRequestOutputAndCommit( |
| 756 std::unique_ptr<CopyOutputResult> result) { | 756 std::unique_ptr<CopyOutputResult> result) { |
| 757 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); | 757 EXPECT_TRUE(layer_tree_host()->task_runner_provider()->IsMainThread()); |
| 758 EXPECT_EQ(gfx::Size(10, 10).ToString(), result->size().ToString()); | 758 EXPECT_EQ(gfx::Size(10, 10).ToString(), result->size().ToString()); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 869 |
| 870 copy_layer_ = FakePictureLayer::Create(©_client_); | 870 copy_layer_ = FakePictureLayer::Create(©_client_); |
| 871 copy_layer_->SetBounds(gfx::Size(10, 10)); | 871 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 872 copy_client_.set_bounds(copy_layer_->bounds()); | 872 copy_client_.set_bounds(copy_layer_->bounds()); |
| 873 // Doing a copy makes the layer have a render surface which can cause | 873 // Doing a copy makes the layer have a render surface which can cause |
| 874 // texture allocations. So get those allocations out of the way in the | 874 // texture allocations. So get those allocations out of the way in the |
| 875 // first frame by forcing it to have a render surface. | 875 // first frame by forcing it to have a render surface. |
| 876 copy_layer_->SetForceRenderSurfaceForTesting(true); | 876 copy_layer_->SetForceRenderSurfaceForTesting(true); |
| 877 root_->AddChild(copy_layer_); | 877 root_->AddChild(copy_layer_); |
| 878 | 878 |
| 879 layer_tree()->SetRootLayer(root_); | 879 layer_tree_host()->SetRootLayer(root_); |
| 880 LayerTreeHostCopyRequestTest::SetupTree(); | 880 LayerTreeHostCopyRequestTest::SetupTree(); |
| 881 } | 881 } |
| 882 | 882 |
| 883 void BeginTest() override { | 883 void BeginTest() override { |
| 884 waited_sync_token_after_readback_.Clear(); | 884 waited_sync_token_after_readback_.Clear(); |
| 885 PostSetNeedsCommitToMainThread(); | 885 PostSetNeedsCommitToMainThread(); |
| 886 } | 886 } |
| 887 | 887 |
| 888 virtual void RequestCopy(Layer* layer) = 0; | 888 virtual void RequestCopy(Layer* layer) = 0; |
| 889 | 889 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 : public LayerTreeHostCopyRequestTest { | 1030 : public LayerTreeHostCopyRequestTest { |
| 1031 protected: | 1031 protected: |
| 1032 void SetupTree() override { | 1032 void SetupTree() override { |
| 1033 root_ = FakePictureLayer::Create(&client_); | 1033 root_ = FakePictureLayer::Create(&client_); |
| 1034 root_->SetBounds(gfx::Size(20, 20)); | 1034 root_->SetBounds(gfx::Size(20, 20)); |
| 1035 | 1035 |
| 1036 copy_layer_ = FakePictureLayer::Create(&client_); | 1036 copy_layer_ = FakePictureLayer::Create(&client_); |
| 1037 copy_layer_->SetBounds(gfx::Size(10, 10)); | 1037 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 1038 root_->AddChild(copy_layer_); | 1038 root_->AddChild(copy_layer_); |
| 1039 | 1039 |
| 1040 layer_tree()->SetRootLayer(root_); | 1040 layer_tree_host()->SetRootLayer(root_); |
| 1041 LayerTreeHostCopyRequestTest::SetupTree(); | 1041 LayerTreeHostCopyRequestTest::SetupTree(); |
| 1042 client_.set_bounds(root_->bounds()); | 1042 client_.set_bounds(root_->bounds()); |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 void BeginTest() override { | 1045 void BeginTest() override { |
| 1046 callback_count_ = 0; | 1046 callback_count_ = 0; |
| 1047 PostSetNeedsCommitToMainThread(); | 1047 PostSetNeedsCommitToMainThread(); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { | 1050 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1065 EXPECT_EQ(0, callback_count_); | 1065 EXPECT_EQ(0, callback_count_); |
| 1066 // Put a copy request on the layer, but then don't allow any | 1066 // Put a copy request on the layer, but then don't allow any |
| 1067 // drawing to take place. | 1067 // drawing to take place. |
| 1068 std::unique_ptr<CopyOutputRequest> request = | 1068 std::unique_ptr<CopyOutputRequest> request = |
| 1069 CopyOutputRequest::CreateRequest( | 1069 CopyOutputRequest::CreateRequest( |
| 1070 base::Bind(&LayerTreeHostCopyRequestTestDestroyBeforeCopy:: | 1070 base::Bind(&LayerTreeHostCopyRequestTestDestroyBeforeCopy:: |
| 1071 CopyOutputCallback, | 1071 CopyOutputCallback, |
| 1072 base::Unretained(this))); | 1072 base::Unretained(this))); |
| 1073 copy_layer_->RequestCopyOfOutput(std::move(request)); | 1073 copy_layer_->RequestCopyOfOutput(std::move(request)); |
| 1074 | 1074 |
| 1075 layer_tree()->SetViewportSize(gfx::Size()); | 1075 layer_tree_host()->SetViewportSize(gfx::Size()); |
| 1076 break; | 1076 break; |
| 1077 } | 1077 } |
| 1078 case 2: | 1078 case 2: |
| 1079 EXPECT_EQ(0, callback_count_); | 1079 EXPECT_EQ(0, callback_count_); |
| 1080 // Remove the copy layer before we were able to draw. | 1080 // Remove the copy layer before we were able to draw. |
| 1081 copy_layer_->RemoveFromParent(); | 1081 copy_layer_->RemoveFromParent(); |
| 1082 break; | 1082 break; |
| 1083 case 3: | 1083 case 3: |
| 1084 EXPECT_EQ(1, callback_count_); | 1084 EXPECT_EQ(1, callback_count_); |
| 1085 // Allow us to draw now. | 1085 // Allow us to draw now. |
| 1086 layer_tree()->SetViewportSize(layer_tree()->root_layer()->bounds()); | 1086 layer_tree_host()->SetViewportSize( |
| 1087 layer_tree_host()->root_layer()->bounds()); |
| 1087 break; | 1088 break; |
| 1088 case 4: | 1089 case 4: |
| 1089 EXPECT_EQ(1, callback_count_); | 1090 EXPECT_EQ(1, callback_count_); |
| 1090 // We should not have crashed. | 1091 // We should not have crashed. |
| 1091 EndTest(); | 1092 EndTest(); |
| 1092 } | 1093 } |
| 1093 } | 1094 } |
| 1094 | 1095 |
| 1095 void AfterTest() override {} | 1096 void AfterTest() override {} |
| 1096 | 1097 |
| 1097 int callback_count_; | 1098 int callback_count_; |
| 1098 FakeContentLayerClient client_; | 1099 FakeContentLayerClient client_; |
| 1099 scoped_refptr<FakePictureLayer> root_; | 1100 scoped_refptr<FakePictureLayer> root_; |
| 1100 scoped_refptr<FakePictureLayer> copy_layer_; | 1101 scoped_refptr<FakePictureLayer> copy_layer_; |
| 1101 }; | 1102 }; |
| 1102 | 1103 |
| 1103 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestDestroyBeforeCopy); | 1104 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostCopyRequestTestDestroyBeforeCopy); |
| 1104 | 1105 |
| 1105 class LayerTreeHostCopyRequestTestShutdownBeforeCopy | 1106 class LayerTreeHostCopyRequestTestShutdownBeforeCopy |
| 1106 : public LayerTreeHostCopyRequestTest { | 1107 : public LayerTreeHostCopyRequestTest { |
| 1107 protected: | 1108 protected: |
| 1108 void SetupTree() override { | 1109 void SetupTree() override { |
| 1109 root_ = FakePictureLayer::Create(&client_); | 1110 root_ = FakePictureLayer::Create(&client_); |
| 1110 root_->SetBounds(gfx::Size(20, 20)); | 1111 root_->SetBounds(gfx::Size(20, 20)); |
| 1111 | 1112 |
| 1112 copy_layer_ = FakePictureLayer::Create(&client_); | 1113 copy_layer_ = FakePictureLayer::Create(&client_); |
| 1113 copy_layer_->SetBounds(gfx::Size(10, 10)); | 1114 copy_layer_->SetBounds(gfx::Size(10, 10)); |
| 1114 root_->AddChild(copy_layer_); | 1115 root_->AddChild(copy_layer_); |
| 1115 | 1116 |
| 1116 layer_tree()->SetRootLayer(root_); | 1117 layer_tree_host()->SetRootLayer(root_); |
| 1117 LayerTreeHostCopyRequestTest::SetupTree(); | 1118 LayerTreeHostCopyRequestTest::SetupTree(); |
| 1118 client_.set_bounds(root_->bounds()); | 1119 client_.set_bounds(root_->bounds()); |
| 1119 } | 1120 } |
| 1120 | 1121 |
| 1121 void BeginTest() override { | 1122 void BeginTest() override { |
| 1122 callback_count_ = 0; | 1123 callback_count_ = 0; |
| 1123 PostSetNeedsCommitToMainThread(); | 1124 PostSetNeedsCommitToMainThread(); |
| 1124 } | 1125 } |
| 1125 | 1126 |
| 1126 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { | 1127 void CopyOutputCallback(std::unique_ptr<CopyOutputResult> result) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1141 EXPECT_EQ(0, callback_count_); | 1142 EXPECT_EQ(0, callback_count_); |
| 1142 // Put a copy request on the layer, but then don't allow any | 1143 // Put a copy request on the layer, but then don't allow any |
| 1143 // drawing to take place. | 1144 // drawing to take place. |
| 1144 std::unique_ptr<CopyOutputRequest> request = | 1145 std::unique_ptr<CopyOutputRequest> request = |
| 1145 CopyOutputRequest::CreateRequest( | 1146 CopyOutputRequest::CreateRequest( |
| 1146 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy:: | 1147 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy:: |
| 1147 CopyOutputCallback, | 1148 CopyOutputCallback, |
| 1148 base::Unretained(this))); | 1149 base::Unretained(this))); |
| 1149 copy_layer_->RequestCopyOfOutput(std::move(request)); | 1150 copy_layer_->RequestCopyOfOutput(std::move(request)); |
| 1150 | 1151 |
| 1151 layer_tree()->SetViewportSize(gfx::Size()); | 1152 layer_tree_host()->SetViewportSize(gfx::Size()); |
| 1152 break; | 1153 break; |
| 1153 } | 1154 } |
| 1154 case 2: | 1155 case 2: |
| 1155 DestroyLayerTreeHost(); | 1156 DestroyLayerTreeHost(); |
| 1156 // End the test after the copy result has had a chance to get back to | 1157 // End the test after the copy result has had a chance to get back to |
| 1157 // the main thread. | 1158 // the main thread. |
| 1158 MainThreadTaskRunner()->PostTask( | 1159 MainThreadTaskRunner()->PostTask( |
| 1159 FROM_HERE, | 1160 FROM_HERE, |
| 1160 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy::EndTest, | 1161 base::Bind(&LayerTreeHostCopyRequestTestShutdownBeforeCopy::EndTest, |
| 1161 base::Unretained(this))); | 1162 base::Unretained(this))); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1178 protected: | 1179 protected: |
| 1179 void SetupTree() override { | 1180 void SetupTree() override { |
| 1180 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_); | 1181 scoped_refptr<FakePictureLayer> root = FakePictureLayer::Create(&client_); |
| 1181 root->SetBounds(gfx::Size(20, 20)); | 1182 root->SetBounds(gfx::Size(20, 20)); |
| 1182 | 1183 |
| 1183 child_ = FakePictureLayer::Create(&client_); | 1184 child_ = FakePictureLayer::Create(&client_); |
| 1184 child_->SetBounds(gfx::Size(10, 10)); | 1185 child_->SetBounds(gfx::Size(10, 10)); |
| 1185 root->AddChild(child_); | 1186 root->AddChild(child_); |
| 1186 child_->SetHideLayerAndSubtree(true); | 1187 child_->SetHideLayerAndSubtree(true); |
| 1187 | 1188 |
| 1188 layer_tree()->SetRootLayer(root); | 1189 layer_tree_host()->SetRootLayer(root); |
| 1189 LayerTreeHostCopyRequestTest::SetupTree(); | 1190 LayerTreeHostCopyRequestTest::SetupTree(); |
| 1190 client_.set_bounds(root->bounds()); | 1191 client_.set_bounds(root->bounds()); |
| 1191 } | 1192 } |
| 1192 | 1193 |
| 1193 void BeginTest() override { | 1194 void BeginTest() override { |
| 1194 num_draws_ = 0; | 1195 num_draws_ = 0; |
| 1195 copy_happened_ = false; | 1196 copy_happened_ = false; |
| 1196 draw_happened_ = false; | 1197 draw_happened_ = false; |
| 1197 PostSetNeedsCommitToMainThread(); | 1198 PostSetNeedsCommitToMainThread(); |
| 1198 } | 1199 } |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 int num_draws_; | 1285 int num_draws_; |
| 1285 bool copy_happened_; | 1286 bool copy_happened_; |
| 1286 bool draw_happened_; | 1287 bool draw_happened_; |
| 1287 }; | 1288 }; |
| 1288 | 1289 |
| 1289 SINGLE_AND_MULTI_THREAD_TEST_F( | 1290 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 1290 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); | 1291 LayerTreeHostCopyRequestTestMultipleDrawsHiddenCopyRequest); |
| 1291 | 1292 |
| 1292 } // namespace | 1293 } // namespace |
| 1293 } // namespace cc | 1294 } // namespace cc |
| OLD | NEW |