OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/gpu/gpu_child_thread.h" | 5 #include "content/gpu/gpu_child_thread.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // The GPU process must never send a synchronous IPC message to the browser | 240 // The GPU process must never send a synchronous IPC message to the browser |
241 // process. This could result in deadlock. | 241 // process. This could result in deadlock. |
242 DCHECK(!msg->is_sync()); | 242 DCHECK(!msg->is_sync()); |
243 | 243 |
244 return ChildThreadImpl::Send(msg); | 244 return ChildThreadImpl::Send(msg); |
245 } | 245 } |
246 | 246 |
247 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { | 247 bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) { |
248 bool handled = true; | 248 bool handled = true; |
249 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) | 249 IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
250 IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) | |
251 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) | 250 IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched) |
252 IPC_MESSAGE_UNHANDLED(handled = false) | 251 IPC_MESSAGE_UNHANDLED(handled = false) |
253 IPC_END_MESSAGE_MAP() | 252 IPC_END_MESSAGE_MAP() |
254 | 253 |
255 return handled; | 254 return handled; |
256 } | 255 } |
257 | 256 |
258 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { | 257 bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { |
259 if (ChildThreadImpl::OnMessageReceived(msg)) | 258 if (ChildThreadImpl::OnMessageReceived(msg)) |
260 return true; | 259 return true; |
(...skipping 16 matching lines...) Expand all Loading... |
277 associated_interfaces_.BindRequest(name, std::move(handle)); | 276 associated_interfaces_.BindRequest(name, std::move(handle)); |
278 else | 277 else |
279 ChildThreadImpl::OnAssociatedInterfaceRequest(name, std::move(handle)); | 278 ChildThreadImpl::OnAssociatedInterfaceRequest(name, std::move(handle)); |
280 } | 279 } |
281 | 280 |
282 void GpuChildThread::CreateGpuService( | 281 void GpuChildThread::CreateGpuService( |
283 ui::mojom::GpuServiceRequest request, | 282 ui::mojom::GpuServiceRequest request, |
284 ui::mojom::GpuHostPtr gpu_host, | 283 ui::mojom::GpuHostPtr gpu_host, |
285 const gpu::GpuPreferences& gpu_preferences, | 284 const gpu::GpuPreferences& gpu_preferences, |
286 mojo::ScopedSharedBufferHandle activity_flags) { | 285 mojo::ScopedSharedBufferHandle activity_flags) { |
| 286 gpu_service_->set_in_host_process(in_browser_process_); |
287 gpu_service_->Bind(std::move(request)); | 287 gpu_service_->Bind(std::move(request)); |
288 | 288 |
289 gpu_info_.video_decode_accelerator_capabilities = | 289 gpu_info_.video_decode_accelerator_capabilities = |
290 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences); | 290 media::GpuVideoDecodeAccelerator::GetCapabilities(gpu_preferences); |
291 gpu_info_.video_encode_accelerator_supported_profiles = | 291 gpu_info_.video_encode_accelerator_supported_profiles = |
292 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences); | 292 media::GpuVideoEncodeAccelerator::GetSupportedProfiles(gpu_preferences); |
293 gpu_info_.jpeg_decode_accelerator_supported = | 293 gpu_info_.jpeg_decode_accelerator_supported = |
294 media::GpuJpegDecodeAcceleratorFactoryProvider:: | 294 media::GpuJpegDecodeAcceleratorFactoryProvider:: |
295 IsAcceleratedJpegDecodeSupported(); | 295 IsAcceleratedJpegDecodeSupported(); |
296 | 296 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 GetInterfaceRegistry()->ResumeBinding(); | 343 GetInterfaceRegistry()->ResumeBinding(); |
344 } | 344 } |
345 | 345 |
346 void GpuChildThread::CreateDisplayCompositor( | 346 void GpuChildThread::CreateDisplayCompositor( |
347 cc::mojom::DisplayCompositorRequest request, | 347 cc::mojom::DisplayCompositorRequest request, |
348 cc::mojom::DisplayCompositorClientPtr client) { | 348 cc::mojom::DisplayCompositorClientPtr client) { |
349 NOTREACHED(); | 349 NOTREACHED(); |
350 } | 350 } |
351 | 351 |
352 void GpuChildThread::OnCollectGraphicsInfo() { | |
353 if (dead_on_arrival_) | |
354 return; | |
355 | |
356 #if defined(OS_MACOSX) | |
357 // gpu::CollectContextGraphicsInfo() is already called during gpu process | |
358 // initialization (see GpuInit::InitializeAndStartSandbox()) on non-mac | |
359 // platforms, and during in-browser gpu thread initialization on all platforms | |
360 // (See InProcessGpuThread::Init()). | |
361 if (!in_browser_process_) { | |
362 DCHECK_EQ(gpu::kCollectInfoNone, gpu_info_.context_info_state); | |
363 gpu::CollectInfoResult result = gpu::CollectContextGraphicsInfo(&gpu_info_); | |
364 switch (result) { | |
365 case gpu::kCollectInfoFatalFailure: | |
366 LOG(ERROR) << "gpu::CollectGraphicsInfo failed (fatal)."; | |
367 // TODO(piman): can we signal overall failure? | |
368 break; | |
369 case gpu::kCollectInfoNonFatalFailure: | |
370 DVLOG(1) << "gpu::CollectGraphicsInfo failed (non-fatal)."; | |
371 break; | |
372 case gpu::kCollectInfoNone: | |
373 NOTREACHED(); | |
374 break; | |
375 case gpu::kCollectInfoSuccess: | |
376 break; | |
377 } | |
378 GetContentClient()->SetGpuInfo(gpu_info_); | |
379 } | |
380 #endif | |
381 | |
382 #if defined(OS_WIN) | |
383 // GPU full info collection should only happen on un-sandboxed GPU process | |
384 // or single process/in-process gpu mode on Windows. | |
385 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
386 DCHECK(command_line->HasSwitch(switches::kDisableGpuSandbox) || | |
387 in_browser_process_); | |
388 | |
389 // This is slow, but it's the only thing the unsandboxed GPU process does, | |
390 // and GpuDataManager prevents us from sending multiple collecting requests, | |
391 // so it's OK to be blocking. | |
392 gpu::GetDxDiagnostics(&gpu_info_.dx_diagnostics); | |
393 gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess; | |
394 #endif // OS_WIN | |
395 | |
396 Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); | |
397 | |
398 #if defined(OS_WIN) | |
399 if (!in_browser_process_) { | |
400 // The unsandboxed GPU process fulfilled its duty. Rest in peace. | |
401 base::MessageLoop::current()->QuitWhenIdle(); | |
402 } | |
403 #endif // OS_WIN | |
404 } | |
405 | |
406 void GpuChildThread::OnGpuSwitched() { | 352 void GpuChildThread::OnGpuSwitched() { |
407 DVLOG(1) << "GPU: GPU has switched"; | 353 DVLOG(1) << "GPU: GPU has switched"; |
408 // Notify observers in the GPU process. | 354 // Notify observers in the GPU process. |
409 if (!in_browser_process_) | 355 if (!in_browser_process_) |
410 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); | 356 ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
411 } | 357 } |
412 | 358 |
413 void GpuChildThread::OnDestroyGpuMemoryBuffer( | 359 void GpuChildThread::OnDestroyGpuMemoryBuffer( |
414 gfx::GpuMemoryBufferId id, | 360 gfx::GpuMemoryBufferId id, |
415 int client_id, | 361 int client_id, |
416 const gpu::SyncToken& sync_token) { | 362 const gpu::SyncToken& sync_token) { |
417 if (gpu_channel_manager()) | 363 if (gpu_channel_manager()) |
418 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token); | 364 gpu_channel_manager()->DestroyGpuMemoryBuffer(id, client_id, sync_token); |
419 } | 365 } |
420 | 366 |
421 void GpuChildThread::BindServiceFactoryRequest( | 367 void GpuChildThread::BindServiceFactoryRequest( |
422 service_manager::mojom::ServiceFactoryRequest request) { | 368 service_manager::mojom::ServiceFactoryRequest request) { |
423 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; | 369 DVLOG(1) << "GPU: Binding service_manager::mojom::ServiceFactoryRequest"; |
424 DCHECK(service_factory_); | 370 DCHECK(service_factory_); |
425 service_factory_bindings_.AddBinding(service_factory_.get(), | 371 service_factory_bindings_.AddBinding(service_factory_.get(), |
426 std::move(request)); | 372 std::move(request)); |
427 } | 373 } |
428 | 374 |
429 } // namespace content | 375 } // namespace content |
OLD | NEW |