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

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

Issue 2559113002: mus/gpu: Introduce the GpuServiceHost mojom interface. (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_internal.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"
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::GpuServiceInternalRequest request,
114 const CreateGpuServiceCallback& callback) { 114 mojom::GpuServiceHostPtr 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::ThreadTaskRunnerHandle::Get(), callback)); 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_internal_) {
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 }
(...skipping 11 matching lines...) Expand all
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_internal_ = base::MakeUnique<GpuServiceInternal>(
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 gpu_service_internal_->Initialize();
154 } 153 }
155 154
156 void GpuMain::CreateDisplayCompositorInternal( 155 void GpuMain::CreateDisplayCompositorInternal(
157 cc::mojom::DisplayCompositorRequest request, 156 cc::mojom::DisplayCompositorRequest request,
158 cc::mojom::DisplayCompositorClientPtrInfo client_info) { 157 cc::mojom::DisplayCompositorClientPtrInfo client_info) {
159 DCHECK(!gpu_command_service_); 158 DCHECK(!gpu_command_service_);
160 gpu_command_service_ = new gpu::GpuInProcessThreadService( 159 gpu_command_service_ = new gpu::GpuInProcessThreadService(
161 gpu_thread_.task_runner(), gpu_service_internal_->sync_point_manager(), 160 gpu_thread_.task_runner(), gpu_service_internal_->sync_point_manager(),
162 gpu_service_internal_->mailbox_manager(), 161 gpu_service_internal_->mailbox_manager(),
163 gpu_service_internal_->share_group()); 162 gpu_service_internal_->share_group());
164 163
165 // |gpu_memory_buffer_factory_| is null in tests. 164 // |gpu_memory_buffer_factory_| is null in tests.
166 gpu::ImageFactory* image_factory = 165 gpu::ImageFactory* image_factory =
167 gpu_memory_buffer_factory_ ? gpu_memory_buffer_factory_->AsImageFactory() 166 gpu_memory_buffer_factory_ ? gpu_memory_buffer_factory_->AsImageFactory()
168 : nullptr; 167 : nullptr;
169 168
170 mojom::GpuServiceInternalPtr gpu_service; 169 mojom::GpuServiceInternalPtr gpu_service;
171 mojom::GpuServiceInternalRequest gpu_service_request = 170 mojom::GpuServiceInternalRequest gpu_service_request =
172 mojo::GetProxy(&gpu_service); 171 mojo::GetProxy(&gpu_service);
173 172
174 CreateGpuService(std::move(gpu_service_request), CreateGpuServiceCallback()); 173 if (gpu_thread_.task_runner()->BelongsToCurrentThread()) {
174 // If the DisplayCompositor creation was delayed because GpuServiceInternal
175 // had not been created yet, then this is called, in gpu thread, right after
176 // GpuServiceInternal is created.
177 BindGpuInternalOnGpuThread(std::move(gpu_service_request));
178 } else {
179 gpu_thread_.task_runner()->PostTask(
180 FROM_HERE,
181 base::Bind(&GpuMain::BindGpuInternalOnGpuThread, base::Unretained(this),
182 base::Passed(std::move(gpu_service_request))));
183 }
175 184
176 compositor_thread_.task_runner()->PostTask( 185 compositor_thread_.task_runner()->PostTask(
177 FROM_HERE, base::Bind(&GpuMain::CreateDisplayCompositorOnCompositorThread, 186 FROM_HERE, base::Bind(&GpuMain::CreateDisplayCompositorOnCompositorThread,
178 base::Unretained(this), image_factory, 187 base::Unretained(this), image_factory,
179 base::Passed(gpu_service.PassInterface()), 188 base::Passed(gpu_service.PassInterface()),
180 base::Passed(std::move(request)), 189 base::Passed(std::move(request)),
181 base::Passed(std::move(client_info)))); 190 base::Passed(std::move(client_info))));
182 } 191 }
183 192
184 void GpuMain::CreateDisplayCompositorOnCompositorThread( 193 void GpuMain::CreateDisplayCompositorOnCompositorThread(
(...skipping 19 matching lines...) Expand all
204 } 213 }
205 214
206 void GpuMain::TearDownOnGpuThread() { 215 void GpuMain::TearDownOnGpuThread() {
207 gpu_service_internal_.reset(); 216 gpu_service_internal_.reset();
208 gpu_memory_buffer_factory_.reset(); 217 gpu_memory_buffer_factory_.reset();
209 gpu_init_.reset(); 218 gpu_init_.reset();
210 } 219 }
211 220
212 void GpuMain::CreateGpuServiceOnGpuThread( 221 void GpuMain::CreateGpuServiceOnGpuThread(
213 mojom::GpuServiceInternalRequest request, 222 mojom::GpuServiceInternalRequest request,
214 scoped_refptr<base::SingleThreadTaskRunner> origin_runner, 223 mojom::GpuServiceHostPtrInfo gpu_host_info) {
215 const CreateGpuServiceCallback& callback) { 224 mojom::GpuServiceHostPtr gpu_host;
225 gpu_host.Bind(std::move(gpu_host_info));
226 gpu_service_internal_->InitializeWithHost(std::move(gpu_host));
216 gpu_service_internal_->Bind(std::move(request)); 227 gpu_service_internal_->Bind(std::move(request));
217 228
218 if (pending_display_compositor_request_.is_pending()) { 229 if (pending_display_compositor_request_.is_pending()) {
219 CreateDisplayCompositorInternal( 230 CreateDisplayCompositorInternal(
220 std::move(pending_display_compositor_request_), 231 std::move(pending_display_compositor_request_),
221 std::move(pending_display_compositor_client_info_)); 232 std::move(pending_display_compositor_client_info_));
222 } 233 }
234 }
223 235
224 if (!callback.is_null()) { 236 void GpuMain::BindGpuInternalOnGpuThread(
225 origin_runner->PostTask( 237 mojom::GpuServiceInternalRequest request) {
226 FROM_HERE, base::Bind(callback, gpu_service_internal_->gpu_info())); 238 gpu_service_internal_->Bind(std::move(request));
227 }
228 } 239 }
229 240
230 void GpuMain::PreSandboxStartup() { 241 void GpuMain::PreSandboxStartup() {
231 // TODO(sad): https://crbug.com/645602 242 // TODO(sad): https://crbug.com/645602
232 } 243 }
233 244
234 bool GpuMain::EnsureSandboxInitialized( 245 bool GpuMain::EnsureSandboxInitialized(
235 gpu::GpuWatchdogThread* watchdog_thread) { 246 gpu::GpuWatchdogThread* watchdog_thread) {
236 // TODO(sad): https://crbug.com/645602 247 // TODO(sad): https://crbug.com/645602
237 return true; 248 return true;
238 } 249 }
239 250
240 } // namespace ui 251 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/gpu/gpu_main.h ('k') | services/ui/gpu/gpu_service_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698