Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(857)

Unified Diff: content/gpu/gpu_child_thread.cc

Issue 1711533002: Decouple browser-specific GPU IPC messages from GPU service IPCs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a couple of missings sends in GpuChildThread Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/gpu/gpu_child_thread.cc
diff --git a/content/gpu/gpu_child_thread.cc b/content/gpu/gpu_child_thread.cc
index 2552d82bff45b05b95e07cefe211a29b8237753e..dda5deb1a3fba47f94684432b764e511a3b43123 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_browser_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"
@@ -44,13 +45,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 GpuBrowserHostMsg_OnLogMessage(severity, header, message));
return false;
}
-// Message filter used to to handle GpuMsg_CreateGpuMemoryBuffer messages on
+// Message filter used to to handle GpuBrowserMsg_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 {
@@ -73,10 +75,11 @@ 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(GpuBrowserMsg_CreateGpuMemoryBuffer,
+ OnCreateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_CreateGpuMemoryBufferFromHandle,
+ OnCreateGpuMemoryBufferFromHandle)
+ IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
@@ -85,24 +88,24 @@ class GpuMemoryBufferMessageFilter : public IPC::MessageFilter {
~GpuMemoryBufferMessageFilter() override {}
void OnCreateGpuMemoryBuffer(
- const GpuMsg_CreateGpuMemoryBuffer_Params& params) {
+ const GpuBrowserMsg_CreateGpuMemoryBuffer_Params& params) {
TRACE_EVENT2("gpu", "GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBuffer",
"id", params.id.id, "client_id", params.client_id);
DCHECK(gpu_memory_buffer_factory_);
- sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated(
+ sender_->Send(new GpuBrowserHostMsg_GpuMemoryBufferCreated(
gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(
params.id, params.size, params.format, params.usage,
params.client_id, params.surface_handle)));
}
void OnCreateGpuMemoryBufferFromHandle(
- const GpuMsg_CreateGpuMemoryBufferFromHandle_Params& params) {
+ const GpuBrowserMsg_CreateGpuMemoryBufferFromHandle_Params& params) {
TRACE_EVENT2(
"gpu",
"GpuMemoryBufferMessageFilter::OnCreateGpuMemoryBufferFromHandle", "id",
params.id.id, "client_id", params.client_id);
- sender_->Send(new GpuHostMsg_GpuMemoryBufferCreated(
+ sender_->Send(new GpuBrowserHostMsg_GpuMemoryBufferCreated(
gpu_memory_buffer_factory_->CreateGpuMemoryBufferFromHandle(
params.handle, params.id, params.size, params.format,
params.client_id)));
@@ -218,16 +221,17 @@ bool GpuChildThread::Send(IPC::Message* msg) {
bool GpuChildThread::OnControlMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
- IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize)
- IPC_MESSAGE_HANDLER(GpuMsg_Finalize, OnFinalize)
- IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
- IPC_MESSAGE_HANDLER(GpuMsg_GetVideoMemoryUsageStats,
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_Initialize, OnInitialize)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_Finalize, OnFinalize)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_CollectGraphicsInfo,
+ OnCollectGraphicsInfo)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_GetVideoMemoryUsageStats,
OnGetVideoMemoryUsageStats)
- IPC_MESSAGE_HANDLER(GpuMsg_Clean, OnClean)
- IPC_MESSAGE_HANDLER(GpuMsg_Crash, OnCrash)
- IPC_MESSAGE_HANDLER(GpuMsg_Hang, OnHang)
- IPC_MESSAGE_HANDLER(GpuMsg_DisableWatchdog, OnDisableWatchdog)
- IPC_MESSAGE_HANDLER(GpuMsg_GpuSwitched, OnGpuSwitched)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_Clean, OnClean)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_Crash, OnCrash)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_Hang, OnHang)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_DisableWatchdog, OnDisableWatchdog)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_GpuSwitched, OnGpuSwitched)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -248,15 +252,73 @@ bool GpuChildThread::OnMessageReceived(const IPC::Message& msg) {
if (ChildThreadImpl::OnMessageReceived(msg))
return true;
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(GpuChildThread, msg)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_EstablishChannel, OnEstablishChannel)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_CloseChannel, OnCloseChannel)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_DestroyGpuMemoryBuffer,
+ OnDestroyGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_LoadedShader, OnLoadedShader)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_UpdateValueState, OnUpdateValueState)
+#if defined(OS_ANDROID)
+ IPC_MESSAGE_HANDLER(GpuBrowserMsg_WakeUpGpu, OnWakeUpGpu);
+#endif
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ if (handled)
+ return true;
+
return gpu_channel_manager_.get() &&
gpu_channel_manager_->OnMessageReceived(msg);
}
+void GpuChildThread::AddSubscription(int32_t client_id, unsigned int target) {
+ Send(new GpuBrowserHostMsg_AddSubscription(client_id, target));
+}
+
+void GpuChildThread::CacheShader(int32_t client_id,
+ const std::string& key,
+ const std::string& shader) {
+ Send(new GpuBrowserHostMsg_CacheShader(client_id, key, shader));
+}
+
+void GpuChildThread::ChannelEstablished(
+ const IPC::ChannelHandle& channel_handle) {
+ Send(new GpuBrowserHostMsg_ChannelEstablished(channel_handle));
+}
+
+void GpuChildThread::DestroyChannel(int client_id) {
+ Send(new GpuBrowserHostMsg_DestroyChannel(client_id));
+}
+
+void GpuChildThread::DidCreateOffscreenContext(const GURL& active_url) {
+ Send(new GpuBrowserHostMsg_DidCreateOffscreenContext(active_url));
+}
+
+void GpuChildThread::DidDestroyOffscreenContext(const GURL& active_url) {
+ Send(new GpuBrowserHostMsg_DidDestroyOffscreenContext(active_url));
+}
+
+void GpuChildThread::DidLoseContext(bool offscreen,
+ gpu::error::ContextLostReason reason,
+ const GURL& active_url) {
+ Send(new GpuBrowserHostMsg_DidLoseContext(offscreen, reason, active_url));
+}
+
+void GpuChildThread::GpuMemoryUmaStats(const GPUMemoryUmaStats& params) {
+ Send(new GpuBrowserHostMsg_GpuMemoryUmaStats(params));
+}
+
+void GpuChildThread::RemoveSubscription(int32_t client_id,
+ unsigned int target) {
+ Send(new GpuBrowserHostMsg_RemoveSubscription(client_id, target));
+}
+
void GpuChildThread::OnInitialize() {
// Record initialization only after collecting the GPU info because that can
// take a significant amount of time.
gpu_info_.initialization_time = base::Time::Now() - process_start_time_;
- Send(new GpuHostMsg_Initialized(!dead_on_arrival_, gpu_info_));
+ Send(new GpuBrowserHostMsg_Initialized(!dead_on_arrival_, gpu_info_));
while (!deferred_messages_.empty()) {
Send(deferred_messages_.front());
deferred_messages_.pop();
@@ -277,7 +339,7 @@ void GpuChildThread::OnInitialize() {
// 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(),
+ new GpuChannelManager(this, channel(), watchdog_thread_.get(),
base::ThreadTaskRunnerHandle::Get().get(),
ChildProcess::current()->io_task_runner(),
ChildProcess::current()->GetShutDownEvent(),
@@ -336,7 +398,7 @@ void GpuChildThread::OnCollectGraphicsInfo() {
gpu_info_.dx_diagnostics_info_state = gpu::kCollectInfoSuccess;
#endif // OS_WIN
- Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_));
+ Send(new GpuBrowserHostMsg_GraphicsInfoCollected(gpu_info_));
#if defined(OS_WIN)
if (!in_browser_process_) {
@@ -351,13 +413,13 @@ void GpuChildThread::OnGetVideoMemoryUsageStats() {
if (gpu_channel_manager_)
gpu_channel_manager_->gpu_memory_manager()->GetVideoMemoryUsageStats(
&video_memory_usage_stats);
- Send(new GpuHostMsg_VideoMemoryUsageStats(video_memory_usage_stats));
+ Send(new GpuBrowserHostMsg_VideoMemoryUsageStats(video_memory_usage_stats));
}
void GpuChildThread::OnClean() {
DVLOG(1) << "GPU: Removing all contexts";
if (gpu_channel_manager_)
- gpu_channel_manager_->LoseAllContexts();
+ gpu_channel_manager_->ClearAllChannels();
}
void GpuChildThread::OnCrash() {
@@ -393,6 +455,48 @@ void GpuChildThread::OnGpuSwitched() {
ui::GpuSwitchingManager::GetInstance()->NotifyGpuSwitched();
}
+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_->LoadedShader(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_->ClearAllChannels();
+}
+
void GpuChildThread::BindProcessControlRequest(
mojo::InterfaceRequest<ProcessControl> request) {
DVLOG(1) << "GPU: Binding ProcessControl request";

Powered by Google App Engine
This is Rietveld 408576698