Bug 1293908 - Specify the LayersBackend to be used when creating Textures r=nical
This commit is contained in:
@@ -23,7 +23,9 @@ class MemoryTextureData : public BufferTextureData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static MemoryTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
static MemoryTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend,TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend,
|
||||||
|
TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator);
|
ClientIPCAllocator* aAllocator);
|
||||||
|
|
||||||
@@ -60,7 +62,9 @@ class ShmemTextureData : public BufferTextureData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static ShmemTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
static ShmemTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend,
|
||||||
|
TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator);
|
ClientIPCAllocator* aAllocator);
|
||||||
|
|
||||||
@@ -107,15 +111,18 @@ bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
|||||||
|
|
||||||
BufferTextureData*
|
BufferTextureData*
|
||||||
BufferTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
BufferTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend, TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator)
|
ClientIPCAllocator* aAllocator)
|
||||||
{
|
{
|
||||||
if (!aAllocator || aAllocator->IsSameProcess()) {
|
if (!aAllocator || aAllocator->IsSameProcess()) {
|
||||||
return MemoryTextureData::Create(aSize, aFormat, aMoz2DBackend, aFlags,
|
return MemoryTextureData::Create(aSize, aFormat, aMoz2DBackend,
|
||||||
|
aLayersBackend, aFlags,
|
||||||
aAllocFlags, aAllocator);
|
aAllocFlags, aAllocator);
|
||||||
} else if (aAllocator->AsShmemAllocator()) {
|
} else if (aAllocator->AsShmemAllocator()) {
|
||||||
return ShmemTextureData::Create(aSize, aFormat, aMoz2DBackend, aFlags,
|
return ShmemTextureData::Create(aSize, aFormat, aMoz2DBackend,
|
||||||
|
aLayersBackend, aFlags,
|
||||||
aAllocFlags, aAllocator);
|
aAllocFlags, aAllocator);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -452,7 +459,8 @@ InitBuffer(uint8_t* buf, size_t bufSize,
|
|||||||
|
|
||||||
MemoryTextureData*
|
MemoryTextureData*
|
||||||
MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend, TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator)
|
ClientIPCAllocator* aAllocator)
|
||||||
{
|
{
|
||||||
@@ -474,10 +482,7 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fwd = aAllocator ? aAllocator->AsCompositableForwarder() : nullptr;
|
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||||
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat,
|
|
||||||
fwd->GetCompositorBackendType())
|
|
||||||
: true;
|
|
||||||
|
|
||||||
GfxMemoryImageReporter::DidAlloc(buf);
|
GfxMemoryImageReporter::DidAlloc(buf);
|
||||||
|
|
||||||
@@ -500,8 +505,13 @@ MemoryTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
|
|||||||
TextureFlags aFlags,
|
TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags) const
|
TextureAllocationFlags aAllocFlags) const
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aAllocator->AsCompositableForwarder());
|
||||||
|
|
||||||
|
LayersBackend backend =
|
||||||
|
aAllocator->AsCompositableForwarder()->GetCompositorBackendType();
|
||||||
|
|
||||||
return MemoryTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
|
return MemoryTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
|
||||||
aFlags, aAllocFlags, aAllocator);
|
backend, aFlags, aAllocFlags, aAllocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -519,7 +529,8 @@ ShmemTextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
|
|||||||
|
|
||||||
ShmemTextureData*
|
ShmemTextureData*
|
||||||
ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend, TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend, TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator)
|
ClientIPCAllocator* aAllocator)
|
||||||
{
|
{
|
||||||
@@ -551,10 +562,7 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto fwd = aAllocator->AsCompositableForwarder();
|
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||||
bool hasIntermediateBuffer = fwd ? ComputeHasIntermediateBuffer(aFormat,
|
|
||||||
fwd->GetCompositorBackendType())
|
|
||||||
: true;
|
|
||||||
|
|
||||||
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
|
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
|
||||||
|
|
||||||
@@ -568,8 +576,13 @@ ShmemTextureData::CreateSimilar(ClientIPCAllocator* aAllocator,
|
|||||||
TextureFlags aFlags,
|
TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags) const
|
TextureAllocationFlags aAllocFlags) const
|
||||||
{
|
{
|
||||||
|
MOZ_ASSERT(aAllocator->AsCompositableForwarder());
|
||||||
|
|
||||||
|
LayersBackend backend =
|
||||||
|
aAllocator->AsCompositableForwarder()->GetCompositorBackendType();
|
||||||
|
|
||||||
return ShmemTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
|
return ShmemTextureData::Create(GetSize(), GetFormat(), mMoz2DBackend,
|
||||||
aFlags, aAllocFlags, aAllocator);
|
backend, aFlags, aAllocFlags, aAllocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ class BufferTextureData : public TextureData
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
static BufferTextureData* Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||||
gfx::BackendType aMoz2DBackend,TextureFlags aFlags,
|
gfx::BackendType aMoz2DBackend,
|
||||||
|
LayersBackend aLayersBackend,
|
||||||
|
TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags,
|
TextureAllocationFlags aAllocFlags,
|
||||||
ClientIPCAllocator* aAllocator);
|
ClientIPCAllocator* aAllocator);
|
||||||
|
|
||||||
|
|||||||
@@ -1111,7 +1111,8 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
|
|||||||
|
|
||||||
// Can't do any better than a buffer texture client.
|
// Can't do any better than a buffer texture client.
|
||||||
return TextureClient::CreateForRawBufferAccess(aAllocator, aFormat, aSize,
|
return TextureClient::CreateForRawBufferAccess(aAllocator, aFormat, aSize,
|
||||||
moz2DBackend, aTextureFlags, aAllocFlags);
|
moz2DBackend, aLayersBackend,
|
||||||
|
aTextureFlags, aAllocFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
@@ -1184,6 +1185,22 @@ TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
|
|||||||
gfx::BackendType aMoz2DBackend,
|
gfx::BackendType aMoz2DBackend,
|
||||||
TextureFlags aTextureFlags,
|
TextureFlags aTextureFlags,
|
||||||
TextureAllocationFlags aAllocFlags)
|
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
|
// also test the validity of aAllocator
|
||||||
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
|
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
|
||||||
@@ -1206,8 +1223,8 @@ TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureData* texData = BufferTextureData::Create(aSize, aFormat, aMoz2DBackend,
|
TextureData* texData = BufferTextureData::Create(aSize, aFormat, aMoz2DBackend,
|
||||||
aTextureFlags, aAllocFlags,
|
aLayersBackend, aTextureFlags,
|
||||||
aAllocator);
|
aAllocFlags, aAllocator);
|
||||||
if (!texData) {
|
if (!texData) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -376,6 +376,16 @@ public:
|
|||||||
// Creates and allocates a TextureClient (can be accessed through raw
|
// Creates and allocates a TextureClient (can be accessed through raw
|
||||||
// pointers).
|
// pointers).
|
||||||
static already_AddRefed<TextureClient>
|
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,
|
CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
|
||||||
gfx::SurfaceFormat aFormat,
|
gfx::SurfaceFormat aFormat,
|
||||||
gfx::IntSize aSize,
|
gfx::IntSize aSize,
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ TextureClientPool::AllocateTextureClient()
|
|||||||
TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
|
TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
|
||||||
mFormat, mSize,
|
mFormat, mSize,
|
||||||
gfx::BackendType::NONE,
|
gfx::BackendType::NONE,
|
||||||
|
mBackend,
|
||||||
mFlags, ALLOC_DEFAULT);
|
mFlags, ALLOC_DEFAULT);
|
||||||
} else {
|
} else {
|
||||||
newClient =
|
newClient =
|
||||||
|
|||||||
@@ -225,7 +225,8 @@ TEST(Layers, TextureSerialization) {
|
|||||||
|
|
||||||
auto texData = BufferTextureData::Create(surface->GetSize(),
|
auto texData = BufferTextureData::Create(surface->GetSize(),
|
||||||
gfx::ImageFormatToSurfaceFormat(surface->Format()),
|
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);
|
ASSERT_TRUE(!!texData);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user