b=763449 Finish X requests on mROFrontBuffer before deleting shadow layer r=cjones
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 25 Sep 2012 16:20:41 +1200
changeset 108062 ef440fbe0d521b96cdc6e34540381a7eb1fa1aa3
parent 108061 2f9d00b31660f9e972abc0018ff6edb2a4aeb110
child 108063 4a255d82170729d86e01be6c02ef5ac25795e738
push id15355
push userktomlinson@mozilla.com
push dateTue, 25 Sep 2012 21:57:00 +0000
treeherdermozilla-inbound@ef440fbe0d52 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs763449
milestone18.0a1
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
b=763449 Finish X requests on mROFrontBuffer before deleting shadow layer r=cjones
gfx/layers/basic/BasicThebesLayer.cpp
gfx/layers/basic/BasicThebesLayer.h
gfx/layers/ipc/ShadowLayerUtilsX11.cpp
gfx/layers/ipc/ShadowLayers.h
--- a/gfx/layers/basic/BasicThebesLayer.cpp
+++ b/gfx/layers/basic/BasicThebesLayer.cpp
@@ -276,16 +276,27 @@ struct NS_STACK_CLASS AutoBufferTracker 
   nsAutoTArray<Maybe<AutoOpenSurface>, 3> mNewBuffers;
   BasicShadowableThebesLayer* mLayer;
 
 private:
   AutoBufferTracker(const AutoBufferTracker&) MOZ_DELETE;
   AutoBufferTracker& operator=(const AutoBufferTracker&) MOZ_DELETE;
 };
 
+BasicShadowableThebesLayer::~BasicShadowableThebesLayer()
+{
+  // Finish any use of mROFrontBuffer since the last ForwardTransaction(),
+  // before the Shadow frees the surface.
+  if (OptionalThebesBuffer::Tnull_t != mROFrontBuffer.type()) {
+    ShadowLayerForwarder::PlatformSyncBeforeUpdate();
+  }
+  DestroyBackBuffer();
+  MOZ_COUNT_DTOR(BasicShadowableThebesLayer);
+}
+
 void
 BasicShadowableThebesLayer::PaintThebes(gfxContext* aContext,
                                         Layer* aMaskLayer,
                                         LayerManager::DrawThebesLayerCallback aCallback,
                                         void* aCallbackData,
                                         ReadbackProcessor* aReadback)
 {
   if (!HasShadow()) {
--- a/gfx/layers/basic/BasicThebesLayer.h
+++ b/gfx/layers/basic/BasicThebesLayer.h
@@ -116,21 +116,17 @@ public:
   BasicShadowableThebesLayer(BasicShadowLayerManager* aManager)
     : BasicThebesLayer(aManager)
     , mBufferTracker(nullptr)
     , mIsNewBuffer(false)
     , mFrontAndBackBufferDiffer(false)
   {
     MOZ_COUNT_CTOR(BasicShadowableThebesLayer);
   }
-  virtual ~BasicShadowableThebesLayer()
-  {
-    DestroyBackBuffer();
-    MOZ_COUNT_DTOR(BasicShadowableThebesLayer);
-  }
+  virtual ~BasicShadowableThebesLayer();
 
   virtual void PaintThebes(gfxContext* aContext,
                            Layer* aMaskLayer,
                            LayerManager::DrawThebesLayerCallback aCallback,
                            void* aCallbackData,
                            ReadbackProcessor* aReadback);
 
   virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
--- a/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
+++ b/gfx/layers/ipc/ShadowLayerUtilsX11.cpp
@@ -172,17 +172,17 @@ ShadowLayerForwarder::PlatformDestroySha
 /*static*/ void
 ShadowLayerForwarder::PlatformSyncBeforeUpdate()
 {
   if (UsingXCompositing()) {
     // If we're using X surfaces, then we need to finish all pending
     // operations on the back buffers before handing them to the
     // parent, otherwise the surface might be used by the parent's
     // Display in between two operations queued by our Display.
-    XSync(DefaultXDisplay(), False);
+    FinishX(DefaultXDisplay());
   }
 }
 
 /*static*/ void
 ShadowLayerManager::PlatformSyncBeforeReplyUpdate()
 {
   if (UsingXCompositing()) {
     // If we're using X surfaces, we need to finish all pending
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -314,16 +314,18 @@ public:
   /**
    * Flag the next paint as the first for a document.
    */
   void SetIsFirstPaint() { mIsFirstPaint = true; }
 
   virtual int32_t GetMaxTextureSize() const { return mMaxTextureSize; }
   void SetMaxTextureSize(int32_t aMaxTextureSize) { mMaxTextureSize = aMaxTextureSize; }
 
+  static void PlatformSyncBeforeUpdate();
+
 protected:
   ShadowLayerForwarder();
 
   PLayersChild* mShadowManager;
 
 private:
   bool AllocBuffer(const gfxIntSize& aSize,
                    gfxASurface::gfxContentType aContent,
@@ -374,18 +376,16 @@ private:
   static void
   CloseDescriptor(const SurfaceDescriptor& aDescriptor);
 
   static bool
   PlatformCloseDescriptor(const SurfaceDescriptor& aDescriptor);
 
   bool PlatformDestroySharedSurface(SurfaceDescriptor* aSurface);
 
-  static void PlatformSyncBeforeUpdate();
-
   Transaction* mTxn;
   int32_t mMaxTextureSize;
   LayersBackend mParentBackend;
 
   bool mIsFirstPaint;
 };
 
 class ShadowLayerManager : public LayerManager