Bug 1040028 - Create and allocate in one step when we used to call CreateBufferTextureClient and CreateTextureClientForDrawing. r=sotaro

This commit is contained in:
Nicolas Silva
2014-07-22 14:17:31 +02:00
parent 2fecae0cea
commit 208aa83c35
7 changed files with 90 additions and 58 deletions

View File

@@ -229,6 +229,25 @@ DisableGralloc(SurfaceFormat aFormat, const gfx::IntSize& aSizeHint)
}
#endif
static
TemporaryRef<BufferTextureClient>
CreateBufferTextureClient(ISurfaceAllocator* aAllocator,
SurfaceFormat aFormat,
TextureFlags aTextureFlags,
gfx::BackendType aMoz2DBackend)
{
if (aAllocator->IsSameProcess()) {
RefPtr<BufferTextureClient> result = new MemoryTextureClient(aAllocator, aFormat,
aMoz2DBackend,
aTextureFlags);
return result.forget();
}
RefPtr<BufferTextureClient> result = new ShmemTextureClient(aAllocator, aFormat,
aMoz2DBackend,
aTextureFlags);
return result.forget();
}
static
TemporaryRef<TextureClient>
CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
@@ -313,7 +332,7 @@ CreateTextureClientForDrawing(ISurfaceAllocator* aAllocator,
// Can't do any better than a buffer texture client.
if (!result) {
result = TextureClient::CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend);
result = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend);
}
MOZ_ASSERT(!result || result->CanExposeDrawTarget(), "texture cannot expose a DrawTarget?");
@@ -387,24 +406,29 @@ TextureClient::CreateForYCbCr(ISurfaceAllocator* aAllocator,
return texture;
}
// static
TemporaryRef<BufferTextureClient>
TextureClient::CreateBufferTextureClient(ISurfaceAllocator* aAllocator,
SurfaceFormat aFormat,
TextureFlags aTextureFlags,
gfx::BackendType aMoz2DBackend)
TextureClient::CreateWithBufferSize(ISurfaceAllocator* aAllocator,
gfx::SurfaceFormat aFormat,
size_t aSize,
TextureFlags aTextureFlags)
{
RefPtr<BufferTextureClient> texture;
if (aAllocator->IsSameProcess()) {
RefPtr<BufferTextureClient> result = new MemoryTextureClient(aAllocator, aFormat,
aMoz2DBackend,
aTextureFlags);
return result.forget();
texture = new MemoryTextureClient(aAllocator, gfx::SurfaceFormat::YUV,
gfx::BackendType::NONE,
aTextureFlags);
} else {
texture = new ShmemTextureClient(aAllocator, gfx::SurfaceFormat::YUV,
gfx::BackendType::NONE,
aTextureFlags);
}
RefPtr<BufferTextureClient> result = new ShmemTextureClient(aAllocator, aFormat,
aMoz2DBackend,
aTextureFlags);
return result.forget();
if (!texture->Allocate(aSize)) {
return nullptr;
}
return texture;
}
TextureClient::TextureClient(TextureFlags aFlags)