Bug 914505 - Make sure that ThebesLayerBuffer::SupportsAzureContent is correct for the first frame. r=nrc

This commit is contained in:
Matt Woodrow 2013-09-12 16:53:46 +12:00
parent 45ad762f15
commit a13d1d68bd
5 changed files with 65 additions and 84 deletions

View File

@ -424,6 +424,10 @@ ThebesLayerBuffer::IsAzureBuffer()
if (mBuffer) {
return false;
}
if (mBufferProvider) {
return gfxPlatform::GetPlatform()->SupportsAzureContentForType(
mBufferProvider->BackendType());
}
return SupportsAzureContent();
}
@ -651,13 +655,9 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
// We can't do a real self-copy because the buffer is rotated.
// So allocate a new buffer for the destination.
destBufferRect = ComputeBufferRect(neededRegion.GetBounds());
if (IsAzureBuffer()) {
MOZ_ASSERT(!mBuffer);
destDTBuffer = CreateDTBuffer(contentType, destBufferRect, bufferFlags, &destDTBufferOnWhite);
} else {
MOZ_ASSERT(!mDTBuffer);
destBuffer = CreateBuffer(contentType, destBufferRect, bufferFlags, getter_AddRefs(destBufferOnWhite));
}
CreateBuffer(contentType, destBufferRect, bufferFlags,
getter_AddRefs(destBuffer), getter_AddRefs(destBufferOnWhite),
&destDTBuffer, &destDTBufferOnWhite);
if (!destBuffer && !destDTBuffer)
return result;
}
@ -674,13 +674,9 @@ ThebesLayerBuffer::BeginPaint(ThebesLayer* aLayer, ContentType aContentType,
}
} else {
// The buffer's not big enough, so allocate a new one
if (IsAzureBuffer()) {
MOZ_ASSERT(!mBuffer);
destDTBuffer = CreateDTBuffer(contentType, destBufferRect, bufferFlags, &destDTBufferOnWhite);
} else {
MOZ_ASSERT(!mDTBuffer);
destBuffer = CreateBuffer(contentType, destBufferRect, bufferFlags, getter_AddRefs(destBufferOnWhite));
}
CreateBuffer(contentType, destBufferRect, bufferFlags,
getter_AddRefs(destBuffer), getter_AddRefs(destBufferOnWhite),
&destDTBuffer, &destDTBufferOnWhite);
if (!destBuffer && !destDTBuffer)
return result;
}

View File

@ -245,12 +245,14 @@ public:
* Return a new surface of |aSize| and |aType|.
* @param aFlags if ALLOW_REPEAT is set, then the buffer should be configured
* to allow repeat-mode, otherwise it should be in pad (clamp) mode
* If the created buffer supports azure content, then the result(s) will
* be returned in aBlackDT/aWhiteDT, otherwise aBlackSurface/aWhiteSurface
* will be used.
*/
virtual already_AddRefed<gfxASurface>
CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags, gfxASurface** aWhiteSurface) = 0;
virtual TemporaryRef<gfx::DrawTarget>
CreateDTBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags, RefPtr<gfx::DrawTarget>* aWhiteDT)
{ NS_RUNTIMEABORT("CreateDTBuffer not implemented on this platform!"); return nullptr; }
virtual void
CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
gfxASurface** aBlackSurface, gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) = 0;
virtual bool SupportsAzureContent() const
{ return false; }

View File

@ -77,13 +77,26 @@ ContentClientBasic::ContentClientBasic(CompositableForwarder* aForwarder,
: ContentClient(aForwarder), ThebesLayerBuffer(ContainsVisibleBounds), mManager(aManager)
{}
already_AddRefed<gfxASurface>
void
ContentClientBasic::CreateBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
gfxASurface**)
gfxASurface** aBlackSurface,
gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT,
RefPtr<gfx::DrawTarget>* aWhiteDT)
{
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
if (gfxPlatform::GetPlatform()->SupportsAzureContent()) {
gfxASurface::gfxImageFormat format =
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType);
*aBlackDT = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
IntSize(aRect.width, aRect.height),
ImageFormatToSurfaceFormat(format));
return;
}
nsRefPtr<gfxASurface> referenceSurface = GetBuffer();
if (!referenceSurface) {
gfxContext* defaultTarget = mManager->GetDefaultTarget();
@ -96,23 +109,9 @@ ContentClientBasic::CreateBuffer(ContentType aType,
}
}
}
return referenceSurface->CreateSimilarSurface(
nsRefPtr<gfxASurface> ret = referenceSurface->CreateSimilarSurface(
aType, gfxIntSize(aRect.width, aRect.height));
}
TemporaryRef<DrawTarget>
ContentClientBasic::CreateDTBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
RefPtr<DrawTarget>* aWhiteDT)
{
MOZ_ASSERT(!(aFlags & BUFFER_COMPONENT_ALPHA));
gfxASurface::gfxImageFormat format =
gfxPlatform::GetPlatform()->OptimalFormatForContent(aType);
return gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
IntSize(aRect.width, aRect.height),
ImageFormatToSurfaceFormat(format));
*aBlackSurface = ret.forget().get();
}
void
@ -225,46 +224,37 @@ ContentClientBasic::SupportsAzureContent() const
bool
ContentClientRemoteBuffer::SupportsAzureContent() const
{
if (!mDeprecatedTextureClient) {
// Hopefully we don't call this method before we have a texture client. But if
// we do, then we have no idea if we can support Azure for whatever surface the
// texture client might come up with.
return false;
}
MOZ_ASSERT(mDeprecatedTextureClient);
return gfxPlatform::GetPlatform()->SupportsAzureContentForType(
mDeprecatedTextureClient->BackendType());
}
TemporaryRef<DrawTarget>
ContentClientRemoteBuffer::CreateDTBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
RefPtr<gfx::DrawTarget>* aWhiteDT)
{
BuildDeprecatedTextureClients(aType, aRect, aFlags);
RefPtr<DrawTarget> ret = mDeprecatedTextureClient->LockDrawTarget();
if (aFlags & BUFFER_COMPONENT_ALPHA) {
*aWhiteDT = mDeprecatedTextureClientOnWhite->LockDrawTarget();
}
return ret.forget();
}
already_AddRefed<gfxASurface>
void
ContentClientRemoteBuffer::CreateBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
gfxASurface** aWhiteSurface)
gfxASurface** aBlackSurface,
gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT,
RefPtr<gfx::DrawTarget>* aWhiteDT)
{
BuildDeprecatedTextureClients(aType, aRect, aFlags);
nsRefPtr<gfxASurface> ret = mDeprecatedTextureClient->LockSurface();
if (aFlags & BUFFER_COMPONENT_ALPHA) {
nsRefPtr<gfxASurface> retWhite = mDeprecatedTextureClientOnWhite->LockSurface();
*aWhiteSurface = retWhite.forget().get();
if (gfxPlatform::GetPlatform()->SupportsAzureContentForType(
mDeprecatedTextureClient->BackendType())) {
*aBlackDT = mDeprecatedTextureClient->LockDrawTarget();
if (aFlags & BUFFER_COMPONENT_ALPHA) {
*aWhiteDT = mDeprecatedTextureClientOnWhite->LockDrawTarget();
}
} else {
nsRefPtr<gfxASurface> ret = mDeprecatedTextureClient->LockSurface();
*aBlackSurface = ret.forget().get();
if (aFlags & BUFFER_COMPONENT_ALPHA) {
nsRefPtr<gfxASurface> retWhite = mDeprecatedTextureClientOnWhite->LockSurface();
*aWhiteSurface = retWhite.forget().get();
}
}
return ret.forget();
}
nsIntRegion

View File

@ -152,14 +152,9 @@ public:
ThebesLayerBuffer::DrawTo(aLayer, aTarget, aOpacity, aMask, aMaskTransform);
}
virtual already_AddRefed<gfxASurface> CreateBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
gfxASurface**) MOZ_OVERRIDE;
virtual TemporaryRef<gfx::DrawTarget> CreateDTBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
RefPtr<gfx::DrawTarget>* aWhiteDT);
virtual void CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
gfxASurface** aBlackSurface, gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
virtual bool SupportsAzureContent() const;
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
@ -238,14 +233,9 @@ public:
return ThebesLayerBuffer::BufferRotation();
}
virtual already_AddRefed<gfxASurface> CreateBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
gfxASurface** aWhiteSurface) MOZ_OVERRIDE;
virtual TemporaryRef<gfx::DrawTarget> CreateDTBuffer(ContentType aType,
const nsIntRect& aRect,
uint32_t aFlags,
RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
virtual void CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
gfxASurface** aBlackSurface, gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE;
virtual bool SupportsAzureContent() const MOZ_OVERRIDE;

View File

@ -355,13 +355,16 @@ public:
}
// ThebesLayerBuffer interface
virtual already_AddRefed<gfxASurface>
CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags, gfxASurface**)
void
CreateBuffer(ContentType aType, const nsIntRect& aRect, uint32_t aFlags,
gfxASurface** aBlackSurface, gfxASurface** aWhiteSurface,
RefPtr<gfx::DrawTarget>* aBlackDT, RefPtr<gfx::DrawTarget>* aWhiteDT) MOZ_OVERRIDE
{
NS_ASSERTION(gfxASurface::CONTENT_ALPHA != aType,"ThebesBuffer has color");
mTexImage = CreateClampOrRepeatTextureImage(gl(), aRect.Size(), aType, aFlags);
return mTexImage ? mTexImage->GetBackingSurface() : nullptr;
nsRefPtr<gfxASurface> ret = mTexImage ? mTexImage->GetBackingSurface() : nullptr;
*aBlackSurface = ret.forget().get();
}
virtual nsIntPoint GetOriginOffset() {