| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/surfaces/compositor_frame_sink_support.h" | 5 #include "cc/surfaces/compositor_frame_sink_support.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "cc/output/compositor_frame.h" | 8 #include "cc/output/compositor_frame.h" |
| 9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
| (...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 TEST_F(CompositorFrameSinkSupportTest, DestroyCycle) { | 666 TEST_F(CompositorFrameSinkSupportTest, DestroyCycle) { |
| 667 LocalSurfaceId local_surface_id2(5, kArbitraryToken); | 667 LocalSurfaceId local_surface_id2(5, kArbitraryToken); |
| 668 SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); | 668 SurfaceId id2(kYetAnotherArbitraryFrameSinkId, local_surface_id2); |
| 669 std::unique_ptr<CompositorFrameSinkSupport> support2 = | 669 std::unique_ptr<CompositorFrameSinkSupport> support2 = |
| 670 CompositorFrameSinkSupport::Create( | 670 CompositorFrameSinkSupport::Create( |
| 671 &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, | 671 &fake_support_client_, &manager_, kYetAnotherArbitraryFrameSinkId, |
| 672 kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 672 kIsChildRoot, kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
| 673 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); | 673 manager_.RegisterFrameSinkId(kAnotherArbitraryFrameSinkId); |
| 674 // Give id2 a frame that references local_surface_id_. | 674 // Give id2 a frame that references local_surface_id_. |
| 675 { | 675 { |
| 676 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 677 CompositorFrame frame = MakeCompositorFrame(); | 676 CompositorFrame frame = MakeCompositorFrame(); |
| 678 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 679 frame.metadata.referenced_surfaces.push_back( | 677 frame.metadata.referenced_surfaces.push_back( |
| 680 SurfaceId(support_->frame_sink_id(), local_surface_id_)); | 678 SurfaceId(support_->frame_sink_id(), local_surface_id_)); |
| 681 support2->SubmitCompositorFrame(local_surface_id2, std::move(frame)); | 679 support2->SubmitCompositorFrame(local_surface_id2, std::move(frame)); |
| 682 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id2); | 680 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id2); |
| 683 } | 681 } |
| 684 manager_.GetSurfaceForId(id2)->AddDestructionDependency( | 682 manager_.GetSurfaceForId(id2)->AddDestructionDependency( |
| 685 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 683 SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 686 support2->EvictCurrentSurface(); | 684 support2->EvictCurrentSurface(); |
| 687 // Give local_surface_id_ a frame that references id2. | 685 // Give local_surface_id_ a frame that references id2. |
| 688 { | 686 { |
| 689 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 690 CompositorFrame frame = MakeCompositorFrame(); | 687 CompositorFrame frame = MakeCompositorFrame(); |
| 691 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 692 frame.metadata.referenced_surfaces.push_back(id2); | 688 frame.metadata.referenced_surfaces.push_back(id2); |
| 693 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | 689 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
| 694 } | 690 } |
| 695 support_->EvictCurrentSurface(); | 691 support_->EvictCurrentSurface(); |
| 696 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); | 692 EXPECT_TRUE(manager_.GetSurfaceForId(id2)); |
| 697 // local_surface_id_ should be retained by reference from id2. | 693 // local_surface_id_ should be retained by reference from id2. |
| 698 EXPECT_TRUE(manager_.GetSurfaceForId( | 694 EXPECT_TRUE(manager_.GetSurfaceForId( |
| 699 SurfaceId(support_->frame_sink_id(), local_surface_id_))); | 695 SurfaceId(support_->frame_sink_id(), local_surface_id_))); |
| 700 | 696 |
| 701 // Satisfy last destruction dependency for id2. | 697 // Satisfy last destruction dependency for id2. |
| 702 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); | 698 manager_.SatisfySequence(SurfaceSequence(kAnotherArbitraryFrameSinkId, 4)); |
| 703 | 699 |
| 704 // id2 and local_surface_id_ are in a reference cycle that has no surface | 700 // id2 and local_surface_id_ are in a reference cycle that has no surface |
| 705 // sequences holding on to it, so they should be destroyed. | 701 // sequences holding on to it, so they should be destroyed. |
| 706 EXPECT_TRUE(!manager_.GetSurfaceForId(id2)); | 702 EXPECT_TRUE(!manager_.GetSurfaceForId(id2)); |
| 707 EXPECT_TRUE(!manager_.GetSurfaceForId( | 703 EXPECT_TRUE(!manager_.GetSurfaceForId( |
| 708 SurfaceId(support_->frame_sink_id(), local_surface_id_))); | 704 SurfaceId(support_->frame_sink_id(), local_surface_id_))); |
| 709 | 705 |
| 710 local_surface_id_ = LocalSurfaceId(); | 706 local_surface_id_ = LocalSurfaceId(); |
| 711 } | 707 } |
| 712 | 708 |
| 713 void CopyRequestTestCallback(bool* called, | 709 void CopyRequestTestCallback(bool* called, |
| 714 std::unique_ptr<CopyOutputResult> result) { | 710 std::unique_ptr<CopyOutputResult> result) { |
| 715 *called = true; | 711 *called = true; |
| 716 } | 712 } |
| 717 | 713 |
| 718 TEST_F(CompositorFrameSinkSupportTest, DuplicateCopyRequest) { | 714 TEST_F(CompositorFrameSinkSupportTest, DuplicateCopyRequest) { |
| 719 { | 715 { |
| 720 std::unique_ptr<RenderPass> render_pass(RenderPass::Create()); | |
| 721 CompositorFrame frame = MakeCompositorFrame(); | 716 CompositorFrame frame = MakeCompositorFrame(); |
| 722 frame.render_pass_list.push_back(std::move(render_pass)); | |
| 723 frame.metadata.referenced_surfaces.push_back( | 717 frame.metadata.referenced_surfaces.push_back( |
| 724 SurfaceId(support_->frame_sink_id(), local_surface_id_)); | 718 SurfaceId(support_->frame_sink_id(), local_surface_id_)); |
| 725 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); | 719 support_->SubmitCompositorFrame(local_surface_id_, std::move(frame)); |
| 726 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id_); | 720 EXPECT_EQ(last_created_surface_id().local_surface_id(), local_surface_id_); |
| 727 } | 721 } |
| 728 | 722 |
| 729 bool called1 = false; | 723 bool called1 = false; |
| 730 std::unique_ptr<CopyOutputRequest> request; | 724 std::unique_ptr<CopyOutputRequest> request; |
| 731 request = CopyOutputRequest::CreateRequest( | 725 request = CopyOutputRequest::CreateRequest( |
| 732 base::Bind(&CopyRequestTestCallback, &called1)); | 726 base::Bind(&CopyRequestTestCallback, &called1)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); | 777 EXPECT_EQ(expected_surface_id, last_surface_info_.id()); |
| 784 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); | 778 EXPECT_EQ(2.5f, last_surface_info_.device_scale_factor()); |
| 785 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); | 779 EXPECT_EQ(gfx::Size(7, 8), last_surface_info_.size_in_pixels()); |
| 786 } | 780 } |
| 787 | 781 |
| 788 } // namespace | 782 } // namespace |
| 789 | 783 |
| 790 } // namespace test | 784 } // namespace test |
| 791 | 785 |
| 792 } // namespace cc | 786 } // namespace cc |
| OLD | NEW |