From 6f304e526d96f2459bbffa313acab03ad1b7f816 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Wed, 9 Apr 2014 21:15:18 +1200 Subject: [PATCH] Bug 991513 - Part 1: Don't lock ContentClientDoubleBuffered's texture until we need the buffers. r=nrc --- gfx/layers/RotatedBuffer.cpp | 6 +++--- gfx/layers/client/ContentClient.cpp | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/gfx/layers/RotatedBuffer.cpp b/gfx/layers/RotatedBuffer.cpp index cdd195bf6aa..f9ff0be335e 100644 --- a/gfx/layers/RotatedBuffer.cpp +++ b/gfx/layers/RotatedBuffer.cpp @@ -499,14 +499,14 @@ RotatedContentBuffer::BeginPaint(ThebesLayer* aLayer, result.mRegionToDraw.Sub(neededRegion, validRegion); + if (result.mRegionToDraw.IsEmpty()) + return result; + // Do not modify result.mRegionToDraw or result.mContentType after this call. // Do not modify mBufferRect, mBufferRotation, or mDidSelfCopy, // or call CreateBuffer before this call. FinalizeFrame(result.mRegionToDraw); - if (result.mRegionToDraw.IsEmpty()) - return result; - nsIntRect drawBounds = result.mRegionToDraw.GetBounds(); RefPtr destDTBuffer; RefPtr destDTBufferOnWhite; diff --git a/gfx/layers/client/ContentClient.cpp b/gfx/layers/client/ContentClient.cpp index 3149c3a63ee..e424339714b 100644 --- a/gfx/layers/client/ContentClient.cpp +++ b/gfx/layers/client/ContentClient.cpp @@ -156,10 +156,10 @@ ContentClientRemoteBuffer::EndPaint() } mOldTextures.Clear(); - if (mTextureClient) { + if (mTextureClient && mTextureClient->IsLocked()) { mTextureClient->Unlock(); } - if (mTextureClientOnWhite) { + if (mTextureClientOnWhite && mTextureClientOnWhite->IsLocked()) { mTextureClientOnWhite->Unlock(); } } @@ -382,15 +382,6 @@ ContentClientDoubleBuffered::PrepareFrame() { mIsNewBuffer = false; - if (mTextureClient) { - DebugOnly locked = mTextureClient->Lock(OPEN_READ_WRITE); - MOZ_ASSERT(locked); - } - if (mTextureClientOnWhite) { - DebugOnly locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE); - MOZ_ASSERT(locked); - } - if (!mFrontAndBackBufferDiffer) { return; } @@ -415,6 +406,15 @@ ContentClientDoubleBuffered::PrepareFrame() void ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw) { + if (mTextureClient) { + DebugOnly locked = mTextureClient->Lock(OPEN_READ_WRITE); + MOZ_ASSERT(locked); + } + if (mTextureClientOnWhite) { + DebugOnly locked = mTextureClientOnWhite->Lock(OPEN_READ_WRITE); + MOZ_ASSERT(locked); + } + if (!mFrontAndBackBufferDiffer) { MOZ_ASSERT(!mDidSelfCopy, "If we have to copy the world, then our buffers are different, right?"); return;