From 9dab8f05aba21ad6c0c2b854973402450141be44 Mon Sep 17 00:00:00 2001 From: Nicholas Cameron Date: Mon, 19 Aug 2013 11:08:43 +1200 Subject: [PATCH] Bug 904343. Clear surface descriptors. r=nical. --- gfx/layers/client/TextureClient.cpp | 33 ++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 87785dd67e12..6ece7970c854 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -320,7 +320,11 @@ DeprecatedTextureClientShmem::EnsureAllocated(gfx::IntSize aSize, NS_WARNING("creating SurfaceDescriptor failed!"); } if (mContentType == gfxASurface::CONTENT_COLOR_ALPHA) { - nsRefPtr context = new gfxContext(GetSurface()); + gfxASurface* surface = GetSurface(); + if (!surface) { + return false; + } + nsRefPtr context = new gfxContext(surface); context->SetColor(gfxRGBA(0, 0, 0, 0)); context->SetOperator(gfxContext::OPERATOR_SOURCE); context->Paint(); @@ -332,16 +336,17 @@ DeprecatedTextureClientShmem::EnsureAllocated(gfx::IntSize aSize, void DeprecatedTextureClientShmem::SetDescriptor(const SurfaceDescriptor& aDescriptor) { - if (IsSurfaceDescriptorValid(aDescriptor)) { - ReleaseResources(); - mDescriptor = aDescriptor; - } else { + if (aDescriptor.type() == SurfaceDescriptor::Tnull_t) { EnsureAllocated(mSize, mContentType); + return; } - MOZ_ASSERT(!mSurface); + ReleaseResources(); + mDescriptor = aDescriptor; - NS_ASSERTION(mDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc || + MOZ_ASSERT(!mSurface); + NS_ASSERTION(mDescriptor.type() == SurfaceDescriptor::T__None || + mDescriptor.type() == SurfaceDescriptor::TSurfaceDescriptorGralloc || mDescriptor.type() == SurfaceDescriptor::TShmem || mDescriptor.type() == SurfaceDescriptor::TMemoryImage || mDescriptor.type() == SurfaceDescriptor::TRGBImage, @@ -375,6 +380,10 @@ DeprecatedTextureClientShmem::LockDrawTarget() } gfxASurface* surface = GetSurface(); + if (!surface) { + return nullptr; + } + mDrawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(surface, mSize); return mDrawTarget; @@ -394,7 +403,11 @@ gfxImageSurface* DeprecatedTextureClientShmem::LockImageSurface() { if (!mSurfaceAsImage) { - mSurfaceAsImage = GetSurface()->GetAsImageSurface(); + gfxASurface* surface = GetSurface(); + if (!surface) { + return nullptr; + } + mSurfaceAsImage = surface->GetAsImageSurface(); } return mSurfaceAsImage.get(); @@ -417,13 +430,13 @@ DeprecatedTextureClientShmemYCbCr::ReleaseResources() void DeprecatedTextureClientShmemYCbCr::SetDescriptor(const SurfaceDescriptor& aDescriptor) { - MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TYCbCrImage); + MOZ_ASSERT(aDescriptor.type() == SurfaceDescriptor::TYCbCrImage || + aDescriptor.type() == SurfaceDescriptor::T__None); if (IsSurfaceDescriptorValid(mDescriptor)) { GetForwarder()->DestroySharedSurface(&mDescriptor); } mDescriptor = aDescriptor; - MOZ_ASSERT(IsSurfaceDescriptorValid(mDescriptor)); } void