b=682625 share code for layers::SurfaceDescriptorX11 with plugins r=cjones
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 10 Jan 2012 23:54:35 +1300
changeset 85452 e2d3f721ffc900e88dff591fdadfeb380dea6c44
parent 85451 c5aecfec255a2fe3fcb47def49e5c6178575356a
child 85453 04dd5995b0861582ec32d947ff3615d9f277b8fe
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs682625
milestone12.0a1
b=682625 share code for layers::SurfaceDescriptorX11 with plugins r=cjones
dom/plugins/ipc/PPluginInstance.ipdl
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginMessageUtils.h
--- a/dom/plugins/ipc/PPluginInstance.ipdl
+++ b/dom/plugins/ipc/PPluginInstance.ipdl
@@ -54,29 +54,24 @@ using NPRemoteEvent;
 using NPRect;
 using NPNURLVariable;
 using NPCoordinateSpace;
 using mozilla::plugins::NativeWindowHandle;
 using mozilla::gfxSurfaceType;
 using gfxIntSize;
 using mozilla::null_t;
 using mozilla::plugins::WindowsSharedMemoryHandle;
+using SurfaceDescriptorX11;
 using nsIntRect;
 using nsTextEvent;
 using nsKeyEvent;
 
 namespace mozilla {
 namespace plugins {
 
-struct SurfaceDescriptorX11 {
-  int XID;
-  int xrenderPictID;
-  gfxIntSize size;
-};
-
 struct IOSurfaceDescriptor {
   uint32_t surfaceId;
 };
 
 union SurfaceDescriptor {
   Shmem;
   SurfaceDescriptorX11;
   PPluginSurface; // used on Windows
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -3441,24 +3441,17 @@ PluginInstanceChild::RecvUpdateBackgroun
 {
     NS_ABORT_IF_FALSE(mIsTransparent, "Only transparent plugins use backgrounds");
 
     if (!mBackground) {
         // XXX refactor me
         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
         case SurfaceDescriptor::TShmem: {
             mBackground = gfxSharedImageSurface::Open(aBackground.get_Shmem());
             break;
         }
         default:
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -530,24 +530,17 @@ PluginInstanceParent::RecvShow(const NPR
         PLUGIN_LOG_DEBUG(("   (RecvShow invalidated for surface %p)",
                           mFrontSurface.get()));
 
         return true;
     }
 #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
     else if (newSurface.type() == SurfaceDescriptor::TPPluginSurfaceParent) {
         PluginSurfaceParent* s =
             static_cast<PluginSurfaceParent*>(newSurface.get_PPluginSurfaceParent());
         surface = s->Surface();
     }
--- a/dom/plugins/ipc/PluginMessageUtils.h
+++ b/dom/plugins/ipc/PluginMessageUtils.h
@@ -38,16 +38,17 @@
 
 #ifndef DOM_PLUGINS_PLUGINMESSAGEUTILS_H
 #define DOM_PLUGINS_PLUGINMESSAGEUTILS_H
 
 #include "IPC/IPCMessageUtils.h"
 #include "base/message_loop.h"
 
 #include "mozilla/ipc/RPCChannel.h"
+#include "gfxipc/ShadowLayerUtils.h"
 
 #include "npapi.h"
 #include "npruntime.h"
 #include "npfunctions.h"
 #include "nsAutoPtr.h"
 #include "nsStringGlue.h"
 #include "nsTArray.h"
 #include "nsThreadUtils.h"
@@ -61,16 +62,18 @@
 #else
 namespace mac_plugin_interposing { class NSCursorInfo { }; }
 #endif
 using mac_plugin_interposing::NSCursorInfo;
 
 namespace mozilla {
 namespace plugins {
 
+using layers::SurfaceDescriptorX11;
+
 enum ScriptableObjectType
 {
   LocalObject,
   Proxy
 };
 
 mozilla::ipc::RPCChannel::RacyRPCPolicy
 MediateRace(const mozilla::ipc::RPCChannel::Message& parent,