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