Bug 968807 - Add assertions in TextureClient. r=bjacob

This commit is contained in:
Nicolas Silva 2014-03-21 18:03:20 +01:00
parent 23d928823f
commit 9bd388fd15
4 changed files with 19 additions and 6 deletions

View File

@ -488,6 +488,7 @@ bool TextureClient::CopyToTextureClient(TextureClient* aTarget,
void
TextureClient::Finalize()
{
MOZ_ASSERT(!IsLocked());
// Always make a temporary strong reference to the actor before we use it,
// in case TextureChild::ActorDestroy might null mActor concurrently.
RefPtr<TextureChild> actor = mActor;
@ -648,6 +649,7 @@ BufferTextureClient::GetAllocator() const
bool
BufferTextureClient::UpdateSurface(gfxASurface* aSurface)
{
MOZ_ASSERT(mLocked);
MOZ_ASSERT(aSurface);
MOZ_ASSERT(!IsImmutable());
MOZ_ASSERT(IsValid());
@ -676,6 +678,7 @@ BufferTextureClient::UpdateSurface(gfxASurface* aSurface)
already_AddRefed<gfxASurface>
BufferTextureClient::GetAsSurface()
{
MOZ_ASSERT(mLocked);
MOZ_ASSERT(IsValid());
ImageDataSerializer serializer(GetBuffer(), GetBufferSize());
@ -715,8 +718,7 @@ TemporaryRef<gfx::DrawTarget>
BufferTextureClient::GetAsDrawTarget()
{
MOZ_ASSERT(IsValid());
// XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed
NS_WARN_IF_FALSE(mLocked, "GetAsDrawTarget should be called on locked textures only");
MOZ_ASSERT(mLocked, "GetAsDrawTarget should be called on locked textures only");
if (mDrawTarget) {
return mDrawTarget;
@ -753,8 +755,7 @@ BufferTextureClient::GetAsDrawTarget()
bool
BufferTextureClient::Lock(OpenMode aMode)
{
// XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed
NS_WARN_IF_FALSE(!mLocked, "The TextureClient is already Locked!");
MOZ_ASSERT(!mLocked, "The TextureClient is already Locked!");
mOpenMode = aMode;
mLocked = IsValid() && IsAllocated();;
return mLocked;
@ -763,14 +764,19 @@ BufferTextureClient::Lock(OpenMode aMode)
void
BufferTextureClient::Unlock()
{
// XXX - Turn this into a fatal assertion as soon as Bug 952507 is fixed
NS_WARN_IF_FALSE(mLocked, "The TextureClient is already Unlocked!");
MOZ_ASSERT(mLocked, "The TextureClient is already Unlocked!");
mLocked = false;
if (!mDrawTarget) {
mUsingFallbackDrawTarget = false;
return;
}
// see the comment on TextureClientDrawTarget::GetAsDrawTarget.
// This DrawTarget is internal to the TextureClient and is only exposed to the
// outside world between Lock() and Unlock(). This assertion checks that no outside
// reference remains by the time Unlock() is called.
MOZ_ASSERT(mDrawTarget->refCount() == 1);
mDrawTarget->Flush();
if (mUsingFallbackDrawTarget && (mOpenMode & OPEN_WRITE)) {
// When we are using a fallback DrawTarget, it means we could not create
@ -802,6 +808,7 @@ BufferTextureClient::Unlock()
bool
BufferTextureClient::UpdateYCbCr(const PlanarYCbCrData& aData)
{
MOZ_ASSERT(mLocked);
MOZ_ASSERT(mFormat == gfx::SurfaceFormat::YUV, "This textureClient can only use YCbCr data");
MOZ_ASSERT(!IsImmutable());
MOZ_ASSERT(IsValid());

View File

@ -188,6 +188,10 @@ TextureClientD3D11::Unlock()
{
MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
if (mDrawTarget) {
// see the comment on TextureClientDrawTarget::GetAsDrawTarget.
// This DrawTarget is internal to the TextureClient and is only exposed to the
// outside world between Lock() and Unlock(). This assertion checks that no outside
// reference remains by the time Unlock() is called.
MOZ_ASSERT(mDrawTarget->refCount() == 1);
mDrawTarget->Flush();
}

View File

@ -119,6 +119,7 @@ ImageBridgeChild::UseComponentAlphaTextures(CompositableClient* aCompositable,
TextureClient* aTextureOnBlack,
TextureClient* aTextureOnWhite)
{
MOZ_ASSERT(aTextureOnBlack->GetSize() == aTextureOnWhite->GetSize());
mTxn->AddNoSwapEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTextureOnBlack->GetIPDLActor(),
nullptr, aTextureOnWhite->GetIPDLActor()));

View File

@ -439,6 +439,7 @@ ShadowLayerForwarder::UseComponentAlphaTextures(CompositableClient* aCompositabl
TextureClient* aTextureOnBlack,
TextureClient* aTextureOnWhite)
{
MOZ_ASSERT(aTextureOnBlack->GetSize() == aTextureOnWhite->GetSize());
mTxn->AddEdit(OpUseComponentAlphaTextures(nullptr, aCompositable->GetIPDLActor(),
nullptr, aTextureOnBlack->GetIPDLActor(),
nullptr, aTextureOnWhite->GetIPDLActor()));