Index: content/gpu/gpu_child_thread.cc |
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc |
index 914810e9d282661c9e1973448017a720afc7d6cf..6ea7e2ec22010e863e109012fbb8aa56e641af59 100644 |
--- a/content/gpu/gpu_child_thread.cc |
+++ b/content/gpu/gpu_child_thread.cc |
@@ -13,9 +13,8 @@ |
#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 +45,14 @@ |
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 +74,10 @@ |
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,84 +252,8 @@ |
if (ChildThreadImpl::OnMessageReceived(msg)) |
return true; |
- 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)); |
+ return gpu_channel_manager_.get() && |
+ gpu_channel_manager_->OnMessageReceived(msg); |
} |
void GpuChildThread::OnInitialize() { |
@@ -357,11 +280,12 @@ |
// 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( |
- this, 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(channel(), 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() |
@@ -428,16 +352,16 @@ |
void GpuChildThread::OnGetVideoMemoryUsageStats() { |
GPUVideoMemoryUsageStats video_memory_usage_stats; |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
- &video_memory_usage_stats); |
+ if (gpu_channel_manager_) |
+ gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats( |
+ &video_memory_usage_stats); |
Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats)); |
} |
void GpuChildThread::OnClean() { |
DVLOG(1) << "GPU: Removing all contexts"; |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->DestroyAllChannels(); |
+ if (gpu_channel_manager_) |
+ gpu_channel_manager_->LoseAllContexts(); |
} |
void GpuChildThread::OnCrash() { |
@@ -473,55 +397,6 @@ |
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched(); |
} |
-#if defined(OS_MACOSX) |
-void GpuChildThread::OnBufferPresented(const BufferPresentedParams& params) { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->BufferPresented(params); |
-} |
-#endif |
- |
-void GpuChildThread::OnEstablishChannel(const EstablishChannelParams& params) { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->EstablishChannel(params); |
-} |
- |
-void GpuChildThread::OnCloseChannel(const IPC::ChannelHandle& channel_handle) { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->CloseChannel(channel_handle); |
-} |
- |
-void GpuChildThread::OnLoadedShader(const std::string& shader) { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->PopulateShaderCache(shader); |
-} |
- |
-void GpuChildThread::OnDestroyGpuMemoryBuffer( |
- gfx::GpuMemoryBufferId id, |
- int client_id, |
- const gpu::SyncToken& sync_token) { |
- DCHECK(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) { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->UpdateValueState(client_id, target, state); |
-} |
- |
-#if defined(OS_ANDROID) |
-void GpuChildThread::OnWakeUpGpu() { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->WakeUpGpu(); |
-} |
-#endif |
- |
-void GpuChildThread::OnLoseAllContexts() { |
- DCHECK(gpu_channel_manager_); |
- gpu_channel_manager_->DestroyAllChannels(); |
-} |
- |
void GpuChildThread::BindProcessControlRequest( |
mojo::InterfaceRequest<ProcessControl> request) { |
DVLOG(1) << "GPU: Binding ProcessControl request"; |