diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 21:53:50 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-05 21:53:50 +0000 |
commit | 246a7045b9c45620fd725210aac51322e611c83f (patch) | |
tree | 6bdce605ae758c282a2b27e92a6b223d98b8d46a /chrome/browser | |
parent | c3240722a63ff142684575e3ea4eb89915edae72 (diff) | |
download | chromium_src-246a7045b9c45620fd725210aac51322e611c83f.zip chromium_src-246a7045b9c45620fd725210aac51322e611c83f.tar.gz chromium_src-246a7045b9c45620fd725210aac51322e611c83f.tar.bz2 |
Added support for opening a GPU command buffer from a renderer processes through a GPU channel.
Probably only works in windows only so far.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/657046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40783 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/gpu_process_host.cc | 42 | ||||
-rw-r--r-- | chrome/browser/gpu_process_host.h | 39 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store.h | 1 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.cc | 8 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host.h | 6 |
5 files changed, 93 insertions, 3 deletions
diff --git a/chrome/browser/gpu_process_host.cc b/chrome/browser/gpu_process_host.cc index f2cdc80..ef90edc 100644 --- a/chrome/browser/gpu_process_host.cc +++ b/chrome/browser/gpu_process_host.cc @@ -11,9 +11,11 @@ #include "chrome/browser/child_process_host.h" #include "chrome/browser/child_process_launcher.h" #include "chrome/browser/io_thread.h" +#include "chrome/browser/renderer_host/render_process_host.h" #include "chrome/common/child_process_info.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/gpu_messages.h" +#include "chrome/common/render_messages.h" #include "ipc/ipc_switches.h" GpuProcessHost::GpuProcessHost() : last_routing_id_(1) { @@ -93,8 +95,7 @@ bool GpuProcessHost::Send(IPC::Message* msg) { void GpuProcessHost::OnMessageReceived(const IPC::Message& message) { if (message.routing_id() == MSG_ROUTING_CONTROL) { - // We don't currently have any control messages. - // OnControlMessageReceived(message); + OnControlMessageReceived(message); } else { router_.OnMessageReceived(message); } @@ -121,3 +122,40 @@ void GpuProcessHost::AddRoute(int32 routing_id, void GpuProcessHost::RemoveRoute(int32 routing_id) { router_.RemoveRoute(routing_id); } + +void GpuProcessHost::EstablishGpuChannel( + int renderer_id, + int routing_id) { + if (Send(new GpuMsg_EstablishChannel(renderer_id))) + sent_requests_.push(ChannelRequest(renderer_id, routing_id)); + else + ReplyToRenderer(renderer_id, routing_id, IPC::ChannelHandle()); +} + +void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { + IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) + IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) + IPC_MESSAGE_UNHANDLED_ERROR() + IPC_END_MESSAGE_MAP() +} + +void GpuProcessHost::OnChannelEstablished( + const IPC::ChannelHandle& channel_handle) { + const ChannelRequest& request = sent_requests_.front(); + + ReplyToRenderer(request.renderer_id, request.routing_id, channel_handle); + sent_requests_.pop(); +} + +void GpuProcessHost::ReplyToRenderer( + int renderer_id, + int routing_id, + const IPC::ChannelHandle& channel) { + // Check whether the renderer process is still around. + RenderProcessHost* process_host = RenderProcessHost::FromID(renderer_id); + if (!process_host) + return; + + CHECK(process_host->Send(new ViewMsg_GpuChannelEstablished(routing_id, + channel))); +} diff --git a/chrome/browser/gpu_process_host.h b/chrome/browser/gpu_process_host.h index d107b88..f64cdd8 100644 --- a/chrome/browser/gpu_process_host.h +++ b/chrome/browser/gpu_process_host.h @@ -13,9 +13,11 @@ #include "chrome/browser/child_process_launcher.h" #include "chrome/common/gpu_native_window_handle.h" #include "chrome/common/message_router.h" +#include "ipc/ipc_channel_handle.h" #include "ipc/ipc_channel_proxy.h" class ChildProcessLauncher; +class CommandBufferProxy; class GpuProcessHost : public IPC::Channel::Sender, public IPC::Channel::Listener, @@ -45,16 +47,51 @@ class GpuProcessHost : public IPC::Channel::Sender, void AddRoute(int32 routing_id, IPC::Channel::Listener* listener); void RemoveRoute(int32 routing_id); + // Tells the GPU process to create a new channel for communication with a + // renderer. Will asynchronously send message to object with given routing id + // on completion. + void EstablishGpuChannel(int renderer_id, int routing_id); + private: friend struct DefaultSingletonTraits<GpuProcessHost>; + // Used to queue pending channel requests. + struct ChannelRequest { + ChannelRequest(int renderer_id, + int routing_id) : + renderer_id(renderer_id), + routing_id(routing_id) {} + // Used to identify the renderer. The ID is used instead of a pointer to + // the RenderProcessHost in case it is destroyed while the request is + // pending. + // TODO(apatrick): investigate whether these IDs are used for future + // render processes. + int renderer_id; + + // Routing ID of object to receive reply message. + int routing_id; + }; + GpuProcessHost(); virtual ~GpuProcessHost(); + void OnControlMessageReceived(const IPC::Message& message); + + // Message handlers. + void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); + + void ReplyToRenderer(int renderer_id, + int routing_id, + const IPC::ChannelHandle& channel); + + // These are the channel requests that we have already sent to + // the GPU process, but haven't heard back about yet. + std::queue<ChannelRequest> sent_requests_; + scoped_ptr<ChildProcessLauncher> child_process_; // A proxy for our IPC::Channel that lives on the IO thread (see - // browser_process.h). This will be NULL if the class failed to initialize. + // browser_process.h). This will be NULL if the class failed to connect. scoped_ptr<IPC::ChannelProxy> channel_; int last_routing_id_; diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index a60adc2..b32a0e2 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -8,6 +8,7 @@ #include <vector> #include "base/basictypes.h" +#include "base/gfx/rect.h" #include "base/gfx/size.h" #include "base/process.h" #include "chrome/common/transport_dib.h" diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc index 44a36bd..2bee3e6 100644 --- a/chrome/browser/renderer_host/render_widget_host.cc +++ b/chrome/browser/renderer_host/render_widget_host.cc @@ -8,6 +8,7 @@ #include "base/histogram.h" #include "base/keyboard_codes.h" #include "base/message_loop.h" +#include "chrome/browser/gpu_process_host.h" #include "chrome/browser/renderer_host/backing_store.h" #include "chrome/browser/renderer_host/backing_store_manager.h" #include "chrome/browser/renderer_host/render_process_host.h" @@ -15,6 +16,7 @@ #include "chrome/browser/renderer_host/render_widget_host_painting_observer.h" #include "chrome/browser/renderer_host/render_widget_host_view.h" #include "chrome/browser/renderer_host/video_layer.h" +#include "chrome/common/gpu_messages.h" #include "chrome/common/notification_service.h" #include "chrome/common/render_messages.h" #include "webkit/glue/webcursor.h" @@ -137,6 +139,8 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) { IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateStatus, OnMsgImeUpdateStatus) + IPC_MESSAGE_HANDLER(ViewHostMsg_EstablishGpuChannel, + OnMsgEstablishGpuChannel) #if defined(OS_LINUX) IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer, OnMsgCreatePluginContainer) @@ -861,6 +865,10 @@ void RenderWidgetHost::OnMsgImeUpdateStatus(int control, } } +void RenderWidgetHost::OnMsgEstablishGpuChannel() { + GpuProcessHost::Get()->EstablishGpuChannel(process_->id(), routing_id_); +} + #if defined(OS_LINUX) void RenderWidgetHost::OnMsgCreatePluginContainer(gfx::PluginWindowHandle id) { diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h index f1b402e..a3fdfdf 100644 --- a/chrome/browser/renderer_host/render_widget_host.h +++ b/chrome/browser/renderer_host/render_widget_host.h @@ -13,6 +13,7 @@ #include "base/scoped_ptr.h" #include "base/string16.h" #include "base/timer.h" +#include "ipc/ipc_channel_handle.h" #include "chrome/common/edit_command.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/property_bag.h" @@ -443,6 +444,11 @@ class RenderWidgetHost : public IPC::Channel::Listener, // Using int instead of ViewHostMsg_ImeControl for control's type to avoid // having to bring in render_messages.h in a header file. void OnMsgImeUpdateStatus(int control, const gfx::Rect& caret_rect); + + // Renderer process is requesting that the browser process establish a GPU + // channel. + void OnMsgEstablishGpuChannel(); + #if defined(OS_LINUX) void OnMsgCreatePluginContainer(gfx::PluginWindowHandle id); void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id); |