Chromium Code Reviews| Index: content/renderer/render_thread_impl.cc |
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc |
| index 147bf012663f386cc72000b6ce63d04b6b830c0c..77dafd6793fbd0492bfc1256f959075a6386ea04 100644 |
| --- a/content/renderer/render_thread_impl.cc |
| +++ b/content/renderer/render_thread_impl.cc |
| @@ -46,6 +46,7 @@ |
| #include "cc/raster/task_graph_runner.h" |
| #include "cc/trees/layer_tree_host_common.h" |
| #include "cc/trees/layer_tree_settings.h" |
| +#include "components/mus/common/gpu_service.h" |
| #include "components/scheduler/child/compositor_worker_scheduler.h" |
| #include "components/scheduler/child/webthread_base.h" |
| #include "components/scheduler/child/webthread_impl_for_worker_scheduler.h" |
| @@ -442,6 +443,11 @@ scoped_refptr<ContextProviderCommandBuffer> CreateOffscreenContext( |
| attributes, nullptr, type)); |
| } |
| +bool IsRunningInMash() { |
| + const base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| + return cmdline->HasSwitch(switches::kIsRunningInMash); |
| +} |
| + |
| } // namespace |
| // For measuring memory usage after each task. Behind a command line flag. |
| @@ -629,6 +635,13 @@ void RenderThreadImpl::Init( |
| // Register this object as the main thread. |
| ChildProcess::current()->set_main_thread(this); |
| +#if defined(MOJO_SHELL_CLIENT) |
| + if (IsRunningInMash()) { |
| + auto shell_connection = MojoShellConnection::GetForProcess(); |
|
danakj
2016/06/27 21:28:48
auto*
Peng
2016/06/30 19:30:52
Done.
|
| + mus::GpuService::Initialize(shell_connection->GetConnector()); |
| + } |
| +#endif |
| + |
| InitializeWebKit(resource_task_queue); |
| // In single process the single process is all there is. |
| @@ -1599,7 +1612,11 @@ RenderThreadImpl::GetCompositorImplThreadTaskRunner() { |
| } |
| gpu::GpuMemoryBufferManager* RenderThreadImpl::GetGpuMemoryBufferManager() { |
| - return gpu_memory_buffer_manager(); |
| + if (!IsRunningInMash()) { |
| + return gpu_memory_buffer_manager(); |
| + } else { |
| + return mus::GpuService::GetInstance()->gpu_memory_buffer_manager(); |
|
danakj
2016/06/27 21:28:48
Why isn't gpu_memory_buffer_manager() the mus one?
Peng
2016/06/30 19:30:52
Done.
Peng
2016/06/30 19:50:54
Yeah. Unfortunately, mus::GpuService has his own b
|
| + } |
| } |
| scheduler::RendererScheduler* RenderThreadImpl::GetRendererScheduler() { |
| @@ -1762,32 +1779,36 @@ scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync( |
| // Recreate the channel if it has been lost. |
| gpu_channel_->DestroyChannel(); |
| - gpu_channel_ = NULL; |
| + gpu_channel_ = nullptr; |
| } |
| - // Ask the browser for the channel name. |
| - int client_id = 0; |
| - IPC::ChannelHandle channel_handle; |
| - gpu::GPUInfo gpu_info; |
| - if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( |
| - cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || |
| + if (!IsRunningInMash()) { |
| + int client_id = 0; |
| + IPC::ChannelHandle channel_handle; |
| + gpu::GPUInfo gpu_info; |
| + // Ask the browser for the channel name. |
| + if (!Send(new ChildProcessHostMsg_EstablishGpuChannel( |
| + cause_for_gpu_launch, &client_id, &channel_handle, &gpu_info)) || |
| #if defined(OS_POSIX) |
| - channel_handle.socket.fd == -1 || |
| + channel_handle.socket.fd == -1 || |
| #endif |
| - channel_handle.name.empty()) { |
| - // Otherwise cancel the connection. |
| - return NULL; |
| - } |
| - |
| - GetContentClient()->SetGpuInfo(gpu_info); |
| + channel_handle.name.empty()) { |
| + // Otherwise cancel the connection. |
| + return NULL; |
|
danakj
2016/06/27 21:28:47
nullptr
Peng
2016/06/30 19:30:52
Done.
|
| + } |
| + GetContentClient()->SetGpuInfo(gpu_info); |
| - // Cache some variables that are needed on the compositor thread for our |
| - // implementation of GpuChannelHostFactory. |
| - io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); |
| + // Cache some variables that are needed on the compositor thread for our |
| + // implementation of GpuChannelHostFactory. |
| + io_thread_task_runner_ = ChildProcess::current()->io_task_runner(); |
| - gpu_channel_ = gpu::GpuChannelHost::Create( |
| - this, client_id, gpu_info, channel_handle, |
| - ChildProcess::current()->GetShutDownEvent(), gpu_memory_buffer_manager()); |
| + gpu_channel_ = |
| + gpu::GpuChannelHost::Create(this, client_id, gpu_info, channel_handle, |
| + ChildProcess::current()->GetShutDownEvent(), |
| + gpu_memory_buffer_manager()); |
| + } else { |
| + gpu_channel_ = mus::GpuService::GetInstance()->EstablishGpuChannelSync(); |
|
danakj
2016/06/27 21:28:48
Would it be possible to have a non-mash in-process
Peng
2016/06/30 19:30:52
It is possible. But currently some features are no
|
| + } |
| return gpu_channel_; |
| } |
| @@ -1806,7 +1827,6 @@ RenderThreadImpl::CreateCompositorOutputSurface( |
| auto shell_connection = MojoShellConnection::GetForProcess(); |
| if (shell_connection && !use_software && |
| command_line.HasSwitch(switches::kUseMusInRenderer)) { |
| - mus::GpuService::Initialize(shell_connection->GetConnector()); |
| RenderWidgetMusConnection* connection = |
| RenderWidgetMusConnection::GetOrCreate(routing_id); |
| return connection->CreateOutputSurface(); |