Chromium Code Reviews| Index: content/gpu/gpu_child_thread.cc |
| diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc |
| index 7b4450b37cb832cad146caa0141a5baf85a10fdd..6ba542715b091620900d5b7c807e77e13ffdaf77 100644 |
| --- a/content/gpu/gpu_child_thread.cc |
| +++ b/content/gpu/gpu_child_thread.cc |
| @@ -13,8 +13,9 @@ |
| #include "build/build_config.h" |
| #include "content/child/child_process.h" |
| #include "content/child/thread_safe_sender.h" |
| +#include "content/common/gpu/establish_channel_params.h" |
| +#include "content/common/gpu/gpu_host_messages.h" |
| #include "content/common/gpu/gpu_memory_buffer_factory.h" |
| -#include "content/common/gpu/gpu_messages.h" |
| #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| #include "content/gpu/gpu_process_control_impl.h" |
| #include "content/gpu/gpu_watchdog_thread.h" |
| @@ -46,14 +47,14 @@ bool GpuProcessLogMessageHandler(int severity, |
| std::string header = str.substr(0, message_start); |
| std::string message = str.substr(message_start); |
| - g_thread_safe_sender.Get()->Send(new GpuHostMsg_OnLogMessage( |
| - severity, header, message)); |
| + g_thread_safe_sender.Get()->Send( |
| + new GpuHostMsg_OnLogMessage(severity, header, message)); |
| return false; |
| } |
| -// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages on |
| -// the IO thread. This allows the UI thread in the browser process to remain |
| +// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages |
| +// on the IO thread. This allows the UI thread in the browser process to remain |
| // fast at all times. |
| class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { |
| public: |
| @@ -75,10 +76,10 @@ class GpuMemoryBufferMessageFilter : public IPC::MessageFilter { |
| DCHECK(sender_); |
| bool handled = true; |
| IPC_BEGIN_MESSAGE_MAP(GpuMemoryBufferMessageFilter, message) |
| - IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) |
| - IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle, |
| - OnCreateGpuMemoryBufferFromHandle) |
| - IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBuffer, OnCreateGpuMemoryBuffer) |
| + IPC_MESSAGE_HANDLER(GpuMsg_CreateGpuMemoryBufferFromHandle, |
| + OnCreateGpuMemoryBufferFromHandle) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| return handled; |
| } |
| @@ -253,8 +254,84 @@ bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) { |
| if (ChildThreadImpl::OnMessageReceived(msg)) |
| return true; |
| - return gpu_channel_manager_.get() && |
| - gpu_channel_manager_->OnMessageReceived(msg); |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg) |
| +#if defined(OS_MACOSX) |
| + IPC_MESSAGE_HANDLER(AcceleratedSurfaceMsg_BufferPresented, |
| + OnBufferPresented) |
| +#endif |
| + IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) |
| + IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) |
| + IPC_MESSAGE_HANDLER(GpuMsg_DestroyGpuMemoryBuffer, OnDestroyGpuMemoryBuffer) |
| + IPC_MESSAGE_HANDLER(GpuMsg_LoadedShader, OnLoadedShader) |
| + IPC_MESSAGE_HANDLER(GpuMsg_UpdateValueState, OnUpdateValueState) |
| +#if defined(OS_ANDROID) |
| + IPC_MESSAGE_HANDLER(GpuMsg_WakeUpGpu, OnWakeUpGpu); |
| +#endif |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + if (handled) |
| + return true; |
| + |
| + return false; |
| +} |
| + |
| +void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) { |
| + Send(new GpuHostMsg_AddSubscription(client_id, target)); |
| +} |
| + |
| +void GpuChildThread::ChannelEstablished( |
| + const IPC::ChannelHandle& channel_handle) { |
| + Send(new GpuHostMsg_ChannelEstablished(channel_handle)); |
| +} |
| + |
| +void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) { |
| + Send(new GpuHostMsg_DidCreateOffscreenContext(active_url)); |
| +} |
| + |
| +void GpuChildThread::DidDestroyChannel(int client_id) { |
| + Send(new GpuHostMsg_DestroyChannel(client_id)); |
| +} |
| + |
| +void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) { |
| + Send(new GpuHostMsg_DidDestroyOffscreenContext(active_url)); |
| +} |
| + |
| +void GpuChildThread::DidLoseContext(bool offscreen, |
| + gpu::error::ContextLostReason reason, |
| + const GURL& active_url) { |
| + Send(new GpuHostMsg_DidLoseContext(offscreen, reason, active_url)); |
| +} |
| + |
| +void GpuChildThread::GpuMemoryUmaStats(const GPUMemoryUmaStats& params) { |
| + Send(new GpuHostMsg_GpuMemoryUmaStats(params)); |
| +} |
| + |
| +void GpuChildThread::RemoveSubscription(int32_t client_id, |
| + unsigned int target) { |
| + Send(new GpuHostMsg_RemoveSubscription(client_id, target)); |
| +} |
| + |
| +#if defined(OS_MACOSX) |
| +void GpuChildThread::SendAcceleratedSurfaceBuffersSwapped( |
| + const AcceleratedSurfaceBuffersSwappedParams& params) { |
| + Send(new GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| +} |
| +#endif |
| + |
| +#if defined(OS_WIN) |
| +void GpuChildThread::SendAcceleratedSurfaceCreatedChildWindow( |
| + const gfx::PluginWindowHandle& parent_window, |
| + const gfx::PluginWindowHandle& child_window) { |
| + Send(new GpuHostMsg_AcceleratedSurfaceCreatedChildWindow(parent_window, |
| + child_window)); |
| +} |
| +#endif |
| + |
| +void GpuChildThread::StoreShaderToDisk(int32_t client_id, |
| + const std::string& key, |
| + const std::string& shader) { |
| + Send(new GpuHostMsg_CacheShader(client_id, key, shader)); |
| } |
| void GpuChildThread::OnInitialize() { |
| @@ -281,12 +358,11 @@ void GpuChildThread::OnInitialize() { |
| // Defer creation of the render thread. This is to prevent it from handling |
| // IPC messages before the sandbox has been enabled and all other necessary |
| // initialization has succeeded. |
| - gpu_channel_manager_.reset( |
| - new GpuChannelManager(channel(), watchdog_thread_.get(), |
| - base::ThreadTaskRunnerHandle::Get().get(), |
| - ChildProcess::current()->io_task_runner(), |
| - ChildProcess::current()->GetShutDownEvent(), |
| - sync_point_manager_, gpu_memory_buffer_factory_)); |
| + gpu_channel_manager_.reset(new GpuChannelManager( |
| + this, watchdog_thread_.get(), base::ThreadTaskRunnerHandle::Get().get(), |
| + ChildProcess::current()->io_task_runner(), |
| + ChildProcess::current()->GetShutDownEvent(), sync_point_manager_, |
| + gpu_memory_buffer_factory_)); |
| #if defined(USE_OZONE) |
| ui::OzonePlatform::GetInstance() |
| @@ -362,7 +438,7 @@ void GpuChildThread::OnGetVideoMemoryUsageStats() { |
| void GpuChildThread::OnClean() { |
| DVLOG(1) << "GPU: Removing all contexts"; |
| if (gpu_channel_manager_) |
| - gpu_channel_manager_->LoseAllContexts(); |
| + gpu_channel_manager_->DestroyAllChannels(); |
| } |
| void GpuChildThread::OnCrash() { |
| @@ -398,6 +474,55 @@ void GpuChildThread::OnGpuSwitched() { |
| ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
| } |
| +#if defined(OS_MACOSX) |
| +void GpuChildThread::OnBufferPresented(const BufferPresentedParams& params) { |
| + if (gpu_channel_manager_) |
|
piman
2016/02/24 00:58:37
nit: I'd replace this test, and the other ones bel
Fady Samuel
2016/02/24 01:42:30
Done.
|
| + gpu_channel_manager_->BufferPresented(params); |
| +} |
| +#endif |
| + |
| +void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->EstablishChannel(params); |
| +} |
| + |
| +void GpuChildThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->CloseChannel(channel_handle); |
| +} |
| + |
| +void GpuChildThread::OnLoadedShader(const std::string& shader) { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->PopulateShaderCache(shader); |
| +} |
| + |
| +void GpuChildThread::OnDestroyGpuMemoryBuffer( |
| + gfx::GpuMemoryBufferId id, |
| + int client_id, |
| + const gpu::SyncToken& sync_token) { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->DestroyGpuMemoryBuffer(id, client_id, sync_token); |
| +} |
| + |
| +void GpuChildThread::OnUpdateValueState(int client_id, |
| + unsigned int target, |
| + const gpu::ValueState& state) { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->UpdateValueState(client_id, target, state); |
| +} |
| + |
| +#if defined(OS_ANDROID) |
| +void GpuChildThread::OnWakeUpGpu() { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->WakeUpGpu(); |
| +} |
| +#endif |
| + |
| +void GpuChildThread::OnLoseAllContexts() { |
| + if (gpu_channel_manager_) |
| + gpu_channel_manager_->DestroyAllChannels(); |
| +} |
| + |
| void GpuChildThread::BindProcessControlRequest( |
| mojo::InterfaceRequest<ProcessControl> request) { |
| DVLOG(1) << "GPU: Binding ProcessControl request"; |