Commit d8a58e44 authored by backer@chromium.org's avatar backer@chromium.org

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
parent 5ba9c9ae
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include "chrome/browser/gpu_blacklist.h" #include "chrome/browser/gpu_blacklist.h"
#include "chrome/browser/gpu_process_host_ui_shim.h" #include "chrome/browser/gpu_process_host_ui_shim.h"
#include "chrome/browser/renderer_host/render_message_filter.h" #include "chrome/browser/renderer_host/render_message_filter.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view.h"
#include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/gpu_feature_flags.h" #include "chrome/common/gpu_feature_flags.h"
...@@ -26,6 +28,10 @@ ...@@ -26,6 +28,10 @@
#include "media/base/media_switches.h" #include "media/base/media_switches.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
#if defined(OS_LINUX)
#include "gfx/gtk_native_view_id_manager.h"
#endif // defined(OS_LINUX)
namespace { namespace {
enum GPUProcessLifetimeEvent { enum GPUProcessLifetimeEvent {
...@@ -65,6 +71,15 @@ void RouteOnUIThread(const IPC::Message& message) { ...@@ -65,6 +71,15 @@ void RouteOnUIThread(const IPC::Message& message) {
FROM_HERE, FROM_HERE,
new RouteOnUIThreadTask(message)); new RouteOnUIThreadTask(message));
} }
bool SendDelayedMsg(IPC::Message* reply_msg) {
return GpuProcessHost::Get()->Send(reply_msg);
}
bool SendDelayedMsg(IPC::Message* reply, RenderMessageFilter* filter) {
return filter->Send(reply);
}
} // anonymous namespace } // anonymous namespace
class GpuMainThread : public base::Thread { class GpuMainThread : public base::Thread {
...@@ -181,26 +196,119 @@ void GpuProcessHost::Synchronize(IPC::Message* reply, ...@@ -181,26 +196,119 @@ void GpuProcessHost::Synchronize(IPC::Message* reply,
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
if (Send(new GpuMsg_Synchronize())) { if (Send(new GpuMsg_Synchronize())) {
queued_synchronization_replies_.push(SynchronizationRequest(reply, filter)); queued_synchronization_replies_.push(DelayedReply(reply, filter));
} else { } else {
SendSynchronizationReply(reply, filter); SendDelayedMsg(reply, filter);
}
}
class CVCBThreadHopping {
public:
// Send the request for a command buffer from the IO thread and
// queue that we are expecting a response.
static void DispatchIPCAndQueueReply(
gfx::PluginWindowHandle view,
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
scoped_refptr<RenderMessageFilter> filter);
// Get a window for the command buffer that we're creating.
static void GetViewWindow(
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
scoped_refptr<RenderMessageFilter> filter);
};
void CVCBThreadHopping::DispatchIPCAndQueueReply(
gfx::PluginWindowHandle view,
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
scoped_refptr<RenderMessageFilter> filter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
GpuProcessHost* host = GpuProcessHost::Get();
if (view != gfx::kNullPluginWindow &&
SendDelayedMsg(new GpuMsg_CreateViewCommandBuffer(
view, render_view_id, renderer_id, init_params))) {
host->create_command_buffer_replies_.push(
GpuProcessHost::DelayedReply(reply, filter));
} else {
int32 route_id = MSG_ROUTING_NONE;
ViewHostMsg_CreateViewCommandBuffer::WriteReplyParams(reply, route_id);
SendDelayedMsg(reply, filter);
}
}
void CVCBThreadHopping::GetViewWindow(
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
scoped_refptr<RenderMessageFilter> filter) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
gfx::PluginWindowHandle window = gfx::kNullPluginWindow;
RenderViewHost* host = RenderViewHost::FromID(renderer_id,
render_view_id);
#if defined(OS_LINUX)
gfx::NativeViewId view = NULL;
if (host)
view = gfx::IdFromNativeView(host->view()->GetNativeView());
// Lock the window that we will draw into.
GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
if (!manager->GetPermanentXIDForId(&window, view)) {
DLOG(ERROR) << "Can't find XID for view id " << view;
} }
#elif defined(OS_MACOSX)
// On Mac OS X we currently pass a (fake) PluginWindowHandle for the
// window that we draw to.
window = host->view()->AllocateFakePluginWindowHandle(
/*opaque=*/true, /*root=*/true);
#elif defined(OS_WIN)
// Create a window that we will overlay.
window = host->view()->GetCompositorHostWindow();
#endif
BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableFunction(
&CVCBThreadHopping::DispatchIPCAndQueueReply,
window, render_view_id, renderer_id, init_params, reply, filter));
} }
void GpuProcessHost::CreateViewCommandBuffer(
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
RenderMessageFilter* filter) {
DCHECK(CalledOnValidThread());
BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableFunction(
&CVCBThreadHopping::GetViewWindow,
render_view_id, renderer_id, init_params, reply,
static_cast<scoped_refptr<RenderMessageFilter> > (filter)));
}
GpuProcessHost::ChannelRequest::ChannelRequest(RenderMessageFilter* filter) GpuProcessHost::ChannelRequest::ChannelRequest(RenderMessageFilter* filter)
: filter(filter) { : filter(filter) {
} }
GpuProcessHost::ChannelRequest::~ChannelRequest() {} GpuProcessHost::ChannelRequest::~ChannelRequest() {}
GpuProcessHost::SynchronizationRequest::SynchronizationRequest( GpuProcessHost::DelayedReply::DelayedReply(
IPC::Message* reply, IPC::Message* reply,
RenderMessageFilter* filter) RenderMessageFilter* filter)
: reply(reply), : reply(reply),
filter(filter) { filter(filter) {
} }
GpuProcessHost::SynchronizationRequest::~SynchronizationRequest() {} GpuProcessHost::DelayedReply::~DelayedReply() {}
bool GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { bool GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
...@@ -208,6 +316,7 @@ bool GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { ...@@ -208,6 +316,7 @@ bool GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message)
IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished)
IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply)
IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated)
// If the IO thread does not handle the message then automatically route it // If the IO thread does not handle the message then automatically route it
// to the UI thread. The UI thread will report an error if it does not // to the UI thread. The UI thread will report an error if it does not
// handle it. // handle it.
...@@ -256,13 +365,24 @@ void GpuProcessHost::OnChannelEstablished( ...@@ -256,13 +365,24 @@ void GpuProcessHost::OnChannelEstablished(
void GpuProcessHost::OnSynchronizeReply() { void GpuProcessHost::OnSynchronizeReply() {
// Guard against race conditions in abrupt GPU process termination. // Guard against race conditions in abrupt GPU process termination.
if (queued_synchronization_replies_.size() > 0) { if (queued_synchronization_replies_.size() > 0) {
const SynchronizationRequest& request = const DelayedReply& request =
queued_synchronization_replies_.front(); queued_synchronization_replies_.front();
SendSynchronizationReply(request.reply, request.filter); SendDelayedMsg(request.reply, request.filter);
queued_synchronization_replies_.pop(); queued_synchronization_replies_.pop();
} }
} }
void GpuProcessHost::OnCommandBufferCreated(const int32 route_id) {
if (create_command_buffer_replies_.size() > 0) {
const DelayedReply& request =
create_command_buffer_replies_.front();
ViewHostMsg_CreateViewCommandBuffer::WriteReplyParams(
request.reply, route_id);
SendDelayedMsg(request.reply, request.filter);
create_command_buffer_replies_.pop();
}
}
void GpuProcessHost::SendEstablishChannelReply( void GpuProcessHost::SendEstablishChannelReply(
const IPC::ChannelHandle& channel, const IPC::ChannelHandle& channel,
const GPUInfo& gpu_info, const GPUInfo& gpu_info,
...@@ -276,13 +396,6 @@ void GpuProcessHost::SendEstablishChannelReply( ...@@ -276,13 +396,6 @@ void GpuProcessHost::SendEstablishChannelReply(
filter->Send(message); filter->Send(message);
} }
// Sends the response for synchronization request to the renderer.
void GpuProcessHost::SendSynchronizationReply(
IPC::Message* reply,
RenderMessageFilter* filter) {
filter->Send(reply);
}
void GpuProcessHost::SendOutstandingReplies() { void GpuProcessHost::SendOutstandingReplies() {
// First send empty channel handles for all EstablishChannel requests. // First send empty channel handles for all EstablishChannel requests.
while (!sent_requests_.empty()) { while (!sent_requests_.empty()) {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "gfx/native_widget_types.h" #include "gfx/native_widget_types.h"
class GpuBlacklist; class GpuBlacklist;
struct GPUCreateCommandBufferConfig;
class GPUInfo; class GPUInfo;
class RenderMessageFilter; class RenderMessageFilter;
...@@ -44,6 +45,19 @@ class GpuProcessHost : public BrowserChildProcessHost, ...@@ -44,6 +45,19 @@ class GpuProcessHost : public BrowserChildProcessHost,
// in. // in.
void Synchronize(IPC::Message* reply, RenderMessageFilter* filter); void Synchronize(IPC::Message* reply, RenderMessageFilter* filter);
// Tells the GPU process to create a new command buffer that draws into the
// window associated with the given renderer.
void CreateViewCommandBuffer(
int32 render_view_id,
int32 renderer_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply,
RenderMessageFilter* filter);
// We need to hop threads when creating the command buffer.
// Let these tasks access our internals.
friend class CVCBThreadHopping;
private: private:
// Used to queue pending channel requests. // Used to queue pending channel requests.
struct ChannelRequest { struct ChannelRequest {
...@@ -54,10 +68,9 @@ class GpuProcessHost : public BrowserChildProcessHost, ...@@ -54,10 +68,9 @@ class GpuProcessHost : public BrowserChildProcessHost,
scoped_refptr<RenderMessageFilter> filter; scoped_refptr<RenderMessageFilter> filter;
}; };
// Used to queue pending synchronization requests. struct DelayedReply {
struct SynchronizationRequest { DelayedReply(IPC::Message* reply, RenderMessageFilter* filter);
SynchronizationRequest(IPC::Message* reply, RenderMessageFilter* filter); ~DelayedReply();
~SynchronizationRequest();
// The delayed reply message which needs to be sent to the // The delayed reply message which needs to be sent to the
// renderer. // renderer.
...@@ -79,14 +92,12 @@ class GpuProcessHost : public BrowserChildProcessHost, ...@@ -79,14 +92,12 @@ class GpuProcessHost : public BrowserChildProcessHost,
void OnChannelEstablished(const IPC::ChannelHandle& channel_handle, void OnChannelEstablished(const IPC::ChannelHandle& channel_handle,
const GPUInfo& gpu_info); const GPUInfo& gpu_info);
void OnSynchronizeReply(); void OnSynchronizeReply();
void OnCommandBufferCreated(const int32 route_id);
// Sends the response for establish channel request to the renderer. // Sends the response for establish channel request to the renderer.
void SendEstablishChannelReply(const IPC::ChannelHandle& channel, void SendEstablishChannelReply(const IPC::ChannelHandle& channel,
const GPUInfo& gpu_info, const GPUInfo& gpu_info,
RenderMessageFilter* filter); RenderMessageFilter* filter);
// Sends the response for synchronization request to the renderer.
void SendSynchronizationReply(IPC::Message* reply,
RenderMessageFilter* filter);
// Sends outstanding replies to renderer processes. This is only called // Sends outstanding replies to renderer processes. This is only called
// in error situations like the GPU process crashing -- but is necessary // in error situations like the GPU process crashing -- but is necessary
...@@ -114,9 +125,13 @@ class GpuProcessHost : public BrowserChildProcessHost, ...@@ -114,9 +125,13 @@ class GpuProcessHost : public BrowserChildProcessHost,
std::queue<ChannelRequest> sent_requests_; std::queue<ChannelRequest> sent_requests_;
// The pending synchronization requests we need to reply to. // The pending synchronization requests we need to reply to.
std::queue<SynchronizationRequest> queued_synchronization_replies_; std::queue<DelayedReply> queued_synchronization_replies_;
// The pending create command buffer requests we need to reply to.
std::queue<DelayedReply> create_command_buffer_replies_;
DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); DISALLOW_COPY_AND_ASSIGN(GpuProcessHost);
}; };
#endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_ #endif // CHROME_BROWSER_GPU_PROCESS_HOST_H_
...@@ -112,6 +112,32 @@ const GPUInfo& GpuProcessHostUIShim::gpu_info() const { ...@@ -112,6 +112,32 @@ const GPUInfo& GpuProcessHostUIShim::gpu_info() const {
return gpu_info_; return gpu_info_;
} }
void GpuProcessHostUIShim::OnDestroyCommandBuffer(
gfx::PluginWindowHandle window, int32 renderer_id,
int32 render_view_id) {
if (!window)
return;
#if defined(OS_LINUX)
GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
manager->ReleasePermanentXID(window);
#elif defined(OS_MACOSX) || defined(OS_WIN)
RenderViewHost* host = RenderViewHost::FromID(renderer_id,
render_view_id);
if (!host)
return;
RenderWidgetHostView* view = host->view();
if (!view)
return;
#if defined(OS_MACOSX)
view->DestroyFakePluginWindowHandle(window);
#elif defined(OS_WIN)
view->ShowCompositorHostWindow(false);
#endif
#endif // defined(OS_MACOSX) || defined(OS_WIN)
}
void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
gpu_info_ = gpu_info; gpu_info_ = gpu_info;
child_process_logging::SetGpuInfo(gpu_info); child_process_logging::SetGpuInfo(gpu_info);
...@@ -121,6 +147,31 @@ void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) { ...@@ -121,6 +147,31 @@ void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
gpu_info_collected_callback_->Run(); gpu_info_collected_callback_->Run();
} }
bool GpuProcessHostUIShim::OnControlMessageReceived(
const IPC::Message& message) {
DCHECK(CalledOnValidThread());
IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer,
OnDestroyCommandBuffer)
IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
OnGraphicsInfoCollected)
#if defined(OS_LINUX)
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID)
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
OnAcceleratedSurfaceSetIOSurface)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
#elif defined(OS_WIN)
IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite);
#endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
return true;
}
namespace { namespace {
void SendDelayedReply(IPC::Message* reply_msg) { void SendDelayedReply(IPC::Message* reply_msg) {
...@@ -134,25 +185,6 @@ void SendDelayedReply(IPC::Message* reply_msg) { ...@@ -134,25 +185,6 @@ void SendDelayedReply(IPC::Message* reply_msg) {
#if defined(OS_LINUX) #if defined(OS_LINUX)
void GpuProcessHostUIShim::OnGetViewXID(gfx::NativeViewId id,
IPC::Message* reply_msg) {
XID xid;
GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
if (!manager->GetPermanentXIDForId(&xid, id)) {
DLOG(ERROR) << "Can't find XID for view id " << id;
xid = 0;
}
GpuHostMsg_GetViewXID::WriteReplyParams(reply_msg, xid);
SendDelayedReply(reply_msg);
}
void GpuProcessHostUIShim::OnReleaseXID(unsigned long xid) {
GtkNativeViewManager* manager = GtkNativeViewManager::GetInstance();
manager->ReleasePermanentXID(xid);
}
void GpuProcessHostUIShim::OnResizeXID(unsigned long xid, gfx::Size size, void GpuProcessHostUIShim::OnResizeXID(unsigned long xid, gfx::Size size,
IPC::Message *reply_msg) { IPC::Message *reply_msg) {
GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid)); GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid));
...@@ -204,26 +236,6 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( ...@@ -204,26 +236,6 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
#elif defined(OS_WIN) #elif defined(OS_WIN)
void GpuProcessHostUIShim::OnGetCompositorHostWindow(
int renderer_id,
int render_view_id,
IPC::Message* reply_msg) {
RenderViewHost* host = RenderViewHost::FromID(renderer_id,
render_view_id);
if (!host) {
GpuHostMsg_GetCompositorHostWindow::WriteReplyParams(reply_msg,
gfx::kNullPluginWindow);
SendDelayedReply(reply_msg);
return;
}
RenderWidgetHostView* view = host->view();
gfx::PluginWindowHandle id = view->GetCompositorHostWindow();
GpuHostMsg_GetCompositorHostWindow::WriteReplyParams(reply_msg, id);
SendDelayedReply(reply_msg);
}
void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
int render_view_id) { int render_view_id) {
RenderViewHost* host = RenderViewHost::FromID(renderer_id, RenderViewHost* host = RenderViewHost::FromID(renderer_id,
...@@ -233,31 +245,5 @@ void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id, ...@@ -233,31 +245,5 @@ void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
} }
host->ScheduleComposite(); host->ScheduleComposite();
} }
#endif
bool GpuProcessHostUIShim::OnControlMessageReceived(
const IPC::Message& message) {
DCHECK(CalledOnValidThread());
IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
OnGraphicsInfoCollected)
#if defined(OS_LINUX)
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID)
IPC_MESSAGE_HANDLER(GpuHostMsg_ReleaseXID, OnReleaseXID)
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID)
#elif defined(OS_MACOSX)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
OnAcceleratedSurfaceSetIOSurface)
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
OnAcceleratedSurfaceBuffersSwapped)
#elif defined(OS_WIN)
IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetCompositorHostWindow,
OnGetCompositorHostWindow)
IPC_MESSAGE_HANDLER(GpuHostMsg_ScheduleComposite, OnScheduleComposite);
#endif #endif
IPC_MESSAGE_UNHANDLED_ERROR()
IPC_END_MESSAGE_MAP()
return true;
}
...@@ -77,12 +77,12 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender, ...@@ -77,12 +77,12 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
virtual ~GpuProcessHostUIShim(); virtual ~GpuProcessHostUIShim();
// Message handlers. // Message handlers.
void OnDestroyCommandBuffer(gfx::PluginWindowHandle window,
int32 renderer_id, int32 render_view_id);
void OnGraphicsInfoCollected(const GPUInfo& gpu_info); void OnGraphicsInfoCollected(const GPUInfo& gpu_info);
bool OnControlMessageReceived(const IPC::Message& message); bool OnControlMessageReceived(const IPC::Message& message);
#if defined(OS_LINUX) #if defined(OS_LINUX)
void OnGetViewXID(gfx::NativeViewId id, IPC::Message* reply_msg);
void OnReleaseXID(unsigned long xid);
void OnResizeXID(unsigned long xid, gfx::Size size, IPC::Message* reply_msg); void OnResizeXID(unsigned long xid, gfx::Size size, IPC::Message* reply_msg);
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
void OnAcceleratedSurfaceSetIOSurface( void OnAcceleratedSurfaceSetIOSurface(
...@@ -90,9 +90,6 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender, ...@@ -90,9 +90,6 @@ class GpuProcessHostUIShim : public IPC::Channel::Sender,
void OnAcceleratedSurfaceBuffersSwapped( void OnAcceleratedSurfaceBuffersSwapped(
const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params);
#elif defined(OS_WIN) #elif defined(OS_WIN)
void OnGetCompositorHostWindow(int renderer_id,
int render_view_id,
IPC::Message* reply_message);
void OnScheduleComposite(int32 renderer_id, int32 render_view_id); void OnScheduleComposite(int32 renderer_id, int32 render_view_id);
#endif #endif
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_file_util.h"
#include "chrome/common/extensions/extension_message_bundle.h" #include "chrome/common/extensions/extension_message_bundle.h"
#include "chrome/common/gpu_create_command_buffer_config.h"
#include "chrome/common/notification_service.h" #include "chrome/common/notification_service.h"
#include "chrome/common/render_messages.h" #include "chrome/common/render_messages.h"
#include "chrome/common/render_messages_params.h" #include "chrome/common/render_messages_params.h"
...@@ -397,6 +398,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message, ...@@ -397,6 +398,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message,
IPC_MESSAGE_HANDLER(ViewHostMsg_EstablishGpuChannel, OnEstablishGpuChannel) IPC_MESSAGE_HANDLER(ViewHostMsg_EstablishGpuChannel, OnEstablishGpuChannel)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SynchronizeGpu, IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_SynchronizeGpu,
OnSynchronizeGpu) OnSynchronizeGpu)
IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_CreateViewCommandBuffer,
OnCreateViewCommandBuffer)
IPC_MESSAGE_HANDLER(ViewHostMsg_AsyncOpenFile, OnAsyncOpenFile) IPC_MESSAGE_HANDLER(ViewHostMsg_AsyncOpenFile, OnAsyncOpenFile)
IPC_MESSAGE_UNHANDLED(handled = false) IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP_EX() IPC_END_MESSAGE_MAP_EX()
...@@ -1423,6 +1426,14 @@ void RenderMessageFilter::OnSynchronizeGpu(IPC::Message* reply) { ...@@ -1423,6 +1426,14 @@ void RenderMessageFilter::OnSynchronizeGpu(IPC::Message* reply) {
GpuProcessHost::Get()->Synchronize(reply, this); GpuProcessHost::Get()->Synchronize(reply, this);
} }
void RenderMessageFilter::OnCreateViewCommandBuffer(
int32 render_view_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply) {
GpuProcessHost::Get()->CreateViewCommandBuffer(
render_view_id, render_process_id_, init_params, reply, this);
}
void RenderMessageFilter::OnGetExtensionMessageBundle( void RenderMessageFilter::OnGetExtensionMessageBundle(
const std::string& extension_id, IPC::Message* reply_msg) { const std::string& extension_id, IPC::Message* reply_msg) {
ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>( ChromeURLRequestContext* context = static_cast<ChromeURLRequestContext*>(
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
class ChromeURLRequestContext; class ChromeURLRequestContext;
struct FontDescriptor; struct FontDescriptor;
struct GPUCreateCommandBufferConfig;
class HostContentSettingsMap; class HostContentSettingsMap;
class HostZoomMap; class HostZoomMap;
class NotificationsPrefsCache; class NotificationsPrefsCache;
...@@ -332,7 +333,10 @@ class RenderMessageFilter : public BrowserMessageFilter, ...@@ -332,7 +333,10 @@ class RenderMessageFilter : public BrowserMessageFilter,
IPC::Message* reply_msg); IPC::Message* reply_msg);
void OnEstablishGpuChannel(); void OnEstablishGpuChannel();
void OnSynchronizeGpu(IPC::Message* reply); void OnSynchronizeGpu(IPC::Message* reply);
void OnCreateViewCommandBuffer(
int32 render_view_id,
const GPUCreateCommandBufferConfig& init_params,
IPC::Message* reply);
void OnAsyncOpenFile(const IPC::Message& msg, void OnAsyncOpenFile(const IPC::Message& msg,
const FilePath& path, const FilePath& path,
int flags, int flags,
......
...@@ -54,6 +54,14 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, ...@@ -54,6 +54,14 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel,
// asynchronously.) Results in a GpuHostMsg_SynchronizeReply. // asynchronously.) Results in a GpuHostMsg_SynchronizeReply.
IPC_MESSAGE_CONTROL0(GpuMsg_Synchronize) IPC_MESSAGE_CONTROL0(GpuMsg_Synchronize)
// Tells the GPU process to create a new command buffer that renders directly
// to a native view. A corresponding GpuCommandBufferStub is created.
IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer,
gfx::PluginWindowHandle, /* view */
int32, /* render_view_id */
int32, /* renderer_id */
GPUCreateCommandBufferConfig /* init_params */)
// Tells the GPU process to create a context for collecting graphics card // Tells the GPU process to create a context for collecting graphics card
// information. // information.
IPC_MESSAGE_CONTROL1(GpuMsg_CollectGraphicsInfo, IPC_MESSAGE_CONTROL1(GpuMsg_CollectGraphicsInfo,
...@@ -92,29 +100,31 @@ IPC_MESSAGE_CONTROL2(GpuHostMsg_ChannelEstablished, ...@@ -92,29 +100,31 @@ IPC_MESSAGE_CONTROL2(GpuHostMsg_ChannelEstablished,
IPC::ChannelHandle, /* channel_handle */ IPC::ChannelHandle, /* channel_handle */
GPUInfo /* GPU logging stats */) GPUInfo /* GPU logging stats */)
// Response to a GpuMsg_Synchronize message. // Respond to a GpuMsg_CreateViewCommandBuffer message.
IPC_MESSAGE_CONTROL0(GpuHostMsg_SynchronizeReply) IPC_MESSAGE_CONTROL1(GpuHostMsg_CommandBufferCreated,
int32 /* route_id */)
// Free the browser resources associated with the command buffer
// (typically a window that was drawn into).
IPC_MESSAGE_CONTROL3(GpuHostMsg_DestroyCommandBuffer,
gfx::PluginWindowHandle, /* view */
int32, /* render_view_id */
int32 /* renderer_id */)
// Response to a GpuMsg_CollectGraphicsInfo. // Response to a GpuMsg_CollectGraphicsInfo.
IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected, IPC_MESSAGE_CONTROL1(GpuHostMsg_GraphicsInfoCollected,
GPUInfo /* GPU logging stats */) GPUInfo /* GPU logging stats */)
#if defined(OS_LINUX) // Response to a GpuMsg_Synchronize message.
// Get the XID for a view ID. IPC_MESSAGE_CONTROL0(GpuHostMsg_SynchronizeReply)
IPC_SYNC_MESSAGE_CONTROL1_1(GpuHostMsg_GetViewXID,
gfx::NativeViewId, /* view */
unsigned long /* xid */)
// Release the lock on the window.
// If the associated view has been destroyed, destroy the window.
IPC_MESSAGE_CONTROL1(GpuHostMsg_ReleaseXID,
unsigned long /* xid */)
#if defined(OS_LINUX)
// Resize the window that is being drawn into. It's important that this
// resize be synchronized with the swapping of the front and back buffers.
IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_ResizeXID, IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_ResizeXID,
unsigned long, /* xid */ unsigned long, /* xid */
gfx::Size, /* size */ gfx::Size, /* size */
bool /* success */) bool /* success */)
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
// This message, used on Mac OS X 10.6 and later (where IOSurface is // This message, used on Mac OS X 10.6 and later (where IOSurface is
// supported), is sent from the GPU process to the browser to indicate that a // supported), is sent from the GPU process to the browser to indicate that a
...@@ -130,12 +140,6 @@ IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceSetIOSurface, ...@@ -130,12 +140,6 @@ IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceSetIOSurface,
IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, IPC_MESSAGE_CONTROL1(GpuHostMsg_AcceleratedSurfaceBuffersSwapped,
GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params) GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params)
#elif defined(OS_WIN) #elif defined(OS_WIN)
// Get the HWND for the compositor window and if necessary, create it
IPC_SYNC_MESSAGE_CONTROL2_1(GpuHostMsg_GetCompositorHostWindow,
int32, /* renderer_id */
int32, /* render_view_id */
gfx::PluginWindowHandle /* compositor_host_id */)
IPC_MESSAGE_CONTROL2(GpuHostMsg_ScheduleComposite, IPC_MESSAGE_CONTROL2(GpuHostMsg_ScheduleComposite,
int32, /* renderer_id */ int32, /* renderer_id */
int32 /* render_view_id */) int32 /* render_view_id */)
...@@ -144,15 +148,6 @@ IPC_MESSAGE_CONTROL2(GpuHostMsg_ScheduleComposite, ...@@ -144,15 +148,6 @@ IPC_MESSAGE_CONTROL2(GpuHostMsg_ScheduleComposite,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// GPU Channel Messages // GPU Channel Messages
// These are messages from a renderer process to the GPU process. // These are messages from a renderer process to the GPU process.
// Tells the GPU process to create a new command buffer that renders directly
// to a native view. The |render_view_id| is currently needed only on Mac OS
// X in order to identify the window on the browser side into which the
// rendering results go. A corresponding GpuCommandBufferStub is created.
IPC_SYNC_MESSAGE_CONTROL3_1(GpuChannelMsg_CreateViewCommandBuffer,
gfx::NativeViewId, /* view */
int32, /* render_view_id */
GPUCreateCommandBufferConfig, /* init_params */
int32 /* route_id */)
// Tells the GPU process to create a new command buffer that renders to an // Tells the GPU process to create a new command buffer that renders to an
// offscreen frame buffer. If parent_route_id is not zero, the texture backing // offscreen frame buffer. If parent_route_id is not zero, the texture backing
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
typedef std::map<std::string, std::string> SubstitutionMap; typedef std::map<std::string, std::string> SubstitutionMap;
class Value; class Value;
struct GPUCreateCommandBufferConfig;
class GPUInfo; class GPUInfo;
class SkBitmap; class SkBitmap;
struct ThumbnailScore; struct ThumbnailScore;
...@@ -1544,6 +1545,13 @@ IPC_MESSAGE_CONTROL0(ViewHostMsg_EstablishGpuChannel) ...@@ -1544,6 +1545,13 @@ IPC_MESSAGE_CONTROL0(ViewHostMsg_EstablishGpuChannel)
// been established. // been established.
IPC_SYNC_MESSAGE_CONTROL0_0(ViewHostMsg_SynchronizeGpu) IPC_SYNC_MESSAGE_CONTROL0_0(ViewHostMsg_SynchronizeGpu)
// A renderer sends this to the browser process when it wants to
// create a GL context associated with the given view_id.
IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_CreateViewCommandBuffer,
int32, /* render_view_id */
GPUCreateCommandBufferConfig, /* init_params */
int32 /* route_id */)
// A renderer sends this to the browser process when it wants to start // A renderer sends this to the browser process when it wants to start
// a new instance of the Native Client process. The browser will launch // a new instance of the Native Client process. The browser will launch
// the process and return a handle to an IMC channel. // the process and return a handle to an IMC channel.
......
...@@ -71,6 +71,23 @@ bool GpuChannel::Send(IPC::Message* message) { ...@@ -71,6 +71,23 @@ bool GpuChannel::Send(IPC::Message* message) {
return channel_->Send(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) #if defined(OS_MACOSX)
void GpuChannel::AcceleratedSurfaceBuffersSwapped( void GpuChannel::AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count) { int32 route_id, uint64 swap_buffers_count) {
...@@ -97,8 +114,6 @@ bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) { ...@@ -97,8 +114,6 @@ bool GpuChannel::IsRenderViewGone(int32 renderer_route_id) {
bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) { bool GpuChannel::OnControlMessageReceived(const IPC::Message& msg) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg) IPC_BEGIN_MESSAGE_MAP(GpuChannel, msg)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateViewCommandBuffer,
OnCreateViewCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer, IPC_MESSAGE_HANDLER(GpuChannelMsg_CreateOffscreenCommandBuffer,
OnCreateOffscreenCommandBuffer) OnCreateOffscreenCommandBuffer)
IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer, IPC_MESSAGE_HANDLER(GpuChannelMsg_DestroyCommandBuffer,
...@@ -118,53 +133,6 @@ int GpuChannel::GenerateRouteID() { ...@@ -118,53 +133,6 @@ int GpuChannel::GenerateRouteID() {
return ++last_id; 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( void GpuChannel::OnCreateOffscreenCommandBuffer(
int32 parent_route_id, int32 parent_route_id,
const gfx::Size& size, const gfx::Size& size,
......
...@@ -59,6 +59,12 @@ class GpuChannel : public IPC::Channel::Listener, ...@@ -59,6 +59,12 @@ class GpuChannel : public IPC::Channel::Listener,
// IPC::Message::Sender implementation: // IPC::Message::Sender implementation:
virtual bool Send(IPC::Message* msg); 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) #if defined(OS_MACOSX)
virtual void AcceleratedSurfaceBuffersSwapped( virtual void AcceleratedSurfaceBuffersSwapped(
int32 route_id, uint64 swap_buffers_count); int32 route_id, uint64 swap_buffers_count);
...@@ -73,11 +79,6 @@ class GpuChannel : public IPC::Channel::Listener, ...@@ -73,11 +79,6 @@ class GpuChannel : public IPC::Channel::Listener,
int GenerateRouteID(); int GenerateRouteID();
// Message handlers. // Message handlers.
void OnCreateViewCommandBuffer(
gfx::NativeViewId view,
int32 render_view_id,
const GPUCreateCommandBufferConfig& init_params,
int32* route_id);
void OnCreateOffscreenCommandBuffer( void OnCreateOffscreenCommandBuffer(
int32 parent_route_id, int32 parent_route_id,
const gfx::Size& size, const gfx::Size& size,
......
...@@ -80,17 +80,7 @@ static LRESULT CALLBACK CompositorWindowProc( ...@@ -80,17 +80,7 @@ static LRESULT CALLBACK CompositorWindowProc(
bool GpuCommandBufferStub::CreateCompositorWindow() { bool GpuCommandBufferStub::CreateCompositorWindow() {
DCHECK(handle_ != gfx::kNullPluginWindow); DCHECK(handle_ != gfx::kNullPluginWindow);
HWND host_window = static_cast<HWND>(handle_);
// 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);
// Create the compositor window itself. // Create the compositor window itself.
DCHECK(host_window); DCHECK(host_window);
...@@ -163,11 +153,11 @@ GpuCommandBufferStub::~GpuCommandBufferStub() { ...@@ -163,11 +153,11 @@ GpuCommandBufferStub::~GpuCommandBufferStub() {
DestroyWindow(static_cast<HWND>(compositor_window_)); DestroyWindow(static_cast<HWND>(compositor_window_));
compositor_window_ = NULL; compositor_window_ = NULL;
} }
#elif defined(OS_LINUX)
GpuThread* gpu_thread = channel_->gpu_thread();
gpu_thread->Send(
new GpuHostMsg_ReleaseXID(handle_));
#endif // defined(OS_WIN) #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) { bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) {
......
...@@ -69,6 +69,8 @@ bool GpuThread::OnControlMessageReceived(const IPC::Message& msg) { ...@@ -69,6 +69,8 @@ bool GpuThread::OnControlMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize) IPC_MESSAGE_HANDLER(GpuMsg_Initialize, OnInitialize)
IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel)
IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel)
IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer,
OnCreateViewCommandBuffer);
IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize) IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize)
IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo) IPC_MESSAGE_HANDLER(GpuMsg_CollectGraphicsInfo, OnCollectGraphicsInfo)
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -215,10 +217,25 @@ void GpuThread::OnCollectGraphicsInfo(GPUInfo::Level level) { ...@@ -215,10 +217,25 @@ void GpuThread::OnCollectGraphicsInfo(GPUInfo::Level level) {
} }
} }
#endif #endif
Send(new GpuHostMsg_GraphicsInfoCollected(gpu_info_)); 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) #if defined(OS_MACOSX)
void GpuThread::OnAcceleratedSurfaceBuffersSwappedACK( void GpuThread::OnAcceleratedSurfaceBuffersSwappedACK(
int renderer_id, int32 route_id, uint64 swap_buffers_count) { int renderer_id, int32 route_id, uint64 swap_buffers_count) {
......
...@@ -51,6 +51,11 @@ class GpuThread : public ChildThread { ...@@ -51,6 +51,11 @@ class GpuThread : public ChildThread {
void OnCloseChannel(const IPC::ChannelHandle& channel_handle); void OnCloseChannel(const IPC::ChannelHandle& channel_handle);
void OnSynchronize(); void OnSynchronize();
void OnCollectGraphicsInfo(GPUInfo::Level level); 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) #if defined(OS_MACOSX)
void OnAcceleratedSurfaceBuffersSwappedACK( void OnAcceleratedSurfaceBuffersSwappedACK(
int renderer_id, int32 route_id, uint64 swap_buffers_count); int renderer_id, int32 route_id, uint64 swap_buffers_count);
......
...@@ -62,7 +62,7 @@ class Context : public base::SupportsWeakPtr<Context> { ...@@ -62,7 +62,7 @@ class Context : public base::SupportsWeakPtr<Context> {
// Initialize a GGL context that can be used in association with a a GPU // Initialize a GGL context that can be used in association with a a GPU
// channel acquired from a RenderWidget or RenderView. // channel acquired from a RenderWidget or RenderView.
bool Initialize(gfx::NativeViewId view, bool Initialize(bool onscreen,
int render_view_id, int render_view_id,
const gfx::Size& size, const gfx::Size& size,
const char* allowed_extensions, const char* allowed_extensions,
...@@ -156,7 +156,7 @@ Context::~Context() { ...@@ -156,7 +156,7 @@ Context::~Context() {
Destroy(); Destroy();
} }
bool Context::Initialize(gfx::NativeViewId view, bool Context::Initialize(bool onscreen,
int render_view_id, int render_view_id,
const gfx::Size& size, const gfx::Size& size,
const char* allowed_extensions, const char* allowed_extensions,
...@@ -207,9 +207,8 @@ bool Context::Initialize(gfx::NativeViewId view, ...@@ -207,9 +207,8 @@ bool Context::Initialize(gfx::NativeViewId view,
} }
// Create a proxy to a command buffer in the GPU process. // Create a proxy to a command buffer in the GPU process.
if (view) { if (onscreen) {
command_buffer_ = channel_->CreateViewCommandBuffer( command_buffer_ = channel_->CreateViewCommandBuffer(
view,
render_view_id, render_view_id,
allowed_extensions, allowed_extensions,
attribs); attribs);
...@@ -434,14 +433,13 @@ void Context::OnSwapBuffers() { ...@@ -434,14 +433,13 @@ void Context::OnSwapBuffers() {
#endif // ENABLE_GPU #endif // ENABLE_GPU
Context* CreateViewContext(GpuChannelHost* channel, Context* CreateViewContext(GpuChannelHost* channel,
gfx::NativeViewId view,
int render_view_id, int render_view_id,
const char* allowed_extensions, const char* allowed_extensions,
const int32* attrib_list) { const int32* attrib_list) {
#if defined(ENABLE_GPU) #if defined(ENABLE_GPU)
scoped_ptr<Context> context(new Context(channel, NULL)); scoped_ptr<Context> context(new Context(channel, NULL));
if (!context->Initialize( if (!context->Initialize(
view, render_view_id, gfx::Size(), allowed_extensions, attrib_list)) true, render_view_id, gfx::Size(), allowed_extensions, attrib_list))
return NULL; return NULL;
return context.release(); return context.release();
...@@ -465,7 +463,7 @@ Context* CreateOffscreenContext(GpuChannelHost* channel, ...@@ -465,7 +463,7 @@ Context* CreateOffscreenContext(GpuChannelHost* channel,
const int32* attrib_list) { const int32* attrib_list) {
#if defined(ENABLE_GPU) #if defined(ENABLE_GPU)
scoped_ptr<Context> context(new Context(channel, parent)); scoped_ptr<Context> context(new Context(channel, parent));
if (!context->Initialize(0, 0, size, allowed_extensions, attrib_list)) if (!context->Initialize(false, 0, size, allowed_extensions, attrib_list))
return NULL; return NULL;
return context.release(); return context.release();
......
...@@ -80,7 +80,6 @@ bool Terminate(); ...@@ -80,7 +80,6 @@ bool Terminate();
// TODO(kbr): clean up the arguments to this function and make them // TODO(kbr): clean up the arguments to this function and make them
// more cross-platform. // more cross-platform.
Context* CreateViewContext(GpuChannelHost* channel, Context* CreateViewContext(GpuChannelHost* channel,
gfx::NativeViewId view,
int render_view_id, int render_view_id,
const char* allowed_extensions, const char* allowed_extensions,
const int32* attrib_list); const int32* attrib_list);
......
...@@ -7,8 +7,10 @@ ...@@ -7,8 +7,10 @@
#include "chrome/common/child_process.h" #include "chrome/common/child_process.h"
#include "chrome/common/gpu_create_command_buffer_config.h" #include "chrome/common/gpu_create_command_buffer_config.h"
#include "chrome/common/gpu_messages.h" #include "chrome/common/gpu_messages.h"
#include "chrome/common/render_messages.h"
#include "chrome/renderer/command_buffer_proxy.h" #include "chrome/renderer/command_buffer_proxy.h"
#include "chrome/renderer/gpu_video_service_host.h" #include "chrome/renderer/gpu_video_service_host.h"
#include "chrome/renderer/render_thread.h"
GpuChannelHost::GpuChannelHost() : state_(kUnconnected) { GpuChannelHost::GpuChannelHost() : state_(kUnconnected) {
} }
...@@ -90,7 +92,6 @@ bool GpuChannelHost::Send(IPC::Message* message) { ...@@ -90,7 +92,6 @@ bool GpuChannelHost::Send(IPC::Message* message) {
} }
CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer(
gfx::NativeViewId view,
int render_view_id, int render_view_id,
const std::string& allowed_extensions, const std::string& allowed_extensions,
const std::vector<int32>& attribs) { const std::vector<int32>& attribs) {
...@@ -101,10 +102,8 @@ CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer( ...@@ -101,10 +102,8 @@ CommandBufferProxy* GpuChannelHost::CreateViewCommandBuffer(
GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs); GPUCreateCommandBufferConfig init_params(allowed_extensions, attribs);
int32 route_id; int32 route_id;
if (!Send(new GpuChannelMsg_CreateViewCommandBuffer(view, if (!RenderThread::current()->Send(new ViewHostMsg_CreateViewCommandBuffer(
render_view_id, render_view_id, init_params, &route_id))) {
init_params,
&route_id))) {
return NULL; return NULL;
} }
......
...@@ -65,7 +65,6 @@ class GpuChannelHost : public IPC::Channel::Listener, ...@@ -65,7 +65,6 @@ class GpuChannelHost : public IPC::Channel::Listener,
// Create and connect to a command buffer in the GPU process. // Create and connect to a command buffer in the GPU process.
CommandBufferProxy* CreateViewCommandBuffer( CommandBufferProxy* CreateViewCommandBuffer(
gfx::NativeViewId view,
int render_view_id, int render_view_id,
const std::string& allowed_extensions, const std::string& allowed_extensions,
const std::vector<int32>& attribs); const std::vector<int32>& attribs);
......
...@@ -162,9 +162,6 @@ RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper( ...@@ -162,9 +162,6 @@ RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper(
webkit::ppapi::PluginInstance* plugin) webkit::ppapi::PluginInstance* plugin)
: RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect), : RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect),
plugin_(plugin), plugin_(plugin),
#if defined(OS_MACOSX)
plugin_handle_(NULL),
#endif
context_(NULL), context_(NULL),
buffer_(0), buffer_(0),
program_(0) { program_(0) {
...@@ -267,16 +264,6 @@ void RenderWidgetFullscreenPepper::CreateContext() { ...@@ -267,16 +264,6 @@ void RenderWidgetFullscreenPepper::CreateContext() {
GpuChannelHost* host = render_thread->EstablishGpuChannelSync(); GpuChannelHost* host = render_thread->EstablishGpuChannelSync();
if (!host) if (!host)
return; return;
gfx::NativeViewId view_id;
#if !defined(OS_MACOSX)
view_id = host_window();
#else
Send(new ViewHostMsg_AllocateFakePluginWindowHandle(
routing_id(), true, true, &plugin_handle_));
if (!plugin_handle_)
return;
view_id = static_cast<gfx::NativeViewId>(plugin_handle_);
#endif
const int32 attribs[] = { const int32 attribs[] = {
ggl::GGL_ALPHA_SIZE, 8, ggl::GGL_ALPHA_SIZE, 8,
ggl::GGL_DEPTH_SIZE, 0, ggl::GGL_DEPTH_SIZE, 0,
...@@ -287,7 +274,6 @@ void RenderWidgetFullscreenPepper::CreateContext() { ...@@ -287,7 +274,6 @@ void RenderWidgetFullscreenPepper::CreateContext() {
}; };
context_ = ggl::CreateViewContext( context_ = ggl::CreateViewContext(
host, host,
view_id,
routing_id(), routing_id(),
"GL_OES_packed_depth_stencil GL_OES_depth24", "GL_OES_packed_depth_stencil GL_OES_depth24",
attribs); attribs);
...@@ -314,13 +300,6 @@ void RenderWidgetFullscreenPepper::DestroyContext() { ...@@ -314,13 +300,6 @@ void RenderWidgetFullscreenPepper::DestroyContext() {
ggl::DestroyContext(context_); ggl::DestroyContext(context_);
context_ = NULL; context_ = NULL;
} }
#if defined(OS_MACOSX)
if (plugin_handle_) {
Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(),
plugin_handle_));
plugin_handle_ = NULL;
}
#endif
} }
namespace { namespace {
......
...@@ -78,9 +78,6 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen, ...@@ -78,9 +78,6 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen,
// The plugin instance this widget wraps. // The plugin instance this widget wraps.
webkit::ppapi::PluginInstance* plugin_; webkit::ppapi::PluginInstance* plugin_;
#if defined(OS_MACOSX)
gfx::PluginWindowHandle plugin_handle_;
#endif
// GL context for compositing. // GL context for compositing.
ggl::Context* context_; ggl::Context* context_;
unsigned int buffer_; unsigned int buffer_;
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
: context_(NULL), : context_(NULL),
web_view_(NULL), web_view_(NULL),
#if defined(OS_MACOSX)
plugin_handle_(NULL),
#endif // defined(OS_MACOSX)
cached_width_(0), cached_width_(0),
cached_height_(0), cached_height_(0),
bound_fbo_(0) { bound_fbo_(0) {
...@@ -37,19 +34,6 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl() ...@@ -37,19 +34,6 @@ WebGraphicsContext3DCommandBufferImpl::WebGraphicsContext3DCommandBufferImpl()
WebGraphicsContext3DCommandBufferImpl:: WebGraphicsContext3DCommandBufferImpl::
~WebGraphicsContext3DCommandBufferImpl() { ~WebGraphicsContext3DCommandBufferImpl() {
#if defined(OS_MACOSX)
if (web_view_) {
DCHECK(plugin_handle_ != gfx::kNullPluginWindow);
RenderView* renderview = RenderView::FromWebView(web_view_);
// The RenderView might already have been freed, but in its
// destructor it destroys all fake plugin window handles it
// allocated.
if (renderview) {
renderview->DestroyFakePluginWindowHandle(plugin_handle_);
}
plugin_handle_ = gfx::kNullPluginWindow;
}
#endif
if (context_) { if (context_) {
ggl::DestroyContext(context_); ggl::DestroyContext(context_);
} }
...@@ -101,18 +85,10 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize( ...@@ -101,18 +85,10 @@ bool WebGraphicsContext3DCommandBufferImpl::initialize(
RenderView* renderview = RenderView::FromWebView(web_view); RenderView* renderview = RenderView::FromWebView(web_view);
if (!renderview) if (!renderview)
return false; return false;
gfx::NativeViewId view_id;
#if !defined(OS_MACOSX)
view_id = renderview->host_window();
#else
plugin_handle_ = renderview->AllocateFakePluginWindowHandle(
/*opaque=*/true, /*root=*/true);
view_id = static_cast<gfx::NativeViewId>(plugin_handle_);
#endif
web_view_ = web_view; web_view_ = web_view;
context_ = ggl::CreateViewContext( context_ = ggl::CreateViewContext(
host, host,
view_id,
renderview->routing_id(), renderview->routing_id(),
kWebGraphicsContext3DPerferredGLExtensions, kWebGraphicsContext3DPerferredGLExtensions,
attribs); attribs);
......
...@@ -387,10 +387,6 @@ class WebGraphicsContext3DCommandBufferImpl ...@@ -387,10 +387,6 @@ class WebGraphicsContext3DCommandBufferImpl
ggl::Context* context_; ggl::Context* context_;
// If rendering directly to WebView, weak pointer to it. // If rendering directly to WebView, weak pointer to it.
WebKit::WebView* web_view_; WebKit::WebView* web_view_;
#if defined(OS_MACOSX)
// "Fake" plugin window handle in browser process for the compositor's output.
gfx::PluginWindowHandle plugin_handle_;
#endif
WebKit::WebGraphicsContext3D::Attributes attributes_; WebKit::WebGraphicsContext3D::Attributes attributes_;
int cached_width_, cached_height_; int cached_width_, cached_height_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment