Bug 694964 - crash [@ gfxSharedImageSurface::Open]. r=ajuma
authorOleg Romashin <romaxa@gmail.com>
Thu, 12 Jan 2012 15:49:43 -0800
changeset 84336 964b118ac852038d4e33b12592983eafd8112943
parent 84335 c98283f80ae7d02a408e21169144adcf13be08e0
child 84380 b05c0f2fc18e0667a6b1450249f417fb95d374cf
push id21841
push userromaxa@gmail.com
push dateThu, 12 Jan 2012 23:57:21 +0000
treeherdermozilla-central@964b118ac852 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersajuma
bugs694964
milestone12.0a1
first release with
nightly linux32
964b118ac852 / 12.0a1 / 20120113031050 / files
nightly linux64
964b118ac852 / 12.0a1 / 20120113031050 / files
nightly mac
964b118ac852 / 12.0a1 / 20120113031050 / files
nightly win32
964b118ac852 / 12.0a1 / 20120113031050 / files
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
Bug 694964 - crash [@ gfxSharedImageSurface::Open]. r=ajuma
gfx/layers/basic/BasicLayers.cpp
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -2259,20 +2259,23 @@ private:
 void
 BasicShadowableThebesLayer::SetBackBufferAndAttrs(const OptionalThebesBuffer& aBuffer,
                                                   const nsIntRegion& aValidRegion,
                                                   const OptionalThebesBuffer& aReadOnlyFrontBuffer,
                                                   const nsIntRegion& aFrontUpdatedRegion)
 {
   if (OptionalThebesBuffer::Tnull_t == aBuffer.type()) {
     mBackBuffer = SurfaceDescriptor();
-  } else {
+  } else if (!IsSurfaceDescriptorValid(mBackBuffer)) {
     mBackBuffer = aBuffer.get_ThebesBuffer().buffer();
     mBackBufferRect = aBuffer.get_ThebesBuffer().rect();
     mBackBufferRectRotation = aBuffer.get_ThebesBuffer().rotation();
+  } else {
+    SurfaceDescriptor obsoleteBuffer = aBuffer.get_ThebesBuffer().buffer();
+    BasicManager()->ShadowLayerForwarder::DestroySharedSurface(&obsoleteBuffer);
   }
   mFrontAndBackBufferDiffer = true;
   mROFrontBuffer = aReadOnlyFrontBuffer;
   mFrontUpdatedRegion = aFrontUpdatedRegion;
   mFrontValidRegion = aValidRegion;
   if (OptionalThebesBuffer::Tnull_t == mROFrontBuffer.type()) {
     // For null readonly front, we have single buffer mode
     // so we can do sync right now, because it does not create new buffer and
@@ -2365,16 +2368,18 @@ BasicShadowableThebesLayer::PaintBuffer(
                "Update outside of buffer rect!");
   NS_ABORT_IF_FALSE(IsSurfaceDescriptorValid(mBackBuffer),
                     "should have a back buffer by now");
   BasicManager()->PaintedThebesBuffer(BasicManager()->Hold(this),
                                       updatedRegion,
                                       mBuffer.BufferRect(),
                                       mBuffer.BufferRotation(),
                                       mBackBuffer);
+  mROFrontBuffer = ThebesBuffer(mBackBuffer, mBuffer.BufferRect(), mBuffer.BufferRotation());
+  mBackBuffer = SurfaceDescriptor();
 }
 
 already_AddRefed<gfxASurface>
 BasicShadowableThebesLayer::CreateBuffer(Buffer::ContentType aType,
                                          const nsIntSize& aSize)
 {
   if (!HasShadow()) {
     return BasicThebesLayer::CreateBuffer(aType, aSize);