OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/surface.h" | 5 #include "cc/surfaces/surface.h" |
6 #include "base/memory/ptr_util.h" | 6 #include "base/memory/ptr_util.h" |
7 #include "cc/output/copy_output_result.h" | 7 #include "cc/output/copy_output_result.h" |
8 #include "cc/surfaces/compositor_frame_sink_support.h" | 8 #include "cc/surfaces/compositor_frame_sink_support.h" |
9 #include "cc/surfaces/local_surface_id_allocator.h" | 9 #include "cc/surfaces/local_surface_id_allocator.h" |
10 #include "cc/surfaces/surface_dependency_tracker.h" | 10 #include "cc/surfaces/surface_dependency_tracker.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 TEST(SurfaceTest, CopyRequestLifetime) { | 59 TEST(SurfaceTest, CopyRequestLifetime) { |
60 SurfaceManager manager; | 60 SurfaceManager manager; |
61 std::unique_ptr<CompositorFrameSinkSupport> support = | 61 std::unique_ptr<CompositorFrameSinkSupport> support = |
62 CompositorFrameSinkSupport::Create( | 62 CompositorFrameSinkSupport::Create( |
63 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot, | 63 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot, |
64 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 64 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
65 | 65 |
66 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); | 66 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); |
67 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | 67 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
68 CompositorFrame frame = test::MakeCompositorFrame(); | 68 CompositorFrame frame = test::MakeCompositorFrame(); |
| 69 frame.render_pass_list.push_back(RenderPass::Create()); |
69 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); | 70 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
70 Surface* surface = manager.GetSurfaceForId(surface_id); | 71 Surface* surface = manager.GetSurfaceForId(surface_id); |
71 ASSERT_TRUE(!!surface); | 72 ASSERT_TRUE(!!surface); |
72 | 73 |
73 bool copy_called = false; | 74 bool copy_called = false; |
74 support->RequestCopyOfSurface(CopyOutputRequest::CreateRequest( | 75 support->RequestCopyOfSurface(CopyOutputRequest::CreateRequest( |
75 base::Bind(&TestCopyResultCallback, ©_called))); | 76 base::Bind(&TestCopyResultCallback, ©_called))); |
76 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); | 77 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
77 EXPECT_FALSE(copy_called); | 78 EXPECT_FALSE(copy_called); |
78 | 79 |
79 int max_frame = 3, start_id = 200; | 80 int max_frame = 3, start_id = 200; |
80 for (int i = 0; i < max_frame; ++i) { | 81 for (int i = 0; i < max_frame; ++i) { |
81 CompositorFrame frame = test::MakeEmptyCompositorFrame(); | 82 CompositorFrame frame = test::MakeCompositorFrame(); |
82 frame.render_pass_list.push_back(RenderPass::Create()); | 83 frame.render_pass_list.push_back(RenderPass::Create()); |
83 frame.render_pass_list.back()->id = i * 3 + start_id; | 84 frame.render_pass_list.back()->id = i * 3 + start_id; |
84 frame.render_pass_list.push_back(RenderPass::Create()); | 85 frame.render_pass_list.push_back(RenderPass::Create()); |
85 frame.render_pass_list.back()->id = i * 3 + start_id + 1; | 86 frame.render_pass_list.back()->id = i * 3 + start_id + 1; |
86 frame.render_pass_list.push_back(RenderPass::Create()); | 87 frame.render_pass_list.push_back(RenderPass::Create()); |
87 frame.render_pass_list.back()->SetNew(i * 3 + start_id + 2, | 88 frame.render_pass_list.back()->id = i * 3 + start_id + 2; |
88 gfx::Rect(0, 0, 20, 20), gfx::Rect(), | |
89 gfx::Transform()); | |
90 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); | 89 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); |
91 } | 90 } |
92 | 91 |
93 int last_pass_id = (max_frame - 1) * 3 + start_id + 2; | 92 int last_pass_id = (max_frame - 1) * 3 + start_id + 2; |
94 // The copy request should stay on the Surface until TakeCopyOutputRequests | 93 // The copy request should stay on the Surface until TakeCopyOutputRequests |
95 // is called. | 94 // is called. |
96 EXPECT_FALSE(copy_called); | 95 EXPECT_FALSE(copy_called); |
97 EXPECT_EQ( | 96 EXPECT_EQ( |
98 1u, | 97 1u, |
99 surface->GetActiveFrame().render_pass_list.back()->copy_requests.size()); | 98 surface->GetActiveFrame().render_pass_list.back()->copy_requests.size()); |
100 | 99 |
101 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; | 100 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; |
102 surface->TakeCopyOutputRequests(©_requests); | 101 surface->TakeCopyOutputRequests(©_requests); |
103 EXPECT_EQ(1u, copy_requests.size()); | 102 EXPECT_EQ(1u, copy_requests.size()); |
104 // Last (root) pass should receive copy request. | 103 // Last (root) pass should receive copy request. |
105 ASSERT_EQ(1u, copy_requests.count(last_pass_id)); | 104 ASSERT_EQ(1u, copy_requests.count(last_pass_id)); |
106 EXPECT_FALSE(copy_called); | 105 EXPECT_FALSE(copy_called); |
107 copy_requests.find(last_pass_id)->second->SendEmptyResult(); | 106 copy_requests.find(last_pass_id)->second->SendEmptyResult(); |
108 EXPECT_TRUE(copy_called); | 107 EXPECT_TRUE(copy_called); |
109 | 108 |
110 support->EvictCurrentSurface(); | 109 support->EvictCurrentSurface(); |
111 } | 110 } |
112 | 111 |
113 } // namespace | 112 } // namespace |
114 } // namespace cc | 113 } // namespace cc |
OLD | NEW |