| Index: chrome/browser/gpu_process_host_ui_shim.cc
|
| diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc
|
| index 87c7be28ff005ea202985f4e6d6d6030058fc2a3..5419a44a1de77def85b579fc7379d4064072e446 100644
|
| --- a/chrome/browser/gpu_process_host_ui_shim.cc
|
| +++ b/chrome/browser/gpu_process_host_ui_shim.cc
|
| @@ -7,9 +7,19 @@
|
| #include "chrome/browser/browser_thread.h"
|
| #include "chrome/browser/gpu_process_host.h"
|
| #include "chrome/browser/renderer_host/render_view_host.h"
|
| +#include "chrome/browser/renderer_host/render_widget_host_view.h"
|
| #include "chrome/common/child_process_logging.h"
|
| #include "chrome/common/gpu_messages.h"
|
|
|
| +#if defined(OS_LINUX)
|
| +// These two #includes need to come after gpu_messages.h.
|
| +#include <gdk/gdkwindow.h> // NOLINT
|
| +#include <gdk/gdkx.h> // NOLINT
|
| +#include "ui/base/x/x11_util.h"
|
| +#include "gfx/gtk_native_view_id_manager.h"
|
| +#include "gfx/size.h"
|
| +#endif // defined(OS_LINUX)
|
| +
|
| // Tasks used by this file
|
| namespace {
|
|
|
| @@ -110,6 +120,109 @@ void GpuProcessHostUIShim::OnGraphicsInfoCollected(const GPUInfo& gpu_info) {
|
| gpu_info_collected_callback_->Run();
|
| }
|
|
|
| +namespace {
|
| +
|
| +void SendDelayedReply(IPC::Message* reply_msg) {
|
| + BrowserThread::PostTask(
|
| + BrowserThread::IO,
|
| + FROM_HERE,
|
| + new SendOnIOThreadTask(reply_msg));
|
| +}
|
| +
|
| +} // namespace
|
| +
|
| +#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,
|
| + IPC::Message *reply_msg) {
|
| + GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid));
|
| + if (window) {
|
| + Display* display = GDK_WINDOW_XDISPLAY(window);
|
| + gdk_window_resize(window, size.width(), size.height());
|
| + XSync(display, False);
|
| + }
|
| +
|
| + GpuHostMsg_ResizeXID::WriteReplyParams(reply_msg, (window != NULL));
|
| + SendDelayedReply(reply_msg);
|
| +}
|
| +
|
| +#elif defined(OS_MACOSX)
|
| +
|
| +void GpuProcessHostUIShim::OnAcceleratedSurfaceSetIOSurface(
|
| + const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) {
|
| + RenderViewHost* host = RenderViewHost::FromID(params.renderer_id,
|
| + params.render_view_id);
|
| + if (!host)
|
| + return;
|
| + RenderWidgetHostView* view = host->view();
|
| + if (!view)
|
| + return;
|
| + view->AcceleratedSurfaceSetIOSurface(params.window,
|
| + params.width,
|
| + params.height,
|
| + params.identifier);
|
| +}
|
| +
|
| +void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped(
|
| + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) {
|
| + RenderViewHost* host = RenderViewHost::FromID(params.renderer_id,
|
| + params.render_view_id);
|
| + if (!host)
|
| + return;
|
| + RenderWidgetHostView* view = host->view();
|
| + if (!view)
|
| + return;
|
| + view->AcceleratedSurfaceBuffersSwapped(
|
| + // Parameters needed to swap the IOSurface.
|
| + params.window,
|
| + params.surface_id,
|
| + // Parameters needed to formulate an acknowledgment.
|
| + params.renderer_id,
|
| + params.route_id,
|
| + params.swap_buffers_count);
|
| +}
|
| +
|
| +#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,
|
| int render_view_id) {
|
| RenderViewHost* host = RenderViewHost::FromID(renderer_id,
|
| @@ -119,6 +232,7 @@ void GpuProcessHostUIShim::OnScheduleComposite(int renderer_id,
|
| }
|
| host->ScheduleComposite();
|
| }
|
| +#endif
|
|
|
| bool GpuProcessHostUIShim::OnControlMessageReceived(
|
| const IPC::Message& message) {
|
| @@ -127,7 +241,18 @@ bool GpuProcessHostUIShim::OnControlMessageReceived(
|
| IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message)
|
| IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected,
|
| OnGraphicsInfoCollected)
|
| -#if defined(OS_WIN)
|
| +#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
|
| IPC_MESSAGE_UNHANDLED_ERROR()
|
|
|