summaryrefslogtreecommitdiffstats
path: root/chrome/gpu/gpu_channel.cc
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/gpu_channel.cc
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/gpu_channel.cc')
-rw-r--r--chrome/gpu/gpu_channel.cc66
1 files changed, 17 insertions, 49 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,