OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/display.h" | 5 #include "cc/surfaces/display.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/test/null_task_runner.h" | 9 #include "base/test/null_task_runner.h" |
10 #include "cc/output/compositor_frame.h" | 10 #include "cc/output/compositor_frame.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 task_runner_(new base::NullTaskRunner) { | 101 task_runner_(new base::NullTaskRunner) { |
102 manager_.RegisterSurfaceClientId(id_allocator_.client_id()); | 102 manager_.RegisterSurfaceClientId(id_allocator_.client_id()); |
103 } | 103 } |
104 | 104 |
105 ~DisplayTest() override { | 105 ~DisplayTest() override { |
106 manager_.InvalidateSurfaceClientId(id_allocator_.client_id()); | 106 manager_.InvalidateSurfaceClientId(id_allocator_.client_id()); |
107 } | 107 } |
108 | 108 |
109 void SetUpDisplay(const RendererSettings& settings, | 109 void SetUpDisplay(const RendererSettings& settings, |
110 std::unique_ptr<TestWebGraphicsContext3D> context) { | 110 std::unique_ptr<TestWebGraphicsContext3D> context) { |
111 std::unique_ptr<BeginFrameSource> begin_frame_source( | |
112 new StubBeginFrameSource); | |
113 | |
114 std::unique_ptr<FakeOutputSurface> output_surface; | 111 std::unique_ptr<FakeOutputSurface> output_surface; |
115 if (context) { | 112 if (context) { |
116 output_surface = FakeOutputSurface::Create3d(std::move(context)); | 113 output_surface = FakeOutputSurface::Create3d(std::move(context)); |
117 } else { | 114 } else { |
118 std::unique_ptr<TestSoftwareOutputDevice> device( | 115 std::unique_ptr<TestSoftwareOutputDevice> device( |
119 new TestSoftwareOutputDevice); | 116 new TestSoftwareOutputDevice); |
120 software_output_device_ = device.get(); | 117 software_output_device_ = device.get(); |
121 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); | 118 output_surface = FakeOutputSurface::CreateSoftware(std::move(device)); |
122 } | 119 } |
123 output_surface_ = output_surface.get(); | 120 output_surface_ = output_surface.get(); |
124 | 121 |
125 std::unique_ptr<TestDisplayScheduler> scheduler( | 122 std::unique_ptr<TestDisplayScheduler> scheduler( |
126 new TestDisplayScheduler(begin_frame_source.get(), task_runner_.get())); | 123 new TestDisplayScheduler(&begin_frame_source_, task_runner_.get())); |
127 scheduler_ = scheduler.get(); | 124 scheduler_ = scheduler.get(); |
128 | 125 |
129 display_ = base::MakeUnique<Display>( | 126 display_ = base::MakeUnique<Display>( |
130 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, | 127 &shared_bitmap_manager_, nullptr /* gpu_memory_buffer_manager */, |
131 settings, std::move(begin_frame_source), std::move(output_surface), | 128 settings, &begin_frame_source_, std::move(output_surface), |
132 std::move(scheduler), | 129 std::move(scheduler), |
133 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); | 130 base::MakeUnique<TextureMailboxDeleter>(task_runner_.get())); |
134 display_->SetVisible(true); | 131 display_->SetVisible(true); |
135 } | 132 } |
136 | 133 |
137 protected: | 134 protected: |
138 void SubmitCompositorFrame(RenderPassList* pass_list, | 135 void SubmitCompositorFrame(RenderPassList* pass_list, |
139 const SurfaceId& surface_id) { | 136 const SurfaceId& surface_id) { |
140 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); | 137 std::unique_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); |
141 pass_list->swap(frame_data->render_pass_list); | 138 pass_list->swap(frame_data->render_pass_list); |
142 | 139 |
143 CompositorFrame frame; | 140 CompositorFrame frame; |
144 frame.delegated_frame_data = std::move(frame_data); | 141 frame.delegated_frame_data = std::move(frame_data); |
145 | 142 |
146 factory_.SubmitCompositorFrame(surface_id, std::move(frame), | 143 factory_.SubmitCompositorFrame(surface_id, std::move(frame), |
147 SurfaceFactory::DrawCallback()); | 144 SurfaceFactory::DrawCallback()); |
148 } | 145 } |
149 | 146 |
150 static constexpr int kArbitraryClientId = 3; | 147 static constexpr int kArbitraryClientId = 3; |
151 | 148 |
152 SurfaceManager manager_; | 149 SurfaceManager manager_; |
153 FakeSurfaceFactoryClient surface_factory_client_; | 150 FakeSurfaceFactoryClient surface_factory_client_; |
154 SurfaceFactory factory_; | 151 SurfaceFactory factory_; |
155 SurfaceIdAllocator id_allocator_; | 152 SurfaceIdAllocator id_allocator_; |
| 153 StubBeginFrameSource begin_frame_source_; |
156 scoped_refptr<base::NullTaskRunner> task_runner_; | 154 scoped_refptr<base::NullTaskRunner> task_runner_; |
157 TestSharedBitmapManager shared_bitmap_manager_; | 155 TestSharedBitmapManager shared_bitmap_manager_; |
158 std::unique_ptr<Display> display_; | 156 std::unique_ptr<Display> display_; |
159 TestSoftwareOutputDevice* software_output_device_ = nullptr; | 157 TestSoftwareOutputDevice* software_output_device_ = nullptr; |
160 FakeOutputSurface* output_surface_ = nullptr; | 158 FakeOutputSurface* output_surface_ = nullptr; |
161 TestDisplayScheduler* scheduler_ = nullptr; | 159 TestDisplayScheduler* scheduler_ = nullptr; |
162 }; | 160 }; |
163 | 161 |
164 class StubDisplayClient : public DisplayClient { | 162 class StubDisplayClient : public DisplayClient { |
165 public: | 163 public: |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 493 |
496 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); | 494 EXPECT_CALL(*context_ptr, shallowFinishCHROMIUM()); |
497 display_->Resize(gfx::Size(250, 250)); | 495 display_->Resize(gfx::Size(250, 250)); |
498 testing::Mock::VerifyAndClearExpectations(context_ptr); | 496 testing::Mock::VerifyAndClearExpectations(context_ptr); |
499 | 497 |
500 factory_.Destroy(surface_id); | 498 factory_.Destroy(surface_id); |
501 } | 499 } |
502 | 500 |
503 } // namespace | 501 } // namespace |
504 } // namespace cc | 502 } // namespace cc |
OLD | NEW |