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" |
11 #include "cc/output/compositor_frame_sink_client.h" | 11 #include "cc/output/compositor_frame_sink_client.h" |
12 #include "cc/output/copy_output_request.h" | 12 #include "cc/output/copy_output_request.h" |
13 #include "cc/output/direct_renderer.h" | 13 #include "cc/output/direct_renderer.h" |
14 #include "cc/output/output_surface.h" | 14 #include "cc/output/output_surface.h" |
15 #include "cc/output/texture_mailbox_deleter.h" | 15 #include "cc/output/texture_mailbox_deleter.h" |
16 | 16 |
17 static constexpr uint32_t kCompositorClientId = 1; | 17 static constexpr uint32_t kCompositorClientId = 1; |
| 18 static constexpr uint32_t kCompositorSinkId = 1; |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 | 21 |
21 TestCompositorFrameSink::TestCompositorFrameSink( | 22 TestCompositorFrameSink::TestCompositorFrameSink( |
22 scoped_refptr<ContextProvider> compositor_context_provider, | 23 scoped_refptr<ContextProvider> compositor_context_provider, |
23 scoped_refptr<ContextProvider> worker_context_provider, | 24 scoped_refptr<ContextProvider> worker_context_provider, |
24 std::unique_ptr<OutputSurface> display_output_surface, | 25 std::unique_ptr<OutputSurface> display_output_surface, |
25 SharedBitmapManager* shared_bitmap_manager, | 26 SharedBitmapManager* shared_bitmap_manager, |
26 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, | 27 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager, |
27 const RendererSettings& renderer_settings, | 28 const RendererSettings& renderer_settings, |
28 base::SingleThreadTaskRunner* task_runner, | 29 base::SingleThreadTaskRunner* task_runner, |
29 bool synchronous_composite, | 30 bool synchronous_composite, |
30 bool force_disable_reclaim_resources) | 31 bool force_disable_reclaim_resources) |
31 : CompositorFrameSink(std::move(compositor_context_provider), | 32 : CompositorFrameSink(std::move(compositor_context_provider), |
32 std::move(worker_context_provider)), | 33 std::move(worker_context_provider)), |
33 surface_manager_(new SurfaceManager), | 34 surface_manager_(new SurfaceManager(nullptr)), |
34 surface_id_allocator_(new SurfaceIdAllocator(kCompositorClientId)), | 35 surface_id_allocator_(new SurfaceIdAllocator( |
| 36 FrameSinkId(kCompositorClientId, kCompositorSinkId))), |
35 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), | 37 surface_factory_(new SurfaceFactory(surface_manager_.get(), this)), |
36 weak_ptrs_(this) { | 38 weak_ptrs_(this) { |
37 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; | 39 std::unique_ptr<SyntheticBeginFrameSource> begin_frame_source; |
38 std::unique_ptr<DisplayScheduler> scheduler; | 40 std::unique_ptr<DisplayScheduler> scheduler; |
39 if (!synchronous_composite) { | 41 if (!synchronous_composite) { |
40 if (renderer_settings.disable_display_vsync) { | 42 if (renderer_settings.disable_display_vsync) { |
41 begin_frame_source.reset(new BackToBackBeginFrameSource( | 43 begin_frame_source.reset(new BackToBackBeginFrameSource( |
42 base::MakeUnique<DelayBasedTimeSource>(task_runner))); | 44 base::MakeUnique<DelayBasedTimeSource>(task_runner))); |
43 } else { | 45 } else { |
44 begin_frame_source.reset(new DelayBasedBeginFrameSource( | 46 begin_frame_source.reset(new DelayBasedBeginFrameSource( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 if (!CompositorFrameSink::BindToClient(client)) | 83 if (!CompositorFrameSink::BindToClient(client)) |
82 return false; | 84 return false; |
83 | 85 |
84 // We want the Display's OutputSurface to hear about lost context, and since | 86 // We want the Display's OutputSurface to hear about lost context, and since |
85 // this shares a context with it (when delegated_sync_points_required is | 87 // this shares a context with it (when delegated_sync_points_required is |
86 // false), we should not be listening for lost context callbacks on the | 88 // false), we should not be listening for lost context callbacks on the |
87 // context here. | 89 // context here. |
88 if (!capabilities_.delegated_sync_points_required && context_provider()) | 90 if (!capabilities_.delegated_sync_points_required && context_provider()) |
89 context_provider()->SetLostContextCallback(base::Closure()); | 91 context_provider()->SetLostContextCallback(base::Closure()); |
90 | 92 |
91 surface_manager_->RegisterSurfaceClientId(surface_id_allocator_->client_id()); | 93 surface_manager_->RegisterFrameSinkId(surface_id_allocator_->frame_sink_id()); |
92 surface_manager_->RegisterSurfaceFactoryClient( | 94 surface_manager_->RegisterSurfaceFactoryClient( |
93 surface_id_allocator_->client_id(), this); | 95 surface_id_allocator_->frame_sink_id(), this); |
94 display_->Initialize(this, surface_manager_.get(), | 96 display_->Initialize(this, surface_manager_.get(), |
95 surface_id_allocator_->client_id()); | 97 surface_id_allocator_->frame_sink_id()); |
96 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( | 98 display_->renderer_for_testing()->SetEnlargePassTextureAmountForTesting( |
97 enlarge_pass_texture_amount_); | 99 enlarge_pass_texture_amount_); |
98 display_->SetVisible(true); | 100 display_->SetVisible(true); |
99 bound_ = true; | 101 bound_ = true; |
100 return true; | 102 return true; |
101 } | 103 } |
102 | 104 |
103 void TestCompositorFrameSink::DetachFromClient() { | 105 void TestCompositorFrameSink::DetachFromClient() { |
104 // Some tests make BindToClient fail on purpose. ^__^ | 106 // Some tests make BindToClient fail on purpose. ^__^ |
105 if (bound_) { | 107 if (bound_) { |
106 if (!delegated_surface_id_.is_null()) | 108 if (!delegated_surface_id_.is_null()) |
107 surface_factory_->Destroy(delegated_surface_id_); | 109 surface_factory_->Destroy(delegated_surface_id_); |
108 surface_manager_->UnregisterSurfaceFactoryClient( | 110 surface_manager_->UnregisterSurfaceFactoryClient( |
109 surface_id_allocator_->client_id()); | 111 surface_id_allocator_->frame_sink_id()); |
110 surface_manager_->InvalidateSurfaceClientId( | 112 surface_manager_->InvalidateFrameSinkId( |
111 surface_id_allocator_->client_id()); | 113 surface_id_allocator_->frame_sink_id()); |
112 bound_ = false; | 114 bound_ = false; |
113 } | 115 } |
114 display_ = nullptr; | 116 display_ = nullptr; |
115 surface_factory_ = nullptr; | 117 surface_factory_ = nullptr; |
116 surface_id_allocator_ = nullptr; | 118 surface_id_allocator_ = nullptr; |
117 surface_manager_ = nullptr; | 119 surface_manager_ = nullptr; |
118 weak_ptrs_.InvalidateWeakPtrs(); | 120 weak_ptrs_.InvalidateWeakPtrs(); |
119 CompositorFrameSink::DetachFromClient(); | 121 CompositorFrameSink::DetachFromClient(); |
120 } | 122 } |
121 | 123 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 if (test_client_) | 194 if (test_client_) |
193 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); | 195 test_client_->DisplayWillDrawAndSwap(will_draw_and_swap, render_passes); |
194 } | 196 } |
195 | 197 |
196 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { | 198 void TestCompositorFrameSink::DisplayDidDrawAndSwap() { |
197 if (test_client_) | 199 if (test_client_) |
198 test_client_->DisplayDidDrawAndSwap(); | 200 test_client_->DisplayDidDrawAndSwap(); |
199 } | 201 } |
200 | 202 |
201 } // namespace cc | 203 } // namespace cc |
OLD | NEW |