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