From 317ba3c7bb05878d7096524b565072d58f38a5e3 Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Tue, 10 Jan 2012 23:54:35 +1300 Subject: [PATCH] b=682625 share code for layers::SurfaceDescriptorX11 with plugins r=cjones --HG-- extra : transplant_source : %82%82%9C-s%8A%E2J%DC%7E%0A%DF%FDyO%FB0q%3C%23 --- dom/plugins/ipc/PPluginInstance.ipdl | 7 +------ dom/plugins/ipc/PluginInstanceChild.cpp | 9 +-------- dom/plugins/ipc/PluginInstanceParent.cpp | 9 +-------- dom/plugins/ipc/PluginMessageUtils.h | 3 +++ 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/dom/plugins/ipc/PPluginInstance.ipdl b/dom/plugins/ipc/PPluginInstance.ipdl index 933ea9419e5..63597538168 100644 --- a/dom/plugins/ipc/PPluginInstance.ipdl +++ b/dom/plugins/ipc/PPluginInstance.ipdl @@ -59,6 +59,7 @@ using mozilla::gfxSurfaceType; using gfxIntSize; using mozilla::null_t; using mozilla::plugins::WindowsSharedMemoryHandle; +using SurfaceDescriptorX11; using nsIntRect; using nsTextEvent; using nsKeyEvent; @@ -66,12 +67,6 @@ using nsKeyEvent; namespace mozilla { namespace plugins { -struct SurfaceDescriptorX11 { - int XID; - int xrenderPictID; - gfxIntSize size; -}; - struct IOSurfaceDescriptor { uint32_t surfaceId; }; diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 479ffd3b760..2ab5c318ab7 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -3446,14 +3446,7 @@ PluginInstanceChild::RecvUpdateBackground(const SurfaceDescriptor& aBackground, switch (aBackground.type()) { #ifdef MOZ_X11 case SurfaceDescriptor::TSurfaceDescriptorX11: { - SurfaceDescriptorX11 xdesc = aBackground.get_SurfaceDescriptorX11(); - XRenderPictFormat pf; - pf.id = xdesc.xrenderPictID(); - XRenderPictFormat *incFormat = - XRenderFindFormat(DefaultXDisplay(), PictFormatID, &pf, 0); - mBackground = - new gfxXlibSurface(DefaultScreenOfDisplay(DefaultXDisplay()), - xdesc.XID(), incFormat, xdesc.size()); + mBackground = aBackground.get_SurfaceDescriptorX11().OpenForeign(); break; } #endif diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 2dafaa2ed42..d109dc22dec 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -535,14 +535,7 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect, #endif #ifdef MOZ_X11 else if (newSurface.type() == SurfaceDescriptor::TSurfaceDescriptorX11) { - SurfaceDescriptorX11 xdesc = newSurface.get_SurfaceDescriptorX11(); - XRenderPictFormat pf; - pf.id = xdesc.xrenderPictID(); - XRenderPictFormat *incFormat = - XRenderFindFormat(DefaultXDisplay(), PictFormatID, &pf, 0); - surface = - new gfxXlibSurface(DefaultScreenOfDisplay(DefaultXDisplay()), - xdesc.XID(), incFormat, xdesc.size()); + surface = newSurface.get_SurfaceDescriptorX11().OpenForeign(); } #endif #ifdef XP_WIN diff --git a/dom/plugins/ipc/PluginMessageUtils.h b/dom/plugins/ipc/PluginMessageUtils.h index 1d33ec9904e..b48ffb74e22 100644 --- a/dom/plugins/ipc/PluginMessageUtils.h +++ b/dom/plugins/ipc/PluginMessageUtils.h @@ -43,6 +43,7 @@ #include "base/message_loop.h" #include "mozilla/ipc/RPCChannel.h" +#include "gfxipc/ShadowLayerUtils.h" #include "npapi.h" #include "npruntime.h" @@ -66,6 +67,8 @@ using mac_plugin_interposing::NSCursorInfo; namespace mozilla { namespace plugins { +using layers::SurfaceDescriptorX11; + enum ScriptableObjectType { LocalObject,