Bug 893301. Fix alpha corruptions. r=nrc

This commit is contained in:
Nicolas Silva 2013-11-08 18:53:16 +01:00
Родитель 302a5f0e82
Коммит 961a970469
3 изменённых файлов: 33 добавлений и 6 удалений

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

@ -165,13 +165,13 @@ ContentClientRemoteBuffer::CreateAndAllocateTextureClient(RefPtr<TextureClient>&
return false;
}
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize)) {
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
aClient = CreateTextureClientForDrawing(mSurfaceFormat,
mTextureInfo.mTextureFlags | TEXTURE_ALLOC_FALLBACK | aFlags);
if (!aClient) {
return false;
}
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize)) {
if (!aClient->AsTextureClientDrawTarget()->AllocateForSurface(mSize, ALLOC_CLEAR_BUFFER)) {
NS_WARNING("Could not allocate texture client");
aClient = nullptr;
return false;

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

@ -305,7 +305,7 @@ BufferTextureClient::GetAsSurface()
}
bool
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
BufferTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
{
MOZ_ASSERT(IsValid());
MOZ_ASSERT(mFormat != gfx::FORMAT_YUV, "This textureClient cannot use YCbCr data");
@ -315,6 +315,11 @@ BufferTextureClient::AllocateForSurface(gfx::IntSize aSize)
if (!Allocate(bufSize)) {
return false;
}
if (aFlags & ALLOC_CLEAR_BUFFER) {
memset(GetBuffer(), 0, bufSize);
}
ImageDataSerializer serializer(GetBuffer());
serializer.InitializeBufferInfo(aSize, mFormat);
mSize = aSize;

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

@ -48,6 +48,11 @@ class Image;
* using AsTextureCLientSurface(), etc.
*/
enum TextureAllocationFlags {
ALLOC_DEFAULT = 0,
ALLOC_CLEAR_BUFFER = 1
};
/**
* Interface for TextureClients that can be updated using a gfxASurface.
*/
@ -56,7 +61,15 @@ class TextureClientSurface
public:
virtual bool UpdateSurface(gfxASurface* aSurface) = 0;
virtual already_AddRefed<gfxASurface> GetAsSurface() = 0;
virtual bool AllocateForSurface(gfx::IntSize aSize) = 0;
/**
* Allocates for a given surface size, taking into account the pixel format
* which is part of the state of the TextureClient.
*
* Does not clear the surface by default, clearing the surface can be done
* by passing the CLEAR_BUFFER flag.
*/
virtual bool AllocateForSurface(gfx::IntSize aSize,
TextureAllocationFlags flags = ALLOC_DEFAULT) = 0;
};
/**
@ -67,7 +80,15 @@ class TextureClientDrawTarget
public:
virtual TemporaryRef<gfx::DrawTarget> GetAsDrawTarget() = 0;
virtual gfx::SurfaceFormat GetFormat() const = 0;
virtual bool AllocateForSurface(gfx::IntSize aSize) = 0;
/**
* Allocates for a given surface size, taking into account the pixel format
* which is part of the state of the TextureClient.
*
* Does not clear the surface by default, clearing the surface can be done
* by passing the CLEAR_BUFFER flag.
*/
virtual bool AllocateForSurface(gfx::IntSize aSize,
TextureAllocationFlags flags = ALLOC_DEFAULT) = 0;
};
/**
@ -277,7 +298,8 @@ public:
virtual already_AddRefed<gfxASurface> GetAsSurface() MOZ_OVERRIDE;
virtual bool AllocateForSurface(gfx::IntSize aSize) MOZ_OVERRIDE;
virtual bool AllocateForSurface(gfx::IntSize aSize,
TextureAllocationFlags flags = ALLOC_DEFAULT) MOZ_OVERRIDE;
// TextureClientDrawTarget