Bug 1293908 - Specify the LayersBackend to be used when creating Textures r=nical

This commit is contained in:
George Wright
2016-08-18 12:54:17 -04:00
parent 864177c1a4
commit 36fd9eb839
6 changed files with 66 additions and 22 deletions

View File

@@ -23,7 +23,9 @@ class MemoryTextureData : public BufferTextureData
{
public:
static MemoryTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend,TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);
@@ -60,7 +62,9 @@ class ShmemTextureData : public BufferTextureData
{
public:
static ShmemTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);
@@ -107,15 +111,18 @@ bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
BufferTextureData*
BufferTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
{
if (!aAllocator || aAllocator->IsSameProcess()) {
return MemoryTextureData::Create(aSize, aFormat, aMoz2DBackend, aFlags,
return MemoryTextureData::Create(aSize, aFormat, aMoz2DBackend,
aLayersBackend, aFlags,
aAllocFlags, aAllocator);
} else if (aAllocator->AsShmemAllocator()) {
return ShmemTextureData::Create(aSize, aFormat, aMoz2DBackend, aFlags,
return ShmemTextureData::Create(aSize, aFormat, aMoz2DBackend,
aLayersBackend, aFlags,
aAllocFlags, aAllocator);
}
return nullptr;
@@ -452,7 +459,8 @@ InitBuffer(uint8_t* buf, size_t bufSize,
MemoryTextureData*
MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
{
@@ -474,10 +482,7 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
return nullptr;
}
auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat,
fwd->GetCompositorBackendType())
: true;
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
GfxMemoryImageReporter::DidAlloc(buf);
@@ -500,8 +505,13 @@ MemoryTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
MOZ_ASSERT(aAllocator->AsCompositableForwarder());
LayersBackend backend =
aAllocator->AsCompositableForwarder()->GetCompositorBackendType();
return MemoryTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
aFlags, aAllocFlags, aAllocator);
backend, aFlags, aAllocFlags, aAllocator);
}
bool
@@ -519,7 +529,8 @@ ShmemTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
ShmemTextureData*
ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend, TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator)
{
@@ -551,10 +562,7 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
return nullptr;
}
auto fwd = aAllocator->AsCompositableForwarder();
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat,
fwd->GetCompositorBackendType())
: true;
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
@@ -568,8 +576,13 @@ ShmemTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
MOZ_ASSERT(aAllocator->AsCompositableForwarder());
LayersBackend backend =
aAllocator->AsCompositableForwarder()->GetCompositorBackendType();
return ShmemTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
aFlags, aAllocFlags, aAllocator);
backend, aFlags, aAllocFlags, aAllocator);
}
void

View File

@@ -22,7 +22,9 @@ class BufferTextureData : public TextureData
{
public:
static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
gfx::BackendType aMoz2DBackend,TextureFlags aFlags,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags,
ClientIPCAllocator* aAllocator);

View File

@@ -1111,7 +1111,8 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
// Can't do any better than a buffer texture client.
return TextureClient::CreateForRawBufferAccess(aAllocator, aFormat, aSize,
moz2DBackend, aTextureFlags, aAllocFlags);
moz2DBackend, aLayersBackend,
aTextureFlags, aAllocFlags);
}
// static
@@ -1184,6 +1185,22 @@ TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
gfx::BackendType aMoz2DBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
auto fwd = aAllocator->AsCompositableForwarder();
auto backend = fwd ? fwd->GetCompositorBackendType() : LayersBackend::LAYERS_NONE;
return CreateForRawBufferAccess(aAllocator, aFormat, aSize, aMoz2DBackend,
backend, aTextureFlags, aAllocFlags);
}
// static
already_AddRefed<TextureClient>
TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend,
LayersBackend aLayersBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
// also test the validity of aAllocator
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
@@ -1206,8 +1223,8 @@ TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
}
TextureData* texData = BufferTextureData::Create(aSize, aFormat, aMoz2DBackend,
aTextureFlags, aAllocFlags,
aAllocator);
aLayersBackend, aTextureFlags,
aAllocFlags, aAllocator);
if (!texData) {
return nullptr;
}

View File

@@ -376,6 +376,16 @@ public:
// Creates and allocates a TextureClient (can be accessed through raw
// pointers).
static already_AddRefed<TextureClient>
CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend,
LayersBackend aLayersBackend,
TextureFlags aTextureFlags,
TextureAllocationFlags flags = ALLOC_DEFAULT);
// TODO: remove this one and use the one above instead.
static already_AddRefed<TextureClient>
CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
gfx::IntSize aSize,

View File

@@ -153,6 +153,7 @@ TextureClientPool::AllocateTextureClient()
TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
mFormat, mSize,
gfx::BackendType::NONE,
mBackend,
mFlags, ALLOC_DEFAULT);
} else {
newClient =

View File

@@ -225,7 +225,8 @@ TEST(Layers, TextureSerialization) {
auto texData = BufferTextureData::Create(surface->GetSize(),
gfx::ImageFormatToSurfaceFormat(surface->Format()),
gfx::BackendType::CAIRO, TextureFlags::DEALLOCATE_CLIENT, ALLOC_DEFAULT, nullptr
gfx::BackendType::CAIRO, LayersBackend::LAYERS_NONE,
TextureFlags::DEALLOCATE_CLIENT, ALLOC_DEFAULT, nullptr
);
ASSERT_TRUE(!!texData);