Bug 739679 - Part 6: Fix unlocking gfxReusableSurface. r=pcwalton
authorBenoit Girard <b56girard@gmail.com>
Mon, 23 Apr 2012 20:08:18 -0400
changeset 95497 190aa5af83987f5361a29d99027d5be9bb78e620
parent 95496 9924dff6dbe98bb5fff7c14a363b0a331d343bcc
child 95498 37b4c6fd16edb1d282371fb4bd24d33f4cb9b9cc
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspcwalton
bugs739679
milestone14.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 739679 - Part 6: Fix unlocking gfxReusableSurface. r=pcwalton
gfx/layers/TiledLayerBuffer.h
gfx/layers/basic/BasicTiledThebesLayer.h
gfx/layers/opengl/TiledThebesLayerOGL.cpp
gfx/thebes/gfxReusableSurfaceWrapper.cpp
--- a/gfx/layers/TiledLayerBuffer.h
+++ b/gfx/layers/TiledLayerBuffer.h
@@ -111,18 +111,16 @@ protected:
    * Only the region intersecting with mValidRegion should be read from a tile,
    * another other region is assumed to be uninitialized.
    */
   nsTArray<Tile>  mRetainedTiles;
   int             mRetainedWidth;  // in tiles
   int             mRetainedHeight; // in tiles
 
 private:
-  TiledLayerBuffer(const TiledLayerBuffer&) MOZ_DELETE;
-
   const Derived& AsDerived() const { return *static_cast<const Derived*>(this); }
   Derived& AsDerived() { return *static_cast<Derived*>(this); }
 
   bool IsPlaceholder(Tile aTile) const { return aTile == AsDerived().GetPlaceholderTile(); }
 };
 
 class BasicTiledLayerBuffer;
 
--- a/gfx/layers/basic/BasicTiledThebesLayer.h
+++ b/gfx/layers/basic/BasicTiledThebesLayer.h
@@ -74,16 +74,19 @@ class BasicTiledThebesLayer;
  * which is much faster then painting directly into the tiles.
  */
 
 class BasicTiledLayerBuffer : public TiledLayerBuffer<BasicTiledLayerBuffer, BasicTiledLayerTile>
 {
   friend class TiledLayerBuffer<BasicTiledLayerBuffer, BasicTiledLayerTile>;
 
 public:
+  BasicTiledLayerBuffer()
+    {}
+
   void PaintThebes(BasicTiledThebesLayer* aLayer,
                    const nsIntRegion& aNewValidRegion,
                    const nsIntRegion& aPaintRegion,
                    LayerManager::DrawThebesLayerCallback aCallback,
                    void* aCallbackData);
 
   BasicTiledLayerTile GetPlaceholderTile() const {
     return mPlaceholder;
--- a/gfx/layers/opengl/TiledThebesLayerOGL.cpp
+++ b/gfx/layers/opengl/TiledThebesLayerOGL.cpp
@@ -131,16 +131,22 @@ TiledThebesLayerOGL::ProcessUploadQueue(
 {
   if (mRegionToUpload.IsEmpty())
     return;
 
   mVideoMemoryTiledBuffer.Upload(&mMainMemoryTiledBuffer, mMainMemoryTiledBuffer.GetValidRegion(), mRegionToUpload);
   mValidRegion = mVideoMemoryTiledBuffer.GetValidRegion();
 
   mMainMemoryTiledBuffer.ReadUnlock();
+  // Release all the tiles by replacing the tile buffer with an empty
+  // tiled buffer. This will prevent us from doing a double unlock when
+  // calling  ~TiledThebesLayerOGL.
+  // FIXME: This wont be needed when we do progressive upload and lock
+  // tile by tile.
+  mMainMemoryTiledBuffer = BasicTiledLayerBuffer();
   mRegionToUpload = nsIntRegion();
 
 }
 
 void
 TiledThebesLayerOGL::RenderLayer(int aPreviousFrameBuffer, const nsIntPoint& aOffset)
 {
   gl()->MakeCurrent();
--- a/gfx/thebes/gfxReusableSurfaceWrapper.cpp
+++ b/gfx/thebes/gfxReusableSurfaceWrapper.cpp
@@ -43,16 +43,17 @@ gfxReusableSurfaceWrapper::ReadLock()
   NS_CheckThreadSafe(_mOwningThread.GetThread(), "Only the owner thread can call ReadOnlyLock");
   PR_ATOMIC_INCREMENT(&mReadCount);
 }
 
 void
 gfxReusableSurfaceWrapper::ReadUnlock()
 {
   PR_ATOMIC_DECREMENT(&mReadCount);
+  NS_ABORT_IF_FALSE(mReadCount >= 0, "Should not be negative");
 }
 
 gfxReusableSurfaceWrapper*
 gfxReusableSurfaceWrapper::GetWritable(gfxImageSurface** aSurface)
 {
   NS_CheckThreadSafe(_mOwningThread.GetThread(), "Only the owner thread can call GetWritable");
 
   if (mReadCount == 0) {