summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 21:53:50 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-05 21:53:50 +0000
commit246a7045b9c45620fd725210aac51322e611c83f (patch)
tree6bdce605ae758c282a2b27e92a6b223d98b8d46a /chrome/renderer
parentc3240722a63ff142684575e3ea4eb89915edae72 (diff)
downloadchromium_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/renderer')
-rw-r--r--chrome/renderer/command_buffer_proxy.cc35
-rw-r--r--chrome/renderer/command_buffer_proxy.h8
-rw-r--r--chrome/renderer/gpu_channel_host.cc101
-rw-r--r--chrome/renderer/gpu_channel_host.h77
-rw-r--r--chrome/renderer/render_widget.cc41
-rw-r--r--chrome/renderer/render_widget.h15
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.cc27
-rw-r--r--chrome/renderer/webplugin_delegate_pepper.h2
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc15
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.h2
10 files changed, 293 insertions, 30 deletions
diff --git a/chrome/renderer/command_buffer_proxy.cc b/chrome/renderer/command_buffer_proxy.cc
index b2eaa86..bd0f3a0 100644
--- a/chrome/renderer/command_buffer_proxy.cc
+++ b/chrome/renderer/command_buffer_proxy.cc
@@ -4,7 +4,7 @@
#include "base/logging.h"
#include "base/process_util.h"
-#include "chrome/common/command_buffer_messages.h"
+#include "chrome/common/gpu_messages.h"
#include "chrome/common/plugin_messages.h"
#include "chrome/renderer/command_buffer_proxy.h"
#include "chrome/renderer/plugin_channel_host.h"
@@ -13,12 +13,11 @@
using gpu::Buffer;
CommandBufferProxy::CommandBufferProxy(
- PluginChannelHost* channel,
+ IPC::Channel::Sender* channel,
int route_id)
: size_(0),
channel_(channel),
route_id_(route_id) {
- channel->AddRoute(route_id_, this, false);
}
CommandBufferProxy::~CommandBufferProxy() {
@@ -30,20 +29,24 @@ CommandBufferProxy::~CommandBufferProxy() {
delete it->second.shared_memory;
it->second.shared_memory = NULL;
}
-
- channel_->RemoveRoute(route_id_);
}
void CommandBufferProxy::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(CommandBufferProxy, message)
- IPC_MESSAGE_HANDLER(CommandBufferMsg_UpdateState, OnUpdateState);
- IPC_MESSAGE_HANDLER(CommandBufferMsg_NotifyRepaint,
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_UpdateState, OnUpdateState);
+ IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_NotifyRepaint,
OnNotifyRepaint);
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
}
void CommandBufferProxy::OnChannelError() {
+ // Prevent any further messages from being sent.
+ channel_ = NULL;
+
+ // When the client sees that the context is lost, they should delete this
+ // CommandBufferProxy and create a new one.
+ last_state_.error = gpu::error::kLostContext;
}
bool CommandBufferProxy::Send(IPC::Message* msg) {
@@ -63,7 +66,7 @@ bool CommandBufferProxy::Initialize(int32 size) {
// process is responsible for duplicating the handle. This might not be true
// for NaCl.
base::SharedMemoryHandle handle;
- if (Send(new CommandBufferMsg_Initialize(route_id_, size, &handle)) &&
+ if (Send(new GpuCommandBufferMsg_Initialize(route_id_, size, &handle)) &&
base::SharedMemory::IsHandleValid(handle)) {
ring_buffer_.reset(new base::SharedMemory(handle, false));
if (ring_buffer_->Map(size * sizeof(int32))) {
@@ -87,12 +90,12 @@ Buffer CommandBufferProxy::GetRingBuffer() {
}
gpu::CommandBuffer::State CommandBufferProxy::GetState() {
- Send(new CommandBufferMsg_GetState(route_id_, &last_state_));
+ Send(new GpuCommandBufferMsg_GetState(route_id_, &last_state_));
return last_state_;
}
gpu::CommandBuffer::State CommandBufferProxy::Flush(int32 put_offset) {
- Send(new CommandBufferMsg_Flush(route_id_,
+ Send(new GpuCommandBufferMsg_Flush(route_id_,
put_offset,
&last_state_));
return last_state_;
@@ -105,7 +108,7 @@ void CommandBufferProxy::SetGetOffset(int32 get_offset) {
int32 CommandBufferProxy::CreateTransferBuffer(size_t size) {
int32 id;
- if (Send(new CommandBufferMsg_CreateTransferBuffer(route_id_, size, &id)))
+ if (Send(new GpuCommandBufferMsg_CreateTransferBuffer(route_id_, size, &id)))
return id;
return -1;
@@ -121,7 +124,7 @@ void CommandBufferProxy::DestroyTransferBuffer(int32 id) {
transfer_buffers_.erase(it);
- Send(new CommandBufferMsg_DestroyTransferBuffer(route_id_, id));
+ Send(new GpuCommandBufferMsg_DestroyTransferBuffer(route_id_, id));
}
Buffer CommandBufferProxy::GetTransferBuffer(int32 id) {
@@ -136,7 +139,7 @@ Buffer CommandBufferProxy::GetTransferBuffer(int32 id) {
// duplicating the handle. This might not be true for NaCl.
base::SharedMemoryHandle handle;
uint32 size;
- if (!Send(new CommandBufferMsg_GetTransferBuffer(route_id_,
+ if (!Send(new GpuCommandBufferMsg_GetTransferBuffer(route_id_,
id,
&handle,
&size))) {
@@ -182,12 +185,12 @@ void CommandBufferProxy::SetParseError(
#if defined(OS_MACOSX)
void CommandBufferProxy::SetWindowSize(int32 width, int32 height) {
- Send(new CommandBufferMsg_SetWindowSize(route_id_, width, height));
+ Send(new GpuCommandBufferMsg_SetWindowSize(route_id_, width, height));
}
#endif
void CommandBufferProxy::AsyncGetState(Task* completion_task) {
- IPC::Message* message = new CommandBufferMsg_AsyncGetState(route_id_);
+ IPC::Message* message = new GpuCommandBufferMsg_AsyncGetState(route_id_);
// Do not let a synchronous flush hold up this message. If this handler is
// deferred until after the synchronous flush completes, it will overwrite the
@@ -199,7 +202,7 @@ void CommandBufferProxy::AsyncGetState(Task* completion_task) {
}
void CommandBufferProxy::AsyncFlush(int32 put_offset, Task* completion_task) {
- IPC::Message* message = new CommandBufferMsg_AsyncFlush(route_id_,
+ IPC::Message* message = new GpuCommandBufferMsg_AsyncFlush(route_id_,
put_offset);
// Do not let a synchronous flush hold up this message. If this handler is
diff --git a/chrome/renderer/command_buffer_proxy.h b/chrome/renderer/command_buffer_proxy.h
index 990f6f3..5d72f2c 100644
--- a/chrome/renderer/command_buffer_proxy.h
+++ b/chrome/renderer/command_buffer_proxy.h
@@ -27,9 +27,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
public IPC::Channel::Listener,
public IPC::Message::Sender {
public:
- explicit CommandBufferProxy(
- PluginChannelHost* channel,
- int route_id);
+ CommandBufferProxy(IPC::Channel::Sender* channel, int route_id);
virtual ~CommandBufferProxy();
// IPC::Channel::Listener implementation:
@@ -39,6 +37,8 @@ class CommandBufferProxy : public gpu::CommandBuffer,
// IPC::Message::Sender implementation:
virtual bool Send(IPC::Message* msg);
+ int route_id() const { return route_id_; }
+
// CommandBuffer implementation:
virtual bool Initialize(int32 size);
virtual gpu::Buffer GetRingBuffer();
@@ -90,7 +90,7 @@ class CommandBufferProxy : public gpu::CommandBuffer,
// The last cached state received from the service.
State last_state_;
- scoped_refptr<PluginChannelHost> channel_;
+ IPC::Channel::Sender* channel_;
int route_id_;
// Pending asynchronous flush callbacks.
diff --git a/chrome/renderer/gpu_channel_host.cc b/chrome/renderer/gpu_channel_host.cc
new file mode 100644
index 0000000..8e48b85
--- /dev/null
+++ b/chrome/renderer/gpu_channel_host.cc
@@ -0,0 +1,101 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/renderer/gpu_channel_host.h"
+
+#include "chrome/common/child_process.h"
+#include "chrome/common/gpu_messages.h"
+#include "chrome/renderer/command_buffer_proxy.h"
+
+GpuChannelHost::GpuChannelHost() : state_(UNCONNECTED) {
+}
+
+GpuChannelHost::~GpuChannelHost() {
+}
+
+void GpuChannelHost::Connect(const std::string& channel_name) {
+ // Open a channel to the GPU process.
+ channel_.reset(new IPC::SyncChannel(
+ channel_name, IPC::Channel::MODE_CLIENT, this, NULL,
+ ChildProcess::current()->io_message_loop(), true,
+ ChildProcess::current()->GetShutDownEvent()));
+}
+
+void GpuChannelHost::OnMessageReceived(const IPC::Message& message) {
+ DCHECK(message.routing_id() != MSG_ROUTING_CONTROL);
+ if (!router_.RouteMessage(message)) {
+ NOTREACHED() << "GpuChannelHost failed to route message";
+ }
+}
+
+void GpuChannelHost::OnChannelConnected(int32 peer_pid) {
+ state_ = CONNECTED;
+}
+
+void GpuChannelHost::OnChannelError() {
+ state_ = LOST;
+
+ // Channel is invalid and will be reinitialized if this host is requested
+ // again.
+ channel_.reset();
+
+ // Inform all the proxies that an error has occured. This will be reported via
+ // OpenGL as a lost context.
+ for (ProxyMap::iterator iter = proxies_.begin();
+ iter != proxies_.end(); iter++) {
+ proxies_.erase(iter->first);
+ router_.RemoveRoute(iter->first);
+ iter->second->OnChannelError();
+ }
+
+ // The proxies are reference counted so this will not result in their
+ // destruction if the client still holds a reference. The proxy will report
+ // a lost context, indicating to the client that it needs to be recreated.
+ proxies_.clear();
+}
+
+bool GpuChannelHost::Send(IPC::Message* message) {
+ if (!channel_.get()) {
+ delete message;
+ return false;
+ }
+
+ return channel_->Send(message);
+}
+
+CommandBufferProxy* GpuChannelHost::CreateCommandBuffer() {
+#if defined(ENABLE_GPU)
+ // An error occurred. Need to get the host again to reinitialize it.
+ if (!channel_.get())
+ return NULL;
+
+ int32 route_id;
+ if (!Send(new GpuChannelMsg_CreateCommandBuffer(&route_id)) &&
+ route_id != MSG_ROUTING_NONE) {
+ return NULL;
+ }
+
+ CommandBufferProxy* command_buffer = new CommandBufferProxy(this, route_id);
+ router_.AddRoute(route_id, command_buffer);
+ proxies_[route_id] = command_buffer;
+ return command_buffer;
+#else
+ return NULL;
+#endif
+}
+
+void GpuChannelHost::DestroyCommandBuffer(CommandBufferProxy* command_buffer) {
+#if defined(ENABLE_GPU)
+ Send(new GpuChannelMsg_DestroyCommandBuffer(command_buffer->route_id()));
+
+ // Check the proxy has not already been removed after a channel error.
+ int route_id = command_buffer->route_id();
+ if (proxies_.find(command_buffer->route_id()) != proxies_.end()) {
+ proxies_.erase(route_id);
+ router_.RemoveRoute(route_id);
+ }
+
+ delete command_buffer;
+#endif
+}
diff --git a/chrome/renderer/gpu_channel_host.h b/chrome/renderer/gpu_channel_host.h
new file mode 100644
index 0000000..00a6129
--- /dev/null
+++ b/chrome/renderer/gpu_channel_host.h
@@ -0,0 +1,77 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_RENDERER_GPU_CHANNEL_HOST_H_
+#define CHROME_RENDERER_GPU_CHANNEL_HOST_H_
+
+#include <string>
+
+#include "base/hash_tables.h"
+#include "chrome/common/message_router.h"
+#include "ipc/ipc_channel.h"
+#include "ipc/ipc_message.h"
+#include "ipc/ipc_sync_channel.h"
+
+class CommandBufferProxy;
+
+// Encapsulates an IPC channel between the renderer and one plugin process.
+// On the plugin side there's a corresponding GpuChannel.
+class GpuChannelHost : public IPC::Channel::Listener,
+ public IPC::Message::Sender,
+ public base::RefCountedThreadSafe<GpuChannelHost> {
+ public:
+ enum State {
+ // Not yet connected.
+ UNCONNECTED,
+ // Ready to use.
+ CONNECTED,
+ // An error caused the host to become disconnected. Recreate channel to
+ // reestablish connection.
+ LOST
+ };
+
+ // Called on the render thread
+ GpuChannelHost();
+ ~GpuChannelHost();
+
+ // Connect to GPU process channel.
+ void Connect(const std::string& channel_name);
+
+ State state() const { return state_; }
+
+ // Returns whether the channel to the GPU process is ready.
+ bool ready() const { return channel_.get() != NULL; }
+
+ // IPC::Channel::Listener implementation:
+ virtual void OnMessageReceived(const IPC::Message& msg);
+ virtual void OnChannelConnected(int32 peer_pid);
+ virtual void OnChannelError();
+
+ // IPC::Message::Sender implementation:
+ virtual bool Send(IPC::Message* msg);
+
+ // Create and connect to a command buffer in the GPU process.
+ CommandBufferProxy* CreateCommandBuffer();
+
+ // Destroy a command buffer created by this channel.
+ void DestroyCommandBuffer(CommandBufferProxy* command_buffer);
+
+ private:
+ State state_;
+
+ scoped_ptr<IPC::SyncChannel> channel_;
+
+ // Used to implement message routing functionality to CommandBufferProxy
+ // objects
+ MessageRouter router_;
+
+ // Keep track of all the registered CommandBufferProxies to
+ // inform about OnChannelError
+ typedef base::hash_map<int, IPC::Channel::Listener*> ProxyMap;
+ ProxyMap proxies_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuChannelHost);
+};
+
+#endif // CHROME_RENDERER_GPU_CHANNEL_HOST_H_
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 343db541..7d59256 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -147,6 +147,7 @@ IPC_DEFINE_MESSAGE_MAP(RenderWidget)
IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition)
IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnMsgRepaint)
IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection)
+ IPC_MESSAGE_HANDLER(ViewMsg_GpuChannelEstablished, OnGpuChannelEstablished)
IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck)
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
@@ -725,6 +726,17 @@ void RenderWidget::OnSetTextDirection(WebTextDirection direction) {
webwidget_->setTextDirection(direction);
}
+void RenderWidget::OnGpuChannelEstablished(
+ const IPC::ChannelHandle& channel_handle) {
+ if (channel_handle.name.size() != 0) {
+ // Connect to the GPU process if a channel name was received.
+ gpu_channel_->Connect(channel_handle.name);
+ } else {
+ // Otherwise cancel the connection.
+ gpu_channel_ = NULL;
+ }
+}
+
void RenderWidget::SetHidden(bool hidden) {
if (is_hidden_ == hidden)
return;
@@ -867,3 +879,32 @@ void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) {
}
}
}
+
+void RenderWidget::EstablishGpuChannel() {
+ if (gpu_channel_.get()) {
+ // Do nothing if we are already establishing GPU channel.
+ if (gpu_channel_->state() == GpuChannelHost::UNCONNECTED)
+ return;
+
+ // Recreate the channel if it has been lost.
+ if (gpu_channel_->state() == GpuChannelHost::LOST)
+ gpu_channel_ = NULL;
+ }
+
+ if (!gpu_channel_.get())
+ gpu_channel_ = new GpuChannelHost;
+
+ // Ask the browser for the channel name.
+ CHECK(Send(new ViewHostMsg_EstablishGpuChannel(routing_id_)));
+}
+
+GpuChannelHost* RenderWidget::GetGpuChannel() {
+ if (!gpu_channel_.get())
+ return NULL;
+
+ if (gpu_channel_->state() != GpuChannelHost::CONNECTED)
+ return NULL;
+
+ return gpu_channel_.get();
+}
+
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index ab591f0..cc32898 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -14,9 +14,11 @@
#include "base/gfx/size.h"
#include "base/ref_counted.h"
#include "base/shared_memory.h"
+#include "chrome/renderer/gpu_channel_host.h"
#include "chrome/renderer/paint_aggregator.h"
#include "chrome/renderer/render_process.h"
#include "ipc/ipc_channel.h"
+#include "ipc/ipc_channel_handle.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCompositionCommand.h"
@@ -105,6 +107,15 @@ class RenderWidget : public IPC::Channel::Listener,
// Close the underlying WebWidget.
virtual void Close();
+ // Asynchronously establish a channel to the GPU plugin if not previously
+ // established or if it has been lost (for example if the GPU plugin crashed).
+ // Use GetGpuChannel() to determine when the channel is ready for use.
+ void EstablishGpuChannel();
+
+ // Get the GPU channel. Returns NULL if the channel is not established or
+ // has been lost.
+ GpuChannelHost* GetGpuChannel();
+
protected:
// Friend RefCounted so that the dtor can be non-public. Using this class
// without ref-counting is an error.
@@ -160,6 +171,7 @@ class RenderWidget : public IPC::Channel::Listener,
const string16& ime_string);
void OnMsgRepaint(const gfx::Size& size_to_paint);
void OnSetTextDirection(WebKit::WebTextDirection direction);
+ void OnGpuChannelEstablished(const IPC::ChannelHandle& channel_handle);
// Override point to notify that a paint has happened. This fires after the
// browser side has updated the screen for a newly painted region.
@@ -317,6 +329,9 @@ class RenderWidget : public IPC::Channel::Listener,
// Indicates if the next sequence of Char events should be suppressed or not.
bool suppress_next_char_events_;
+ // The channel from the renderer process to the GPU process.
+ scoped_refptr<GpuChannelHost> gpu_channel_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};
diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc
index 5f09e65..e6efd40 100644
--- a/chrome/renderer/webplugin_delegate_pepper.cc
+++ b/chrome/renderer/webplugin_delegate_pepper.cc
@@ -123,6 +123,13 @@ void WebPluginDelegatePepper::DestroyInstance() {
// rendering commands after the GPU plugin has stopped processing them and
// responding to them.
if (nested_delegate_) {
+#if defined(ENABLE_GPU)
+ if (command_buffer_) {
+ nested_delegate_->DestroyCommandBuffer(command_buffer_);
+ command_buffer_ = NULL;
+ }
+#endif
+
nested_delegate_->PluginDestroyed();
nested_delegate_ = NULL;
}
@@ -159,7 +166,7 @@ void WebPluginDelegatePepper::UpdateGeometry(
// Send the new window size to the command buffer service code so it
// can allocate a new backing store. The handle to the new backing
// store is sent back to the browser asynchronously.
- if (command_buffer_.get()) {
+ if (command_buffer_) {
command_buffer_->SetWindowSize(window_rect_.width(),
window_rect_.height());
}
@@ -364,8 +371,8 @@ NPError WebPluginDelegatePepper::Device3DInitializeContext(
plugin_->SetAcceptsInputEvents(true);
// Ask the GPU plugin to create a command buffer and return a proxy.
- command_buffer_.reset(nested_delegate_->CreateCommandBuffer());
- if (command_buffer_.get()) {
+ command_buffer_ = nested_delegate_->CreateCommandBuffer();
+ if (command_buffer_) {
// Initialize the proxy command buffer.
if (command_buffer_->Initialize(config->commandBufferSize)) {
// Get the initial command buffer state.
@@ -395,14 +402,15 @@ NPError WebPluginDelegatePepper::Device3DInitializeContext(
// Save the implementation information (the CommandBuffer).
Device3DImpl* impl = new Device3DImpl;
- impl->command_buffer = command_buffer_.get();
+ impl->command_buffer = command_buffer_;
context->reserved = impl;
return NPERR_NO_ERROR;
}
}
- command_buffer_.reset();
+ nested_delegate_->DestroyCommandBuffer(command_buffer_);
+ command_buffer_ = NULL;
}
nested_delegate_->PluginDestroyed();
@@ -482,9 +490,12 @@ NPError WebPluginDelegatePepper::Device3DDestroyContext(
delete static_cast<Device3DImpl*>(context->reserved);
context->reserved = NULL;
- command_buffer_.reset();
-
if (nested_delegate_) {
+ if (command_buffer_) {
+ nested_delegate_->DestroyCommandBuffer(command_buffer_);
+ command_buffer_ = NULL;
+ }
+
nested_delegate_->PluginDestroyed();
nested_delegate_ = NULL;
}
@@ -849,7 +860,7 @@ void WebPluginDelegatePepper::Device3DUpdateState(
NPDeviceContext3D* context,
NPDeviceFlushContextCallbackPtr callback,
void* user_data) {
- if (command_buffer_.get()) {
+ if (command_buffer_) {
Synchronize3DContext(context, command_buffer_->GetLastState());
if (callback)
callback(npp, context, NPERR_NO_ERROR, user_data);
diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h
index a67b530..181b40b 100644
--- a/chrome/renderer/webplugin_delegate_pepper.h
+++ b/chrome/renderer/webplugin_delegate_pepper.h
@@ -205,7 +205,7 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate {
#if defined(ENABLE_GPU)
// The command buffer used to issue commands to the nested GPU plugin.
- scoped_ptr<CommandBufferProxy> command_buffer_;
+ CommandBufferProxy* command_buffer_;
#endif
// Tells the browser out-of-band where the nested delegate lives on
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index 4157a1f..1e64648 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -1280,12 +1280,25 @@ CommandBufferProxy* WebPluginDelegateProxy::CreateCommandBuffer() {
return NULL;
}
- return new CommandBufferProxy(channel_host_, command_buffer_id);
+ CommandBufferProxy* command_buffer =
+ new CommandBufferProxy(channel_host_, command_buffer_id);
+ channel_host_->AddRoute(command_buffer_id, command_buffer, NULL);
+ return command_buffer;
#else
return NULL;
#endif // ENABLE_GPU
}
+void WebPluginDelegateProxy::DestroyCommandBuffer(
+ CommandBufferProxy* command_buffer) {
+ DCHECK(command_buffer);
+#if defined(ENABLE_GPU)
+ Send(new PluginMsg_DestroyCommandBuffer(instance_id_));
+ channel_host_->RemoveRoute(command_buffer->route_id());
+ delete command_buffer;
+#endif
+}
+
gfx::PluginWindowHandle WebPluginDelegateProxy::GetPluginWindowHandle() {
return window_;
}
diff --git a/chrome/renderer/webplugin_delegate_proxy.h b/chrome/renderer/webplugin_delegate_proxy.h
index 18d2704..212758e 100644
--- a/chrome/renderer/webplugin_delegate_proxy.h
+++ b/chrome/renderer/webplugin_delegate_proxy.h
@@ -106,6 +106,8 @@ class WebPluginDelegateProxy
unsigned long resource_id, int range_request_id);
CommandBufferProxy* CreateCommandBuffer();
+ void DestroyCommandBuffer(CommandBufferProxy* command_buffer);
+
gfx::PluginWindowHandle GetPluginWindowHandle();
protected: