Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: services/ui/gpu/gpu_main.cc

Issue 2559183003: mus: More gpu-related renames. (Closed)
Patch Set: . Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/ui/gpu/gpu_main.h ('k') | services/ui/gpu/gpu_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/gpu/gpu_main.h" 5 #include "services/ui/gpu/gpu_main.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 9 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
10 #include "gpu/ipc/gpu_in_process_thread_service.h" 10 #include "gpu/ipc/gpu_in_process_thread_service.h"
11 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 11 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
12 #include "gpu/ipc/service/gpu_watchdog_thread.h" 12 #include "gpu/ipc/service/gpu_watchdog_thread.h"
13 #include "services/ui/common/server_gpu_memory_buffer_manager.h" 13 #include "services/ui/common/server_gpu_memory_buffer_manager.h"
14 #include "services/ui/gpu/gpu_service_internal.h" 14 #include "services/ui/gpu/gpu_service.h"
15 15
16 namespace { 16 namespace {
17 17
18 #if defined(OS_WIN) 18 #if defined(OS_WIN)
19 std::unique_ptr<base::MessagePump> CreateMessagePumpWin() { 19 std::unique_ptr<base::MessagePump> CreateMessagePumpWin() {
20 base::MessagePumpForGpu::InitFactory(); 20 base::MessagePumpForGpu::InitFactory();
21 return base::MessageLoop::CreateMessagePumpForType( 21 return base::MessageLoop::CreateMessagePumpForType(
22 base::MessageLoop::TYPE_UI); 22 base::MessageLoop::TYPE_UI);
23 } 23 }
24 #endif // defined(OS_WIN) 24 #endif // defined(OS_WIN)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 void GpuMain::OnStart() { 104 void GpuMain::OnStart() {
105 // |this| will outlive the gpu thread and so it's safe to use 105 // |this| will outlive the gpu thread and so it's safe to use
106 // base::Unretained here. 106 // base::Unretained here.
107 gpu_thread_.task_runner()->PostTask( 107 gpu_thread_.task_runner()->PostTask(
108 FROM_HERE, 108 FROM_HERE,
109 base::Bind(&GpuMain::InitOnGpuThread, base::Unretained(this), 109 base::Bind(&GpuMain::InitOnGpuThread, base::Unretained(this),
110 io_thread_.task_runner(), compositor_thread_.task_runner())); 110 io_thread_.task_runner(), compositor_thread_.task_runner()));
111 } 111 }
112 112
113 void GpuMain::CreateGpuService(mojom::GpuServiceInternalRequest request, 113 void GpuMain::CreateGpuService(mojom::GpuServiceRequest request,
114 mojom::GpuServiceHostPtr gpu_host) { 114 mojom::GpuHostPtr gpu_host) {
115 // |this| will outlive the gpu thread and so it's safe to use 115 // |this| will outlive the gpu thread and so it's safe to use
116 // base::Unretained here. 116 // base::Unretained here.
117 gpu_thread_.task_runner()->PostTask( 117 gpu_thread_.task_runner()->PostTask(
118 FROM_HERE, 118 FROM_HERE,
119 base::Bind(&GpuMain::CreateGpuServiceOnGpuThread, base::Unretained(this), 119 base::Bind(&GpuMain::CreateGpuServiceOnGpuThread, base::Unretained(this),
120 base::Passed(std::move(request)), 120 base::Passed(std::move(request)),
121 base::Passed(gpu_host.PassInterface()))); 121 base::Passed(gpu_host.PassInterface())));
122 } 122 }
123 123
124 void GpuMain::CreateDisplayCompositor( 124 void GpuMain::CreateDisplayCompositor(
125 cc::mojom::DisplayCompositorRequest request, 125 cc::mojom::DisplayCompositorRequest request,
126 cc::mojom::DisplayCompositorClientPtr client) { 126 cc::mojom::DisplayCompositorClientPtr client) {
127 if (!gpu_service_internal_) { 127 if (!gpu_service_) {
128 pending_display_compositor_request_ = std::move(request); 128 pending_display_compositor_request_ = std::move(request);
129 pending_display_compositor_client_info_ = client.PassInterface(); 129 pending_display_compositor_client_info_ = client.PassInterface();
130 return; 130 return;
131 } 131 }
132 CreateDisplayCompositorInternal(std::move(request), client.PassInterface()); 132 CreateDisplayCompositorInternal(std::move(request), client.PassInterface());
133 } 133 }
134 134
135 void GpuMain::InitOnGpuThread( 135 void GpuMain::InitOnGpuThread(
136 scoped_refptr<base::SingleThreadTaskRunner> io_runner, 136 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
137 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner) { 137 scoped_refptr<base::SingleThreadTaskRunner> compositor_runner) {
138 gpu_init_.reset(new gpu::GpuInit()); 138 gpu_init_.reset(new gpu::GpuInit());
139 gpu_init_->set_sandbox_helper(this); 139 gpu_init_->set_sandbox_helper(this);
140 bool success = gpu_init_->InitializeAndStartSandbox( 140 bool success = gpu_init_->InitializeAndStartSandbox(
141 *base::CommandLine::ForCurrentProcess()); 141 *base::CommandLine::ForCurrentProcess());
142 if (!success) 142 if (!success)
143 return; 143 return;
144 144
145 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) { 145 if (gpu::GetNativeGpuMemoryBufferType() != gfx::EMPTY_BUFFER) {
146 gpu_memory_buffer_factory_ = 146 gpu_memory_buffer_factory_ =
147 gpu::GpuMemoryBufferFactory::CreateNativeType(); 147 gpu::GpuMemoryBufferFactory::CreateNativeType();
148 } 148 }
149 149
150 gpu_service_internal_ = base::MakeUnique<GpuServiceInternal>( 150 gpu_service_ = base::MakeUnique<GpuService>(
151 gpu_init_->gpu_info(), gpu_init_->TakeWatchdogThread(), 151 gpu_init_->gpu_info(), gpu_init_->TakeWatchdogThread(),
152 gpu_memory_buffer_factory_.get(), io_runner); 152 gpu_memory_buffer_factory_.get(), io_runner);
153 } 153 }
154 154
155 void GpuMain::CreateDisplayCompositorInternal( 155 void GpuMain::CreateDisplayCompositorInternal(
156 cc::mojom::DisplayCompositorRequest request, 156 cc::mojom::DisplayCompositorRequest request,
157 cc::mojom::DisplayCompositorClientPtrInfo client_info) { 157 cc::mojom::DisplayCompositorClientPtrInfo client_info) {
158 DCHECK(!gpu_command_service_); 158 DCHECK(!gpu_command_service_);
159 gpu_command_service_ = new gpu::GpuInProcessThreadService( 159 gpu_command_service_ = new gpu::GpuInProcessThreadService(
160 gpu_thread_.task_runner(), gpu_service_internal_->sync_point_manager(), 160 gpu_thread_.task_runner(), gpu_service_->sync_point_manager(),
161 gpu_service_internal_->mailbox_manager(), 161 gpu_service_->mailbox_manager(), gpu_service_->share_group());
162 gpu_service_internal_->share_group());
163 162
164 // |gpu_memory_buffer_factory_| is null in tests. 163 // |gpu_memory_buffer_factory_| is null in tests.
165 gpu::ImageFactory* image_factory = 164 gpu::ImageFactory* image_factory =
166 gpu_memory_buffer_factory_ ? gpu_memory_buffer_factory_->AsImageFactory() 165 gpu_memory_buffer_factory_ ? gpu_memory_buffer_factory_->AsImageFactory()
167 : nullptr; 166 : nullptr;
168 167
169 mojom::GpuServiceInternalPtr gpu_service; 168 mojom::GpuServicePtr gpu_service;
170 mojom::GpuServiceInternalRequest gpu_service_request = 169 mojom::GpuServiceRequest gpu_service_request = mojo::GetProxy(&gpu_service);
171 mojo::GetProxy(&gpu_service);
172 170
173 if (gpu_thread_.task_runner()->BelongsToCurrentThread()) { 171 if (gpu_thread_.task_runner()->BelongsToCurrentThread()) {
174 // If the DisplayCompositor creation was delayed because GpuServiceInternal 172 // If the DisplayCompositor creation was delayed because GpuService
175 // had not been created yet, then this is called, in gpu thread, right after 173 // had not been created yet, then this is called, in gpu thread, right after
176 // GpuServiceInternal is created. 174 // GpuService is created.
177 BindGpuInternalOnGpuThread(std::move(gpu_service_request)); 175 BindGpuInternalOnGpuThread(std::move(gpu_service_request));
178 } else { 176 } else {
179 gpu_thread_.task_runner()->PostTask( 177 gpu_thread_.task_runner()->PostTask(
180 FROM_HERE, 178 FROM_HERE,
181 base::Bind(&GpuMain::BindGpuInternalOnGpuThread, base::Unretained(this), 179 base::Bind(&GpuMain::BindGpuInternalOnGpuThread, base::Unretained(this),
182 base::Passed(std::move(gpu_service_request)))); 180 base::Passed(std::move(gpu_service_request))));
183 } 181 }
184 182
185 compositor_thread_.task_runner()->PostTask( 183 compositor_thread_.task_runner()->PostTask(
186 FROM_HERE, base::Bind(&GpuMain::CreateDisplayCompositorOnCompositorThread, 184 FROM_HERE, base::Bind(&GpuMain::CreateDisplayCompositorOnCompositorThread,
187 base::Unretained(this), image_factory, 185 base::Unretained(this), image_factory,
188 base::Passed(gpu_service.PassInterface()), 186 base::Passed(gpu_service.PassInterface()),
189 base::Passed(std::move(request)), 187 base::Passed(std::move(request)),
190 base::Passed(std::move(client_info)))); 188 base::Passed(std::move(client_info))));
191 } 189 }
192 190
193 void GpuMain::CreateDisplayCompositorOnCompositorThread( 191 void GpuMain::CreateDisplayCompositorOnCompositorThread(
194 gpu::ImageFactory* image_factory, 192 gpu::ImageFactory* image_factory,
195 mojom::GpuServiceInternalPtrInfo gpu_service_info, 193 mojom::GpuServicePtrInfo gpu_service_info,
196 cc::mojom::DisplayCompositorRequest request, 194 cc::mojom::DisplayCompositorRequest request,
197 cc::mojom::DisplayCompositorClientPtrInfo client_info) { 195 cc::mojom::DisplayCompositorClientPtrInfo client_info) {
198 DCHECK(!display_compositor_); 196 DCHECK(!display_compositor_);
199 cc::mojom::DisplayCompositorClientPtr client; 197 cc::mojom::DisplayCompositorClientPtr client;
200 client.Bind(std::move(client_info)); 198 client.Bind(std::move(client_info));
201 199
202 gpu_internal_.Bind(std::move(gpu_service_info)); 200 gpu_internal_.Bind(std::move(gpu_service_info));
203 201
204 display_compositor_ = base::MakeUnique<DisplayCompositor>( 202 display_compositor_ = base::MakeUnique<DisplayCompositor>(
205 gpu_command_service_, base::MakeUnique<ServerGpuMemoryBufferManager>( 203 gpu_command_service_, base::MakeUnique<ServerGpuMemoryBufferManager>(
206 gpu_internal_.get(), 1 /* client_id */), 204 gpu_internal_.get(), 1 /* client_id */),
207 image_factory, std::move(request), std::move(client)); 205 image_factory, std::move(request), std::move(client));
208 } 206 }
209 207
210 void GpuMain::TearDownOnCompositorThread() { 208 void GpuMain::TearDownOnCompositorThread() {
211 display_compositor_.reset(); 209 display_compositor_.reset();
212 gpu_internal_.reset(); 210 gpu_internal_.reset();
213 } 211 }
214 212
215 void GpuMain::TearDownOnGpuThread() { 213 void GpuMain::TearDownOnGpuThread() {
216 gpu_service_internal_.reset(); 214 gpu_service_.reset();
217 gpu_memory_buffer_factory_.reset(); 215 gpu_memory_buffer_factory_.reset();
218 gpu_init_.reset(); 216 gpu_init_.reset();
219 } 217 }
220 218
221 void GpuMain::CreateGpuServiceOnGpuThread( 219 void GpuMain::CreateGpuServiceOnGpuThread(
222 mojom::GpuServiceInternalRequest request, 220 mojom::GpuServiceRequest request,
223 mojom::GpuServiceHostPtrInfo gpu_host_info) { 221 mojom::GpuHostPtrInfo gpu_host_info) {
224 mojom::GpuServiceHostPtr gpu_host; 222 mojom::GpuHostPtr gpu_host;
225 gpu_host.Bind(std::move(gpu_host_info)); 223 gpu_host.Bind(std::move(gpu_host_info));
226 gpu_service_internal_->InitializeWithHost(std::move(gpu_host)); 224 gpu_service_->InitializeWithHost(std::move(gpu_host));
227 gpu_service_internal_->Bind(std::move(request)); 225 gpu_service_->Bind(std::move(request));
228 226
229 if (pending_display_compositor_request_.is_pending()) { 227 if (pending_display_compositor_request_.is_pending()) {
230 CreateDisplayCompositorInternal( 228 CreateDisplayCompositorInternal(
231 std::move(pending_display_compositor_request_), 229 std::move(pending_display_compositor_request_),
232 std::move(pending_display_compositor_client_info_)); 230 std::move(pending_display_compositor_client_info_));
233 } 231 }
234 } 232 }
235 233
236 void GpuMain::BindGpuInternalOnGpuThread( 234 void GpuMain::BindGpuInternalOnGpuThread(mojom::GpuServiceRequest request) {
237 mojom::GpuServiceInternalRequest request) { 235 gpu_service_->Bind(std::move(request));
238 gpu_service_internal_->Bind(std::move(request));
239 } 236 }
240 237
241 void GpuMain::PreSandboxStartup() { 238 void GpuMain::PreSandboxStartup() {
242 // TODO(sad): https://crbug.com/645602 239 // TODO(sad): https://crbug.com/645602
243 } 240 }
244 241
245 bool GpuMain::EnsureSandboxInitialized( 242 bool GpuMain::EnsureSandboxInitialized(
246 gpu::GpuWatchdogThread* watchdog_thread) { 243 gpu::GpuWatchdogThread* watchdog_thread) {
247 // TODO(sad): https://crbug.com/645602 244 // TODO(sad): https://crbug.com/645602
248 return true; 245 return true;
249 } 246 }
250 247
251 } // namespace ui 248 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_main.h ('k') | services/ui/gpu/gpu_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698