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