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 "services/ui/surfaces/display_compositor.h" | 5 #include "services/ui/surfaces/compositor_frame_sink.h" |
6 | 6 |
7 #include "cc/output/copy_output_request.h" | 7 #include "cc/output/copy_output_request.h" |
8 #include "cc/output/output_surface.h" | 8 #include "cc/output/output_surface.h" |
9 #include "cc/output/renderer_settings.h" | 9 #include "cc/output/renderer_settings.h" |
10 #include "cc/output/texture_mailbox_deleter.h" | 10 #include "cc/output/texture_mailbox_deleter.h" |
11 #include "cc/scheduler/begin_frame_source.h" | 11 #include "cc/scheduler/begin_frame_source.h" |
12 #include "cc/scheduler/delay_based_time_source.h" | 12 #include "cc/scheduler/delay_based_time_source.h" |
13 #include "cc/surfaces/display.h" | 13 #include "cc/surfaces/display.h" |
14 #include "cc/surfaces/display_scheduler.h" | 14 #include "cc/surfaces/display_scheduler.h" |
15 #include "cc/surfaces/frame_sink_id.h" | 15 #include "cc/surfaces/frame_sink_id.h" |
16 #include "gpu/ipc/client/gpu_channel_host.h" | 16 #include "gpu/ipc/client/gpu_channel_host.h" |
17 #include "services/ui/surfaces/direct_output_surface.h" | 17 #include "services/ui/surfaces/direct_output_surface.h" |
18 #include "services/ui/surfaces/surfaces_context_provider.h" | 18 #include "services/ui/surfaces/surfaces_context_provider.h" |
19 | 19 |
20 #if defined(USE_OZONE) | 20 #if defined(USE_OZONE) |
21 #include "gpu/command_buffer/client/gles2_interface.h" | 21 #include "gpu/command_buffer/client/gles2_interface.h" |
22 #include "services/ui/surfaces/direct_output_surface_ozone.h" | 22 #include "services/ui/surfaces/direct_output_surface_ozone.h" |
23 #endif | 23 #endif |
24 | 24 |
25 namespace ui { | 25 namespace ui { |
| 26 namespace surfaces { |
26 | 27 |
27 DisplayCompositor::DisplayCompositor( | 28 CompositorFrameSink::CompositorFrameSink( |
28 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 29 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
29 gfx::AcceleratedWidget widget, | 30 gfx::AcceleratedWidget widget, |
30 scoped_refptr<gpu::GpuChannelHost> gpu_channel, | 31 scoped_refptr<gpu::GpuChannelHost> gpu_channel, |
31 const scoped_refptr<SurfacesState>& surfaces_state) | 32 const scoped_refptr<DisplayCompositor>& display_compositor) |
32 : task_runner_(task_runner), | 33 : task_runner_(task_runner), |
33 surfaces_state_(surfaces_state), | 34 display_compositor_(display_compositor), |
34 factory_(surfaces_state->manager(), this), | 35 factory_(display_compositor->manager(), this), |
35 allocator_(cc::FrameSinkId(surfaces_state->next_client_id(), 0)) { | 36 allocator_( |
36 surfaces_state_->manager()->RegisterFrameSinkId(allocator_.frame_sink_id()); | 37 cc::FrameSinkId(display_compositor->GenerateNextClientId(), 0)) { |
37 surfaces_state_->manager()->RegisterSurfaceFactoryClient( | 38 display_compositor_->manager()->RegisterFrameSinkId( |
| 39 allocator_.frame_sink_id()); |
| 40 display_compositor_->manager()->RegisterSurfaceFactoryClient( |
38 allocator_.frame_sink_id(), this); | 41 allocator_.frame_sink_id(), this); |
39 | 42 |
40 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = | 43 gpu::GpuMemoryBufferManager* gpu_memory_buffer_manager = |
41 gpu_channel->gpu_memory_buffer_manager(); | 44 gpu_channel->gpu_memory_buffer_manager(); |
42 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( | 45 scoped_refptr<SurfacesContextProvider> surfaces_context_provider( |
43 new SurfacesContextProvider(widget, std::move(gpu_channel))); | 46 new SurfacesContextProvider(widget, std::move(gpu_channel))); |
44 // TODO(rjkroege): If there is something better to do than CHECK, add it. | 47 // TODO(rjkroege): If there is something better to do than CHECK, add it. |
45 CHECK(surfaces_context_provider->BindToCurrentThread()); | 48 CHECK(surfaces_context_provider->BindToCurrentThread()); |
46 | 49 |
47 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( | 50 std::unique_ptr<cc::SyntheticBeginFrameSource> synthetic_begin_frame_source( |
(...skipping 20 matching lines...) Expand all Loading... |
68 | 71 |
69 std::unique_ptr<cc::DisplayScheduler> scheduler( | 72 std::unique_ptr<cc::DisplayScheduler> scheduler( |
70 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), | 73 new cc::DisplayScheduler(synthetic_begin_frame_source.get(), |
71 task_runner_.get(), max_frames_pending)); | 74 task_runner_.get(), max_frames_pending)); |
72 | 75 |
73 display_.reset(new cc::Display( | 76 display_.reset(new cc::Display( |
74 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, | 77 nullptr /* bitmap_manager */, gpu_memory_buffer_manager, |
75 cc::RendererSettings(), std::move(synthetic_begin_frame_source), | 78 cc::RendererSettings(), std::move(synthetic_begin_frame_source), |
76 std::move(display_output_surface), std::move(scheduler), | 79 std::move(display_output_surface), std::move(scheduler), |
77 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); | 80 base::MakeUnique<cc::TextureMailboxDeleter>(task_runner_.get()))); |
78 display_->Initialize(this, surfaces_state_->manager(), | 81 display_->Initialize(this, display_compositor_->manager(), |
79 allocator_.frame_sink_id()); | 82 allocator_.frame_sink_id()); |
80 display_->SetVisible(true); | 83 display_->SetVisible(true); |
81 } | 84 } |
82 | 85 |
83 DisplayCompositor::~DisplayCompositor() { | 86 CompositorFrameSink::~CompositorFrameSink() { |
84 surfaces_state_->manager()->UnregisterSurfaceFactoryClient( | 87 display_compositor_->manager()->UnregisterSurfaceFactoryClient( |
85 allocator_.frame_sink_id()); | 88 allocator_.frame_sink_id()); |
86 surfaces_state_->manager()->InvalidateFrameSinkId(allocator_.frame_sink_id()); | 89 display_compositor_->manager()->InvalidateFrameSinkId( |
| 90 allocator_.frame_sink_id()); |
87 } | 91 } |
88 | 92 |
89 void DisplayCompositor::SubmitCompositorFrame( | 93 void CompositorFrameSink::SubmitCompositorFrame( |
90 cc::CompositorFrame frame, | 94 cc::CompositorFrame frame, |
91 const base::Callback<void()>& callback) { | 95 const base::Callback<void()>& callback) { |
92 gfx::Size frame_size = | 96 gfx::Size frame_size = |
93 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); | 97 frame.delegated_frame_data->render_pass_list.back()->output_rect.size(); |
94 if (frame_size.IsEmpty() || frame_size != display_size_) { | 98 if (frame_size.IsEmpty() || frame_size != display_size_) { |
95 if (!surface_id_.is_null()) | 99 if (!surface_id_.is_null()) |
96 factory_.Destroy(surface_id_); | 100 factory_.Destroy(surface_id_); |
97 surface_id_ = allocator_.GenerateId(); | 101 surface_id_ = allocator_.GenerateId(); |
98 factory_.Create(surface_id_); | 102 factory_.Create(surface_id_); |
99 display_size_ = frame_size; | 103 display_size_ = frame_size; |
100 display_->Resize(display_size_); | 104 display_->Resize(display_size_); |
101 } | 105 } |
102 display_->SetSurfaceId(surface_id_, frame.metadata.device_scale_factor); | 106 display_->SetSurfaceId(surface_id_, frame.metadata.device_scale_factor); |
103 factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback); | 107 factory_.SubmitCompositorFrame(surface_id_, std::move(frame), callback); |
104 } | 108 } |
105 | 109 |
106 void DisplayCompositor::RequestCopyOfOutput( | 110 void CompositorFrameSink::RequestCopyOfOutput( |
107 std::unique_ptr<cc::CopyOutputRequest> output_request) { | 111 std::unique_ptr<cc::CopyOutputRequest> output_request) { |
108 factory_.RequestCopyOfSurface(surface_id_, std::move(output_request)); | 112 factory_.RequestCopyOfSurface(surface_id_, std::move(output_request)); |
109 } | 113 } |
110 | 114 |
111 void DisplayCompositor::ReturnResources( | 115 void CompositorFrameSink::ReturnResources( |
112 const cc::ReturnedResourceArray& resources) { | 116 const cc::ReturnedResourceArray& resources) { |
113 // TODO(fsamuel): Implement this. | 117 // TODO(fsamuel): Implement this. |
114 } | 118 } |
115 | 119 |
116 void DisplayCompositor::SetBeginFrameSource( | 120 void CompositorFrameSink::SetBeginFrameSource( |
117 cc::BeginFrameSource* begin_frame_source) { | 121 cc::BeginFrameSource* begin_frame_source) { |
118 // TODO(fsamuel): Implement this. | 122 // TODO(fsamuel): Implement this. |
119 } | 123 } |
120 | 124 |
121 void DisplayCompositor::DisplayOutputSurfaceLost() { | 125 void CompositorFrameSink::DisplayOutputSurfaceLost() { |
122 // TODO(fsamuel): This looks like it would crash if a frame was in flight and | 126 // TODO(fsamuel): This looks like it would crash if a frame was in flight and |
123 // will be submitted. | 127 // will be submitted. |
124 display_.reset(); | 128 display_.reset(); |
125 } | 129 } |
126 | 130 |
127 void DisplayCompositor::DisplayWillDrawAndSwap( | 131 void CompositorFrameSink::DisplayWillDrawAndSwap( |
128 bool will_draw_and_swap, | 132 bool will_draw_and_swap, |
129 const cc::RenderPassList& render_passes) { | 133 const cc::RenderPassList& render_passes) { |
130 // This notification is not relevant to our client outside of tests. | 134 // This notification is not relevant to our client outside of tests. |
131 } | 135 } |
132 | 136 |
133 void DisplayCompositor::DisplayDidDrawAndSwap() { | 137 void CompositorFrameSink::DisplayDidDrawAndSwap() { |
134 // This notification is not relevant to our client outside of tests. We | 138 // This notification is not relevant to our client outside of tests. We |
135 // unblock the client from the DrawCallback when the surface is going to | 139 // unblock the client from the DrawCallback when the surface is going to |
136 // be drawn. | 140 // be drawn. |
137 } | 141 } |
138 | 142 |
| 143 } // namespace surfaces |
139 } // namespace ui | 144 } // namespace ui |
OLD | NEW |