Bug 596451 part C - simplify the behavior of the returning surface from Show, because it's only used to hand back ownership of IPDL shared memory.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Thu, 14 Oct 2010 14:14:23 -0400
changeset 57206 f409549bea96b3c19bd55d28f16479cfddb13431
parent 57205 6435ea1c2fbaca0806f06b6ee6957ce2519108c3
child 57207 f7b85d9a0900caf0983551fb0ff0a579c212524e
push id16846
push userbsmedberg@mozilla.com
push dateWed, 10 Nov 2010 15:29:47 +0000
treeherdermozilla-central@bdbef533364f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs596451
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 596451 part C - simplify the behavior of the returning surface from Show, because it's only used to hand back ownership of IPDL shared memory.
dom/plugins/PPluginInstance.ipdl
dom/plugins/PluginInstanceChild.cpp
dom/plugins/PluginInstanceParent.cpp
--- a/dom/plugins/PPluginInstance.ipdl
+++ b/dom/plugins/PPluginInstance.ipdl
@@ -164,22 +164,24 @@ parent:
    */
   rpc PStreamNotify(nsCString url, nsCString target, bool post,
                     nsCString buffer, bool file)
     returns (NPError result);
 
   async NPN_InvalidateRect(NPRect rect);
 
   // Give |newSurface|, containing this instance's updated pixels, to
-  // the browser for compositing.  Get back |prevSurface|, containing
-  // old pixels, to be recycled
+  // the browser for compositing.  When this method returns, any surface 
+  // previously passed to Show may be destroyed.
+  //
   // @param rect - actually updated rectangle, comparing to prevSurface content
   //               could be used for partial render of layer to topLevel context
   // @param newSurface - remotable surface
-  // @param prevSurface - return surface for recycling
+  // @param prevSurface - if the previous surface was shared-memory, returns
+  //                      the shmem for reuse
   sync Show(NPRect updatedRect, SurfaceDescriptor newSurface)
     returns (SurfaceDescriptor prevSurface);
 
   rpc NPN_PushPopupsEnabledState(bool aState);
 
   rpc NPN_PopPopupsEnabledState();
 
   rpc NPN_GetValueForURL(NPNURLVariable variable, nsCString url)
--- a/dom/plugins/PluginInstanceChild.cpp
+++ b/dom/plugins/PluginInstanceChild.cpp
@@ -2478,34 +2478,37 @@ PluginInstanceChild::ShowPluginFrame()
     if (mDoAlphaExtraction) {
         PaintRectWithAlphaExtraction(rect, mCurrentSurface);
     } else {
         PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0));
     }
 
     NPRect r = { rect.y, rect.x, rect.YMost(), rect.XMost() };
     SurfaceDescriptor currSurf;
-    SurfaceDescriptor outSurf = null_t();
 #ifdef MOZ_X11
     if (mCurrentSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
         gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(mCurrentSurface.get());
         currSurf = SurfaceDescriptorX11(xsurf->XDrawable(), xsurf->XRenderFormat()->id,
                                         mCurrentSurface->GetSize());
         // Need to sync all pending x-paint requests
         // before giving drawable to another process
         XSync(mWsInfo.display, False);
     } else
 #endif
     if (gfxSharedImageSurface::IsSharedImage(mCurrentSurface)) {
         currSurf = static_cast<gfxSharedImageSurface*>(mCurrentSurface.get())->GetShmem();
     } else {
         NS_RUNTIMEABORT("Surface type is not remotable");
         return false;
     }
-    if (!SendShow(r, currSurf, &outSurf)) {
+
+    // Unused, except to possibly return a shmem to us
+    SurfaceDescriptor returnSurf;
+
+    if (!SendShow(r, currSurf, &returnSurf)) {
         return false;
     }
 
     nsRefPtr<gfxASurface> tmp = mCurrentSurface;
     mCurrentSurface = mBackSurface;
     mBackSurface = tmp;
     // Outdated back surface... not usable anymore due to changed plugin size.
     // Dropping obsolete surface
--- a/dom/plugins/PluginInstanceParent.cpp
+++ b/dom/plugins/PluginInstanceParent.cpp
@@ -493,41 +493,24 @@ PluginInstanceParent::RecvShow(const NPR
             XRenderFindFormat(DefaultXDisplay(), PictFormatID, &pf, 0);
         surface =
             new gfxXlibSurface(DefaultScreenOfDisplay(DefaultXDisplay()),
                                xdesc.XID(), incFormat, xdesc.size());
     }
 #endif
 
     mSentPaintNotification = PR_FALSE;
-    if (mFrontSurface) {
-#ifdef MOZ_X11
-        if (mFrontSurface->GetType() == gfxASurface::SurfaceTypeXlib) {
-            gfxXlibSurface *xsurf = static_cast<gfxXlibSurface*>(mFrontSurface.get());
-            *prevSurface =
-                SurfaceDescriptorX11(xsurf->XDrawable(), xsurf->XRenderFormat()->id,
-                                    mFrontSurface->GetSize());
-        } else
-#endif
-        if (gfxSharedImageSurface::IsSharedImage(mFrontSurface)) {
-            *prevSurface = static_cast<gfxSharedImageSurface*>(mFrontSurface.get())->GetShmem();
-        } else {
-            *prevSurface = null_t();
-        }
-    } else {
+
+    if (mFrontSurface && gfxSharedImageSurface::IsSharedImage(mFrontSurface))
+        *prevSurface = static_cast<gfxSharedImageSurface*>(mFrontSurface.get())->GetShmem();
+    else
         *prevSurface = null_t();
-    }
+
     mFrontSurface = surface;
     RecvNPN_InvalidateRect(updatedRect);
-#ifdef MOZ_X11
-    // Sync prevSurface before sending to child
-    if (prevSurface->type() == SurfaceDescriptor::TSurfaceDescriptorX11) {
-        XSync(DefaultXDisplay(), False);
-    }
-#endif
 
     return true;
 }
 
 nsresult
 PluginInstanceParent::AsyncSetWindow(NPWindow* aWindow)
 {
     NPRemoteWindow window;