From 7c2def154017148d1634b6ec2e283ea1b536bb29 Mon Sep 17 00:00:00 2001 From: Andrew Osmond Date: Tue, 19 Sep 2017 08:19:48 -0400 Subject: [PATCH] Bug 1380649 - Part 2. Ensure SourceSurfaceVolatileData does not forget its purged state. r=jrmuizel Currently if SourceSurfaceVolatileData::Map fails due to being purged, we expect that the surface will be discarded by the caller. This has not consistently been the case, and as such, we should ensure we do not forget if a buffer was previously purged when we reacquire it. Since we do not at this time support repopulating an already allocated buffer with new data, we cannot reset this state once it has been set. --- gfx/layers/SourceSurfaceVolatileData.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gfx/layers/SourceSurfaceVolatileData.h b/gfx/layers/SourceSurfaceVolatileData.h index 7641733621a6..a97bf08ee73c 100644 --- a/gfx/layers/SourceSurfaceVolatileData.h +++ b/gfx/layers/SourceSurfaceVolatileData.h @@ -32,6 +32,7 @@ public: , mStride(0) , mMapCount(0) , mFormat(SurfaceFormat::UNKNOWN) + , mWasPurged(false) { } @@ -66,10 +67,14 @@ public: bool Map(MapType, MappedSurface *aMappedSurface) override { MutexAutoLock lock(mMutex); + if (mWasPurged) { + return false; + } if (mMapCount == 0) { mVBufPtr = mVBuf; } if (mVBufPtr.WasBufferPurged()) { + mWasPurged = true; return false; } aMappedSurface->mData = mVBufPtr; @@ -82,6 +87,7 @@ public: { MutexAutoLock lock(mMutex); MOZ_ASSERT(mMapCount > 0); + MOZ_ASSERT(!mWasPurged); if (--mMapCount == 0) { mVBufPtr = nullptr; } @@ -100,6 +106,7 @@ private: RefPtr mVBuf; VolatileBufferPtr mVBufPtr; SurfaceFormat mFormat; + bool mWasPurged; }; } // namespace gfx