Bug 952507 - Flush the back buffer after syncing with the front buffer in the buffered ContentClient. r=Bas

This commit is contained in:
Nicolas Silva 2014-02-04 21:35:22 +01:00
parent 41488b0e13
commit b02c28b821
6 changed files with 38 additions and 28 deletions

View File

@ -133,8 +133,8 @@ ClientThebesLayer::PaintBuffer(gfxContext* aContext,
ClientManager()->SetTransactionIncomplete();
return;
}
ClientManager()->GetThebesLayerCallback()(this,
aContext,
ClientManager()->GetThebesLayerCallback()(this,
aContext,
aExtendedRegionToDraw,
aClip,
aRegionToInvalidate,

View File

@ -107,7 +107,7 @@ protected:
const nsIntRegion& aRegionToInvalidate,
bool aDidSelfCopy,
DrawRegionClip aClip);
void PaintThebes();
void DestroyBackBuffer()

View File

@ -630,18 +630,22 @@ ContentClientDoubleBuffered::FinalizeFrame(const nsIntRegion& aRegionToDraw)
mFrontClient->Unlock();
return;
}
RefPtr<DrawTarget> dt =
mFrontClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
RefPtr<DrawTarget> dtOnWhite = mFrontClientOnWhite
? mFrontClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget()
: nullptr;
RotatedBuffer frontBuffer(dt,
dtOnWhite,
mFrontBufferRect,
mFrontBufferRotation);
UpdateDestinationFrom(frontBuffer, updateRegion);
// We need to flush our buffers before we unlock our front textures
FlushBuffers();
{
// Restrict the DrawTargets and frontBuffer to a scope to make
// sure there is no more external references to the DrawTargets
// when we Unlock the TextureClients.
RefPtr<DrawTarget> dt =
mFrontClient->AsTextureClientDrawTarget()->GetAsDrawTarget();
RefPtr<DrawTarget> dtOnWhite = mFrontClientOnWhite
? mFrontClientOnWhite->AsTextureClientDrawTarget()->GetAsDrawTarget()
: nullptr;
RotatedBuffer frontBuffer(dt,
dtOnWhite,
mFrontBufferRect,
mFrontBufferRotation);
UpdateDestinationFrom(frontBuffer, updateRegion);
}
mFrontClient->Unlock();
if (mFrontClientOnWhite) {
mFrontClientOnWhite->Unlock();
@ -667,6 +671,8 @@ ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
if (isClippingCheap) {
destDT->PopClip();
}
// Flush the destination before the sources become inaccessible (Unlock).
destDT->Flush();
ReturnDrawTargetToBuffer(destDT);
if (aSource.HaveBufferOnWhite()) {
@ -686,6 +692,8 @@ ContentClientDoubleBuffered::UpdateDestinationFrom(const RotatedBuffer& aSource,
if (isClippingCheap) {
destDT->PopClip();
}
// Flush the destination before the sources become inaccessible (Unlock).
destDT->Flush();
ReturnDrawTargetToBuffer(destDT);
}
}

View File

@ -155,18 +155,16 @@ TextureClientD3D11::~TextureClientD3D11()
bool
TextureClientD3D11::Lock(OpenMode aMode)
{
if (!IsValid() || !IsAllocated()) {
return false;
}
MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");
LockD3DTexture(mTexture.get());
mIsLocked = true;
if (mNeedsClear) {
mDrawTarget = GetAsDrawTarget();
mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
mNeedsClear = false;
}
mIsLocked = true;
return true;
}
@ -175,8 +173,12 @@ TextureClientD3D11::Unlock()
{
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
if (mDrawTarget) {
MOZ_ASSERT(mDrawTarget->refCount() == 1);
mDrawTarget->Flush();
}
// The DrawTarget is created only once, and is only usable between calls
// to Lock and Unlock.
UnlockD3DTexture(mTexture.get());
mIsLocked = false;
}
@ -190,8 +192,6 @@ TextureClientD3D11::GetAsDrawTarget()
return mDrawTarget;
}
// The DrawTarget is created only once, and is only usable between calls
// to Lock and Unlock.
mDrawTarget = Factory::CreateDrawTargetForD3D10Texture(mTexture, mFormat);
return mDrawTarget;
}

View File

@ -72,9 +72,11 @@ CreateTextureHostD3D9(const SurfaceDescriptor& aDesc,
}
case SurfaceDescriptor::TSurfaceDescriptorD3D9: {
result = new TextureHostD3D9(aFlags, aDesc);
break;
}
case SurfaceDescriptor::TSurfaceDescriptorDIB: {
result = new DIBTextureHostD3D9(aFlags, aDesc);
break;
}
default: {
NS_WARNING("Unsupported SurfaceDescriptor type");
@ -1255,6 +1257,7 @@ CairoTextureClientD3D9::CairoTextureClientD3D9(gfx::SurfaceFormat aFormat, Textu
: TextureClient(aFlags)
, mFormat(aFormat)
, mIsLocked(false)
, mNeedsClear(false)
{
MOZ_COUNT_CTOR(CairoTextureClientD3D9);
}
@ -1271,6 +1274,10 @@ CairoTextureClientD3D9::Lock(OpenMode)
if (!IsValid() || !IsAllocated()) {
return false;
}
if (mNeedsClear) {
mDrawTarget = GetAsDrawTarget();
mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
}
mIsLocked = true;
return true;
}
@ -1353,13 +1360,7 @@ CairoTextureClientD3D9::AllocateForSurface(gfx::IntSize aSize, TextureAllocation
return false;
}
if (aFlags & ALLOC_CLEAR_BUFFER) {
DebugOnly<bool> locked = Lock(OPEN_WRITE_ONLY);
MOZ_ASSERT(locked);
RefPtr<DrawTarget> dt = GetAsDrawTarget();
dt->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
Unlock();
}
mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER;
MOZ_ASSERT(mTexture);
return true;

View File

@ -227,6 +227,7 @@ private:
gfx::IntSize mSize;
gfx::SurfaceFormat mFormat;
bool mIsLocked;
bool mNeedsClear;
};
/**