| 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/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "base/metrics/histogram_macros.h" | 23 #include "base/metrics/histogram_macros.h" |
| 24 #include "base/sha1.h" | 24 #include "base/sha1.h" |
| 25 #include "base/threading/thread.h" | 25 #include "base/threading/thread.h" |
| 26 #include "base/threading/thread_task_runner_handle.h" | 26 #include "base/threading/thread_task_runner_handle.h" |
| 27 #include "base/trace_event/trace_event.h" | 27 #include "base/trace_event/trace_event.h" |
| 28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
| 29 #include "components/tracing/common/tracing_switches.h" | 29 #include "components/tracing/common/tracing_switches.h" |
| 30 #include "content/browser/browser_child_process_host_impl.h" | 30 #include "content/browser/browser_child_process_host_impl.h" |
| 31 #include "content/browser/gpu/compositor_util.h" | 31 #include "content/browser/gpu/compositor_util.h" |
| 32 #include "content/browser/gpu/gpu_data_manager_impl.h" | 32 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 33 #include "content/browser/gpu/gpu_main_thread_factory.h" |
| 33 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 34 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 34 #include "content/browser/gpu/shader_cache_factory.h" | 35 #include "content/browser/gpu/shader_cache_factory.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 36 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 36 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" | 37 #include "content/browser/renderer_host/render_widget_host_view_frame_subscriber
.h" |
| 37 #include "content/browser/service_manager/service_manager_context.h" | 38 #include "content/browser/service_manager/service_manager_context.h" |
| 38 #include "content/common/child_process_host_impl.h" | 39 #include "content/common/child_process_host_impl.h" |
| 39 #include "content/common/establish_channel_params.h" | 40 #include "content/common/establish_channel_params.h" |
| 40 #include "content/common/gpu_host_messages.h" | 41 #include "content/common/gpu_host_messages.h" |
| 41 #include "content/common/in_process_child_thread_params.h" | 42 #include "content/common/in_process_child_thread_params.h" |
| 42 #include "content/common/service_manager/child_connection.h" | 43 #include "content/common/service_manager/child_connection.h" |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 void GpuProcessHost::SendOnIO(GpuProcessKind kind, | 416 void GpuProcessHost::SendOnIO(GpuProcessKind kind, |
| 416 bool force_create, | 417 bool force_create, |
| 417 IPC::Message* message) { | 418 IPC::Message* message) { |
| 418 if (!BrowserThread::PostTask( | 419 if (!BrowserThread::PostTask( |
| 419 BrowserThread::IO, FROM_HERE, | 420 BrowserThread::IO, FROM_HERE, |
| 420 base::Bind(&SendGpuProcessMessage, kind, force_create, message))) { | 421 base::Bind(&SendGpuProcessMessage, kind, force_create, message))) { |
| 421 delete message; | 422 delete message; |
| 422 } | 423 } |
| 423 } | 424 } |
| 424 | 425 |
| 425 GpuMainThreadFactoryFunction g_gpu_main_thread_factory = NULL; | |
| 426 | |
| 427 GpuProcessHost::EstablishChannelRequest::EstablishChannelRequest() | 426 GpuProcessHost::EstablishChannelRequest::EstablishChannelRequest() |
| 428 : client_id(0) {} | 427 : client_id(0) {} |
| 429 | 428 |
| 430 GpuProcessHost::EstablishChannelRequest::EstablishChannelRequest( | 429 GpuProcessHost::EstablishChannelRequest::EstablishChannelRequest( |
| 431 const EstablishChannelRequest& other) = default; | 430 const EstablishChannelRequest& other) = default; |
| 432 | 431 |
| 433 GpuProcessHost::EstablishChannelRequest::~EstablishChannelRequest() {} | 432 GpuProcessHost::EstablishChannelRequest::~EstablishChannelRequest() {} |
| 434 | 433 |
| 435 void GpuProcessHost::RegisterGpuMainThreadFactory( | |
| 436 GpuMainThreadFactoryFunction create) { | |
| 437 g_gpu_main_thread_factory = create; | |
| 438 } | |
| 439 | |
| 440 service_manager::InterfaceProvider* GpuProcessHost::GetRemoteInterfaces() { | 434 service_manager::InterfaceProvider* GpuProcessHost::GetRemoteInterfaces() { |
| 441 return process_->child_connection()->GetRemoteInterfaces(); | 435 return process_->child_connection()->GetRemoteInterfaces(); |
| 442 } | 436 } |
| 443 | 437 |
| 444 // static | 438 // static |
| 445 GpuProcessHost* GpuProcessHost::FromID(int host_id) { | 439 GpuProcessHost* GpuProcessHost::FromID(int host_id) { |
| 446 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 440 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 447 | 441 |
| 448 for (int i = 0; i < GPU_PROCESS_KIND_COUNT; ++i) { | 442 for (int i = 0; i < GPU_PROCESS_KIND_COUNT; ++i) { |
| 449 GpuProcessHost* host = g_gpu_process_hosts[i]; | 443 GpuProcessHost* host = g_gpu_process_hosts[i]; |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 if (ServiceManagerConnection::GetForProcess()) { | 583 if (ServiceManagerConnection::GetForProcess()) { |
| 590 ServiceManagerConnection::GetForProcess()->AddConnectionFilter( | 584 ServiceManagerConnection::GetForProcess()->AddConnectionFilter( |
| 591 base::MakeUnique<ConnectionFilterImpl>(this)); | 585 base::MakeUnique<ConnectionFilterImpl>(this)); |
| 592 } | 586 } |
| 593 | 587 |
| 594 process_->GetHost()->CreateChannelMojo(); | 588 process_->GetHost()->CreateChannelMojo(); |
| 595 | 589 |
| 596 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); | 590 gpu::GpuPreferences gpu_preferences = GetGpuPreferencesFromCommandLine(); |
| 597 if (in_process_) { | 591 if (in_process_) { |
| 598 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 592 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 599 DCHECK(g_gpu_main_thread_factory); | 593 DCHECK(GetGpuMainThreadFactory()); |
| 600 in_process_gpu_thread_.reset(g_gpu_main_thread_factory( | 594 in_process_gpu_thread_.reset(GetGpuMainThreadFactory()( |
| 601 InProcessChildThreadParams( | 595 InProcessChildThreadParams( |
| 602 base::ThreadTaskRunnerHandle::Get(), | 596 base::ThreadTaskRunnerHandle::Get(), |
| 603 process_->child_connection()->service_token()), | 597 process_->child_connection()->service_token()), |
| 604 gpu_preferences)); | 598 gpu_preferences)); |
| 605 base::Thread::Options options; | 599 base::Thread::Options options; |
| 606 #if defined(OS_WIN) | 600 #if defined(OS_WIN) |
| 607 // WGL needs to create its own window and pump messages on it. | 601 // WGL needs to create its own window and pump messages on it. |
| 608 options.message_loop_type = base::MessageLoop::TYPE_UI; | 602 options.message_loop_type = base::MessageLoop::TYPE_UI; |
| 609 #endif | 603 #endif |
| 610 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | 604 #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| (...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 GetShaderCacheFactorySingleton()->Get(client_id); | 1196 GetShaderCacheFactorySingleton()->Get(client_id); |
| 1203 if (!cache.get()) | 1197 if (!cache.get()) |
| 1204 return; | 1198 return; |
| 1205 | 1199 |
| 1206 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); | 1200 cache->set_shader_loaded_callback(base::Bind(&HostLoadedShader, host_id_)); |
| 1207 | 1201 |
| 1208 client_id_to_shader_cache_[client_id] = cache; | 1202 client_id_to_shader_cache_[client_id] = cache; |
| 1209 } | 1203 } |
| 1210 | 1204 |
| 1211 } // namespace content | 1205 } // namespace content |
| OLD | NEW |