summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 15:24:25 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-27 15:24:25 +0000
commitd8a58e44578fa646480cec37db3ddb40a5b673b7 (patch)
tree4221925985cab2e659d9b2a22434810361c1958a /chrome/gpu
parent5ba9c9ae342ff20bde44be9dfc538727d3696865 (diff)
downloadchromium_src-d8a58e44578fa646480cec37db3ddb40a5b673b7.zip
chromium_src-d8a58e44578fa646480cec37db3ddb40a5b673b7.tar.gz
chromium_src-d8a58e44578fa646480cec37db3ddb40a5b673b7.tar.bz2
Route IPC through browser when creating a viewable command buffer.
The communications path for creating a viewable command buffer used to be directly from the renderer (gpu_channel.cc) to the gpu process (gpu_channel.cc). This patch makes the browser an intermediary: - renderer (gpu_channel.cc) makes a synchronous request to the browser (picked up in renderer_message_filter.cc and forwarded to gpu_process_host.cc) - browser (gpu_process_host.cc) makes an asynchronous request to the gpu process (picked up in gpu_thread.cc and forwarded to gpu_channel.cc) for the command buffer - gpu process (gpu_thread.cc) sends an ACK with the route_id for the command buffer back to the browser (gpu_process_host.cc) - browser (gpu_process_host.cc) sends a delayed reply back to the renderer (gpu_channel_host.cc), which had blocked There are several motivations for this patch: - creating an onscreen command buffer requires a window to draw into (which is acquired/locked in the browser); by routing through the browser, we can acquire the get the window beforehand (thereby preventing a deadlock in some other work that I'm doing) - we can eliminate several separate synchronous IPC messages for obtaining and releasing the window associated with drawing (I've tried to unify the different code paths for Linux, Windows, and Mac) - in the future, we can have the browser allocate SHM for the command buffer and transfer buffers, allowing us to sandbox the gpu process BUG=none TEST=by hand on all 3 platforms, trybots Review URL: http://codereview.chromium.org/6343006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@72798 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_channel.cc66
-rw-r--r--chrome/gpu/gpu_channel.h11
-rw-r--r--chrome/gpu/gpu_command_buffer_stub.cc20
-rw-r--r--chrome/gpu/gpu_thread.cc19
-rw-r--r--chrome/gpu/gpu_thread.h5
5 files changed, 51 insertions, 70 deletions
diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc
index 66b928e..5ef74e2 100644
--- a/chrome/gpu/gpu_channel.cc
+++ b/chrome/gpu/gpu_channel.cc
@@ -71,6 +71,23 @@ bool GpuChannel::Send(IPC::Message* message) {
return channel_->Send(message);
}
+void GpuChannel::CreateViewCommandBuffer(
+ gfx::PluginWindowHandle window,
+ int32 render_view_id,
+ const GPUCreateCommandBufferConfig& init_params,
+ int32* route_id) {
+ *route_id = MSG_ROUTING_NONE;
+
+#if defined(ENABLE_GPU)
+ *route_id = GenerateRouteID();
+ scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
+ this, window, NULL, gfx::Size(), init_params.allowed_extensions,
+ init_params.attribs, 0, *route_id, renderer_id_, render_view_id));
+ router_.AddRoute(*route_id, stub.get());
+ stubs_.AddWithID(stub.release(), *route_id);
+#endif // ENABLE_GPU
+}
+
#if defined(OS_MACOSX)
void GpuChannel::AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count) {
@@ -97,8 +114,6 @@ bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) {
bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg)
- IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer,
- OnCreateViewCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer,
OnCreateOffscreenCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
@@ -118,53 +133,6 @@ int GpuChannel::GenerateRouteID() {
return ++last_id;
}
-void GpuChannel::OnCreateViewCommandBuffer(
- gfx::NativeViewId view_id,
- int32 render_view_id,
- const GPUCreateCommandBufferConfig& init_params,
- int32* route_id) {
- *route_id = MSG_ROUTING_NONE;
-
-#if defined(ENABLE_GPU)
-
- gfx::PluginWindowHandle handle = gfx::kNullPluginWindow;
-#if defined(OS_WIN)
- // TODO(apatrick): We don't actually need the window handle on the Windows
- // platform. At this point, it only indicates to the GpuCommandBufferStub
- // whether onscreen or offscreen rendering is requested. The window handle
- // that will be rendered to is the child compositor window and that window
- // handle is provided by the browser process. Looking at what we are doing on
- // this and other platforms, I think a redesign is in order here. Perhaps
- // on all platforms the renderer just indicates whether it wants onscreen or
- // offscreen rendering and the browser provides whichever platform specific
- // "render target" the GpuCommandBufferStub targets.
- handle = gfx::NativeViewFromId(view_id);
-#elif defined(OS_LINUX)
- // Ask the browser for the view's XID.
- gpu_thread_->Send(new GpuHostMsg_GetViewXID(view_id, &handle));
-#elif defined(OS_MACOSX)
- // On Mac OS X we currently pass a (fake) PluginWindowHandle for the
- // NativeViewId. We could allocate fake NativeViewIds on the browser
- // side as well, and map between those and PluginWindowHandles, but
- // this seems excessive.
- handle = static_cast<gfx::PluginWindowHandle>(
- static_cast<intptr_t>(view_id));
-#else
- // TODO(apatrick): This needs to be something valid for mac and linux.
- // Offscreen rendering will work on these platforms but not rendering to the
- // window.
- DCHECK_EQ(view_id, 0);
-#endif
-
- *route_id = GenerateRouteID();
- scoped_ptr<GpuCommandBufferStub> stub(new GpuCommandBufferStub(
- this, handle, NULL, gfx::Size(), init_params.allowed_extensions,
- init_params.attribs, 0, *route_id, renderer_id_, render_view_id));
- router_.AddRoute(*route_id, stub.get());
- stubs_.AddWithID(stub.release(), *route_id);
-#endif // ENABLE_GPU
-}
-
void GpuChannel::OnCreateOffscreenCommandBuffer(
int32 parent_route_id,
const gfx::Size& size,
diff --git a/chrome/gpu/gpu_channel.h b/chrome/gpu/gpu_channel.h
index 75d57ca..2ebe6d7 100644
--- a/chrome/gpu/gpu_channel.h
+++ b/chrome/gpu/gpu_channel.h
@@ -59,6 +59,12 @@ class GpuChannel : public IPC::Channel::Listener,
// IPC::Message::Sender implementation:
virtual bool Send(IPC::Message* msg);
+ void CreateViewCommandBuffer(
+ gfx::PluginWindowHandle window,
+ int32 render_view_id,
+ const GPUCreateCommandBufferConfig& init_params,
+ int32* route_id);
+
#if defined(OS_MACOSX)
virtual void AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count);
@@ -73,11 +79,6 @@ class GpuChannel : public IPC::Channel::Listener,
int GenerateRouteID();
// Message handlers.
- void OnCreateViewCommandBuffer(
- gfx::NativeViewId view,
- int32 render_view_id,
- const GPUCreateCommandBufferConfig& init_params,
- int32* route_id);
void OnCreateOffscreenCommandBuffer(
int32 parent_route_id,
const gfx::Size& size,
diff --git a/chrome/gpu/gpu_command_buffer_stub.cc b/chrome/gpu/gpu_command_buffer_stub.cc
index 43a1be5..3a832441 100644
--- a/chrome/gpu/gpu_command_buffer_stub.cc
+++ b/chrome/gpu/gpu_command_buffer_stub.cc
@@ -80,17 +80,7 @@ static LRESULT CALLBACK CompositorWindowProc(
bool GpuCommandBufferStub::CreateCompositorWindow() {
DCHECK(handle_ != gfx::kNullPluginWindow);
-
- // Ask the browser to create the the host window.
- GpuThread* gpu_thread = channel_->gpu_thread();
- gfx::PluginWindowHandle host_window_id = gfx::kNullPluginWindow;
- gpu_thread->Send(new GpuHostMsg_GetCompositorHostWindow(
- renderer_id_,
- render_view_id_,
- &host_window_id));
- if (host_window_id == gfx::kNullPluginWindow)
- return false;
- HWND host_window = static_cast<HWND>(host_window_id);
+ HWND host_window = static_cast<HWND>(handle_);
// Create the compositor window itself.
DCHECK(host_window);
@@ -163,11 +153,11 @@ GpuCommandBufferStub::~GpuCommandBufferStub() {
DestroyWindow(static_cast<HWND>(compositor_window_));
compositor_window_ = NULL;
}
-#elif defined(OS_LINUX)
- GpuThread* gpu_thread = channel_->gpu_thread();
- gpu_thread->Send(
- new GpuHostMsg_ReleaseXID(handle_));
#endif // defined(OS_WIN)
+
+ GpuThread* gpu_thread = channel_->gpu_thread();
+ gpu_thread->Send(new GpuHostMsg_DestroyCommandBuffer(
+ handle_, renderer_id_, render_view_id_));
}
bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
diff --git a/chrome/gpu/gpu_thread.cc b/chrome/gpu/gpu_thread.cc
index 752478e..e52b7a6 100644
--- a/chrome/gpu/gpu_thread.cc
+++ b/chrome/gpu/gpu_thread.cc
@@ -69,6 +69,8 @@ bool GpuThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize)
IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
+ IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
+ OnCreateViewCommandBuffer);
IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize)
IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
#if defined(OS_MACOSX)
@@ -215,10 +217,25 @@ void GpuThread::OnCollectGraphicsInfo(GPUInfo::Level level) {
}
}
#endif
-
Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_));
}
+void GpuThread::OnCreateViewCommandBuffer(
+ gfx::PluginWindowHandle window,
+ int32 render_view_id,
+ int32 renderer_id,
+ const GPUCreateCommandBufferConfig& init_params) {
+ int32 route_id = MSG_ROUTING_NONE;
+
+ GpuChannelMap::const_iterator iter = gpu_channels_.find(renderer_id);
+ if (iter != gpu_channels_.end()) {
+ iter->second->CreateViewCommandBuffer(
+ window, render_view_id, init_params, &route_id);
+ }
+
+ Send(new GpuHostMsg_CommandBufferCreated(route_id));
+}
+
#if defined(OS_MACOSX)
void GpuThread::OnAcceleratedSurfaceBuffersSwappedACK(
int renderer_id, int32 route_id, uint64 swap_buffers_count) {
diff --git a/chrome/gpu/gpu_thread.h b/chrome/gpu/gpu_thread.h
index 1bbb225..7f82ab6 100644
--- a/chrome/gpu/gpu_thread.h
+++ b/chrome/gpu/gpu_thread.h
@@ -51,6 +51,11 @@ class GpuThread : public ChildThread {
void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
void OnSynchronize();
void OnCollectGraphicsInfo(GPUInfo::Level level);
+ void OnCreateViewCommandBuffer(
+ gfx::PluginWindowHandle window,
+ int32 render_view_id,
+ int32 renderer_id,
+ const GPUCreateCommandBufferConfig& init_params);
#if defined(OS_MACOSX)
void OnAcceleratedSurfaceBuffersSwappedACK(
int renderer_id, int32 route_id, uint64 swap_buffers_count);