OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/test/test_compositor_frame_sink.h" | 5 #include "cc/test/test_compositor_frame_sink.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "cc/output/begin_frame_args.h" | 10 #include "cc/output/begin_frame_args.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 scoped_refptr<ContextProvider> compositor_context_provider, | 22 scoped_refptr<ContextProvider> compositor_context_provider, |
23 scoped_refptr<ContextProvider> worker_context_provider, | 23 scoped_refptr<ContextProvider> worker_context_provider, |
24 std::unique_ptr<OutputSurface> display_output_surface, | 24 std::unique_ptr<OutputSurface> display_output_surface, |
25 SharedBitmapManager* shared_bitmap_manager, | 25 SharedBitmapManager* shared_bitmap_manager, |
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
27 const RendererSettings& renderer_settings, | 27 const RendererSettings& renderer_settings, |
28 base::SingleThreadTaskRunner* task_runner, | 28 base::SingleThreadTaskRunner* task_runner, |
29 bool synchronous_composite, | 29 bool synchronous_composite, |
30 bool force_disable_reclaim_resources) | 30 bool force_disable_reclaim_resources) |
31 : CompositorFrameSink(std::move(compositor_context_provider), | 31 : CompositorFrameSink(std::move(compositor_context_provider), |
32 std::move(worker_context_provider), | 32 std::move(worker_context_provider)), |
33 nullptr), | |
34 surface_manager_(new SurfaceManager), | 33 surface_manager_(new SurfaceManager), |
35 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), | 34 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), |
36 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), | 35 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
37 weak_ptrs_(this) { | 36 weak_ptrs_(this) { |
38 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; | 37 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; |
39 std::unique_ptr<DisplayScheduler> scheduler; | 38 std::unique_ptr<DisplayScheduler> scheduler; |
40 if (!synchronous_composite) { | 39 if (!synchronous_composite) { |
41 if (renderer_settings.disable_display_vsync) { | 40 if (renderer_settings.disable_display_vsync) { |
42 begin_frame_source.reset(new BackToBackBeginFrameSource( | 41 begin_frame_source.reset(new BackToBackBeginFrameSource( |
43 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 42 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
44 } else { | 43 } else { |
45 begin_frame_source.reset(new DelayBasedBeginFrameSource( | 44 begin_frame_source.reset(new DelayBasedBeginFrameSource( |
46 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 45 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
47 begin_frame_source->SetAuthoritativeVSyncInterval( | 46 begin_frame_source->SetAuthoritativeVSyncInterval( |
48 base::TimeDelta::FromMilliseconds(1000.f / | 47 base::TimeDelta::FromMilliseconds(1000.f / |
49 renderer_settings.refresh_rate)); | 48 renderer_settings.refresh_rate)); |
50 } | 49 } |
51 scheduler.reset(new DisplayScheduler( | 50 scheduler.reset(new DisplayScheduler( |
52 begin_frame_source.get(), task_runner, | 51 begin_frame_source.get(), task_runner, |
53 display_output_surface->capabilities().max_frames_pending)); | 52 display_output_surface->capabilities().max_frames_pending)); |
54 } | 53 } |
55 const bool context_shared_with_compositor = | 54 const bool context_shared_with_compositor = |
56 display_output_surface->context_provider() == context_provider(); | 55 display_output_surface->context_provider() == context_provider(); |
57 display_.reset( | 56 display_.reset( |
58 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, | 57 new Display(shared_bitmap_manager, gpu_memory_buffer_manager, |
59 renderer_settings, std::move(begin_frame_source), | 58 renderer_settings, std::move(begin_frame_source), |
60 std::move(display_output_surface), std::move(scheduler), | 59 std::move(display_output_surface), std::move(scheduler), |
61 base::MakeUnique<TextureMailboxDeleter>(task_runner))); | 60 base::MakeUnique<TextureMailboxDeleter>(task_runner))); |
62 | 61 |
63 capabilities_.delegated_rendering = true; | |
64 // Since this CompositorFrameSink and the Display are tightly coupled and in | 62 // Since this CompositorFrameSink and the Display are tightly coupled and in |
65 // the same process/thread, the LayerTreeHostImpl can reclaim resources from | 63 // the same process/thread, the LayerTreeHostImpl can reclaim resources from |
66 // the Display. But we allow tests to disable this to mimic an out-of-process | 64 // the Display. But we allow tests to disable this to mimic an out-of-process |
67 // Display. | 65 // Display. |
68 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; | 66 capabilities_.can_force_reclaim_resources = !force_disable_reclaim_resources; |
69 capabilities_.delegated_sync_points_required = | 67 capabilities_.delegated_sync_points_required = |
70 !context_shared_with_compositor; | 68 !context_shared_with_compositor; |
71 } | 69 } |
72 | 70 |
73 TestCompositorFrameSink::~TestCompositorFrameSink() { | 71 TestCompositorFrameSink::~TestCompositorFrameSink() { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 | 165 |
168 void TestCompositorFrameSink::ForceReclaimResources() { | 166 void TestCompositorFrameSink::ForceReclaimResources() { |
169 if (capabilities_.can_force_reclaim_resources && | 167 if (capabilities_.can_force_reclaim_resources && |
170 !delegated_surface_id_.is_null()) { | 168 !delegated_surface_id_.is_null()) { |
171 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, | 169 surface_factory_->SubmitCompositorFrame(delegated_surface_id_, |
172 CompositorFrame(), | 170 CompositorFrame(), |
173 SurfaceFactory::DrawCallback()); | 171 SurfaceFactory::DrawCallback()); |
174 } | 172 } |
175 } | 173 } |
176 | 174 |
177 void TestCompositorFrameSink::BindFramebuffer() { | |
178 // This is a delegating output surface, no framebuffer/direct drawing support. | |
179 NOTREACHED(); | |
180 } | |
181 | |
182 uint32_t TestCompositorFrameSink::GetFramebufferCopyTextureFormat() { | |
183 // This is a delegating output surface, no framebuffer/direct drawing support. | |
184 NOTREACHED(); | |
185 return 0; | |
186 } | |
187 | |
188 void TestCompositorFrameSink::ReturnResources( | 175 void TestCompositorFrameSink::ReturnResources( |
189 const ReturnedResourceArray& resources) { | 176 const ReturnedResourceArray& resources) { |
190 client_->ReclaimResources(resources); | 177 client_->ReclaimResources(resources); |
191 } | 178 } |
192 | 179 |
193 void TestCompositorFrameSink::SetBeginFrameSource( | 180 void TestCompositorFrameSink::SetBeginFrameSource( |
194 BeginFrameSource* begin_frame_source) { | 181 BeginFrameSource* begin_frame_source) { |
195 client_->SetBeginFrameSource(begin_frame_source); | 182 client_->SetBeginFrameSource(begin_frame_source); |
196 } | 183 } |
197 | 184 |
198 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { | 185 void TestCompositorFrameSink::DisplayOutputSurfaceLost() { |
199 client_->DidLoseCompositorFrameSink(); | 186 client_->DidLoseCompositorFrameSink(); |
200 } | 187 } |
201 | 188 |
202 void TestCompositorFrameSink::DisplayWillDrawAndSwap( | 189 void TestCompositorFrameSink::DisplayWillDrawAndSwap( |
203 bool will_draw_and_swap, | 190 bool will_draw_and_swap, |
204 const RenderPassList& render_passes) { | 191 const RenderPassList& render_passes) { |
205 if (test_client_) | 192 if (test_client_) |
206 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 193 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
207 } | 194 } |
208 | 195 |
209 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 196 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
210 if (test_client_) | 197 if (test_client_) |
211 test_client_->DisplayDidDrawAndSwap(); | 198 test_client_->DisplayDidDrawAndSwap(); |
212 } | 199 } |
213 | 200 |
214 } // namespace cc | 201 } // namespace cc |
OLD | NEW |