Bug 693282 - BasicShadowableThebesLayer leaking backBuffers. r=cjones
authorOleg Romashin <romaxa@gmail.com>
Mon, 10 Oct 2011 16:43:56 -0700
changeset 78526 cd148629d7e7cf71a7eb03886c5835091906191f
parent 78525 09ca3ba9ccb0dac4ee1ee5a184c8b511625306da
child 78527 f4fa6df431be373458eb0d57e37b011a4ab89414
push id21308
push usermak77@bonardo.net
push dateTue, 11 Oct 2011 09:17:03 +0000
treeherdermozilla-central@568821b5cdca [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscjones
bugs693282
milestone10.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 693282 - BasicShadowableThebesLayer leaking backBuffers. r=cjones
gfx/layers/basic/BasicLayers.cpp
gfx/layers/ipc/ShadowLayers.cpp
gfx/layers/ipc/ShadowLayers.h
--- a/gfx/layers/basic/BasicLayers.cpp
+++ b/gfx/layers/basic/BasicLayers.cpp
@@ -2352,16 +2352,18 @@ BasicShadowableThebesLayer::CreateBuffer
     return BasicThebesLayer::CreateBuffer(aType, aSize);
   }
 
   MOZ_LAYERS_LOG(("BasicShadowableThebes(%p): creating %d x %d buffer(x2)",
                   this,
                   aSize.width, aSize.height));
 
   if (IsSurfaceDescriptorValid(mBackBuffer)) {
+    BasicManager()->DestroyedThebesBuffer(BasicManager()->Hold(this),
+                                          mBackBuffer);
     mBackBuffer = SurfaceDescriptor();
   }
 
   // XXX error handling
   if (!BasicManager()->AllocBuffer(gfxIntSize(aSize.width, aSize.height),
                                    aType,
                                    &mBackBuffer)) {
       NS_RUNTIMEABORT("creating ThebesLayer 'back buffer' failed!");
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -180,16 +180,23 @@ ShadowLayerForwarder::CreatedColorLayer(
 }
 void
 ShadowLayerForwarder::CreatedCanvasLayer(ShadowableLayer* aCanvas)
 {
   CreatedLayer<OpCreateCanvasLayer>(mTxn, aCanvas);
 }
 
 void
+ShadowLayerForwarder::DestroyedThebesBuffer(ShadowableLayer* aThebes,
+                                            const SurfaceDescriptor& aBackBufferToDestroy)
+{
+  mTxn->AddBufferToDestroy(aBackBufferToDestroy);
+}
+
+void
 ShadowLayerForwarder::Mutated(ShadowableLayer* aMutant)
 {
   mTxn->AddMutant(aMutant);
 }
 
 void
 ShadowLayerForwarder::SetRoot(ShadowableLayer* aRoot)
 {
--- a/gfx/layers/ipc/ShadowLayers.h
+++ b/gfx/layers/ipc/ShadowLayers.h
@@ -136,16 +136,27 @@ public:
    */
   void CreatedThebesLayer(ShadowableLayer* aThebes);
   void CreatedContainerLayer(ShadowableLayer* aContainer);
   void CreatedImageLayer(ShadowableLayer* aImage);
   void CreatedColorLayer(ShadowableLayer* aColor);
   void CreatedCanvasLayer(ShadowableLayer* aCanvas);
 
   /**
+   * The specified layer is destroying its buffers.
+   * |aBackBufferToDestroy| is deallocated when this transaction is
+   * posted to the parent.  During the parent-side transaction, the
+   * shadow is told to destroy its front buffer.  This can happen when
+   * a new front/back buffer pair have been created because of a layer
+   * resize, e.g.
+   */
+  void DestroyedThebesBuffer(ShadowableLayer* aThebes,
+                             const SurfaceDescriptor& aBackBufferToDestroy);
+
+  /**
    * At least one attribute of |aMutant| has changed, and |aMutant|
    * needs to sync to its shadow layer.  This initial implementation
    * forwards all attributes when any is mutated.
    */
   void Mutated(ShadowableLayer* aMutant);
 
   void SetRoot(ShadowableLayer* aRoot);
   /**