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