Bug 964794 - Remove extra Lock and minimize DT creation/destruction in D3D11 TextureClient. r=Bas

This commit is contained in:
Nicolas Silva 2014-01-29 17:26:42 +01:00
Родитель 8b105c15d6
Коммит 69c3714770
2 изменённых файлов: 12 добавлений и 8 удалений

Просмотреть файл

@ -146,6 +146,7 @@ TextureClientD3D11::TextureClientD3D11(gfx::SurfaceFormat aFormat, TextureFlags
: TextureClient(aFlags)
, mFormat(aFormat)
, mIsLocked(false)
, mNeedsClear(false)
{}
TextureClientD3D11::~TextureClientD3D11()
@ -159,6 +160,12 @@ TextureClientD3D11::Lock(OpenMode aMode)
}
MOZ_ASSERT(!mIsLocked, "The Texture is already locked!");
LockD3DTexture(mTexture.get());
if (mNeedsClear) {
mDrawTarget->ClearRect(Rect(0, 0, GetSize().width, GetSize().height));
mNeedsClear = false;
}
mIsLocked = true;
return true;
}
@ -169,7 +176,6 @@ TextureClientD3D11::Unlock()
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
if (mDrawTarget) {
mDrawTarget->Flush();
mDrawTarget = nullptr;
}
UnlockD3DTexture(mTexture.get());
mIsLocked = false;
@ -184,6 +190,8 @@ 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;
}
@ -207,13 +215,8 @@ TextureClientD3D11::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlag
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();
}
// Defer clearing to the next time we lock to avoid an extra (expensive) lock.
mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER;
return true;
}

Просмотреть файл

@ -66,6 +66,7 @@ protected:
RefPtr<gfx::DrawTarget> mDrawTarget;
gfx::SurfaceFormat mFormat;
bool mIsLocked;
bool mNeedsClear;
};
/**