bug 1268638 - Cleanup better in failure cases. - r=jrmuizel
authorJeff Gilbert <jgilbert@mozilla.com>
Thu, 23 Jun 2016 09:42:23 -0700
changeset 303422 f33f67f36e69ea258c21173bc4aa1dd0d3152894
parent 303421 c9902da7753d7dd999f1de3d7eebb8b75ba0beb5
child 303423 639184c289f5a56a94c3b1299b566ebcb5340c63
push id79077
push userjgilbert@mozilla.com
push dateFri, 01 Jul 2016 20:16:16 +0000
treeherdermozilla-inbound@f33f67f36e69 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1268638
milestone50.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
bug 1268638 - Cleanup better in failure cases. - r=jrmuizel MozReview-Commit-ID: 661wHH47xr6
gfx/gl/GLScreenBuffer.cpp
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -470,18 +470,20 @@ GLScreenBuffer::Morph(UniquePtr<SurfaceF
     mFactory = Move(newFactory);
 }
 
 bool
 GLScreenBuffer::Attach(SharedSurface* surf, const gfx::IntSize& size)
 {
     ScopedBindFramebuffer autoFB(mGL);
 
-    if (mRead && SharedSurf())
+    const bool readNeedsUnlock = (mRead && SharedSurf());
+    if (readNeedsUnlock) {
         SharedSurf()->UnlockProd();
+    }
 
     surf->LockProd();
 
     if (mRead &&
         surf->mAttachType == SharedSurf()->mAttachType &&
         size == Size())
     {
         // Same size, same type, ready for reuse!
@@ -502,17 +504,19 @@ GLScreenBuffer::Attach(SharedSurface* su
         if (!mDraw || size != Size())
             drawOk = CreateDraw(size, &draw);  // Can be null.
 
         UniquePtr<ReadBuffer> read = CreateRead(surf);
         bool readOk = !!read;
 
         if (!drawOk || !readOk) {
             surf->UnlockProd();
-
+            if (readNeedsUnlock) {
+                SharedSurf()->LockProd();
+            }
             return false;
         }
 
         if (draw)
             mDraw = Move(draw);
 
         mRead = Move(read);
     }
@@ -545,18 +549,20 @@ GLScreenBuffer::Swap(const gfx::IntSize&
         return false;
 
     // In the case of DXGL interop, the new surface needs to be acquired before
     // it is attached so that the interop surface is locked, which populates
     // the GL renderbuffer. This results in the renderbuffer being ready and
     // attachment to framebuffer succeeds in Attach() call.
     newBack->Surf()->ProducerAcquire();
 
-    if (!Attach(newBack->Surf(), size))
+    if (!Attach(newBack->Surf(), size)) {
+        newBack->Surf()->ProducerRelease();
         return false;
+    }
     // Attach was successful.
 
     mFront = mBack;
     mBack = newBack;
 
     if (ShouldPreserveBuffer() &&
         mFront &&
         mBack &&