Remove the backend flag to TextureClient::CreateForDrawing. (bug 1183910 part 9, r=mattwoodrow)

This commit is contained in:
David Anderson
2015-08-06 02:41:07 -07:00
parent 0912270112
commit 062db27417
12 changed files with 46 additions and 33 deletions

View File

@@ -633,7 +633,7 @@ CairoImage::GetTextureClient(CompositableClient *aClient)
// gfx::BackendType::NONE means default to content backend // gfx::BackendType::NONE means default to content backend
textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(), textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(),
surface->GetSize(), surface->GetSize(),
gfx::BackendType::NONE, BackendSelector::Content,
TextureFlags::DEFAULT); TextureFlags::DEFAULT);
} }
if (!textureClient) { if (!textureClient) {

View File

@@ -126,14 +126,13 @@ CanvasClient2D::CreateTextureClientForCanvas(gfx::SurfaceFormat aFormat,
mTextureFlags | aFlags); mTextureFlags | aFlags);
} }
gfx::BackendType backend = gfxPlatform::GetPlatform()->GetPreferredCanvasBackend();
#ifdef XP_WIN #ifdef XP_WIN
return CreateTextureClientForDrawing(aFormat, aSize, backend, aFlags); return CreateTextureClientForDrawing(aFormat, aSize, BackendSelector::Canvas, aFlags);
#else #else
// XXX - We should use CreateTextureClientForDrawing, but we first need // XXX - We should use CreateTextureClientForDrawing, but we first need
// to use double buffering. // to use double buffering.
return TextureClient::CreateForRawBufferAccess(GetForwarder(), return TextureClient::CreateForRawBufferAccess(GetForwarder(),
aFormat, aSize, backend, aFormat, aSize, gfx::BackendType::NONE,
mTextureFlags | aFlags); mTextureFlags | aFlags);
#endif #endif
} }

View File

@@ -207,12 +207,12 @@ CompositableClient::CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat, CompositableClient::CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags) TextureAllocationFlags aAllocFlags)
{ {
return TextureClient::CreateForDrawing(GetForwarder(), return TextureClient::CreateForDrawing(GetForwarder(),
aFormat, aSize, aMoz2DBackend, aFormat, aSize, aSelector,
aTextureFlags | mTextureFlags, aTextureFlags | mTextureFlags,
aAllocFlags); aAllocFlags);
} }

View File

@@ -140,7 +140,7 @@ public:
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat, CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT); TextureAllocationFlags aAllocFlags = ALLOC_DEFAULT);

View File

@@ -293,7 +293,7 @@ ContentClientRemoteBuffer::CreateBackBuffer(const IntRect& aBufferRect)
{ {
// gfx::BackendType::NONE means fallback to the content backend // gfx::BackendType::NONE means fallback to the content backend
mTextureClient = CreateTextureClientForDrawing( mTextureClient = CreateTextureClientForDrawing(
mSurfaceFormat, mSize, gfx::BackendType::NONE, mSurfaceFormat, mSize, BackendSelector::Content,
mTextureFlags | ExtraTextureFlags(), mTextureFlags | ExtraTextureFlags(),
TextureAllocationFlags::ALLOC_CLEAR_BUFFER TextureAllocationFlags::ALLOC_CLEAR_BUFFER
); );

View File

@@ -216,7 +216,7 @@ ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlag
RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface(); RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
MOZ_ASSERT(surface); MOZ_ASSERT(surface);
texture = CreateTextureClientForDrawing(surface->GetFormat(), image->GetSize(), texture = CreateTextureClientForDrawing(surface->GetFormat(), image->GetSize(),
gfx::BackendType::NONE, mTextureFlags); BackendSelector::Content, mTextureFlags);
if (!texture) { if (!texture) {
return false; return false;
} }

View File

@@ -96,7 +96,7 @@ already_AddRefed<TextureClient>
ClientSingleTiledLayerBuffer::GetTextureClient() ClientSingleTiledLayerBuffer::GetTextureClient()
{ {
return mCompositableClient->CreateTextureClientForDrawing( return mCompositableClient->CreateTextureClientForDrawing(
gfx::ImageFormatToSurfaceFormat(mFormat), mSize, gfx::BackendType::NONE, gfx::ImageFormatToSurfaceFormat(mFormat), mSize, BackendSelector::Content,
TextureFlags::IMMEDIATE_UPLOAD); TextureFlags::IMMEDIATE_UPLOAD);
} }

View File

@@ -320,18 +320,30 @@ CreateBufferTextureClient(ISurfaceAllocator* aAllocator,
return result.forget(); return result.forget();
} }
static inline gfx::BackendType
BackendTypeForBackendSelector(BackendSelector aSelector)
{
switch (aSelector) {
case BackendSelector::Canvas:
return gfxPlatform::GetPlatform()->GetPreferredCanvasBackend();
case BackendSelector::Content:
return gfxPlatform::GetPlatform()->GetContentBackend();
default:
MOZ_ASSERT_UNREACHABLE("Unknown backend selector");
return gfx::BackendType::NONE;
}
};
// static // static
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator, TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags) TextureAllocationFlags aAllocFlags)
{ {
if (aMoz2DBackend == gfx::BackendType::NONE) { gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(aSelector);
aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend();
}
RefPtr<TextureClient> texture; RefPtr<TextureClient> texture;
@@ -342,15 +354,15 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
#ifdef XP_WIN #ifdef XP_WIN
LayersBackend parentBackend = aAllocator->GetCompositorBackendType(); LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
if (parentBackend == LayersBackend::LAYERS_D3D11 && if (parentBackend == LayersBackend::LAYERS_D3D11 &&
((aMoz2DBackend == gfx::BackendType::DIRECT2D && Factory::GetDirect3D10Device()) || (moz2DBackend == gfx::BackendType::DIRECT2D ||
(aMoz2DBackend == gfx::BackendType::DIRECT2D1_1 && Factory::GetDirect3D11Device())) && moz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
aSize.width <= maxTextureSize && aSize.width <= maxTextureSize &&
aSize.height <= maxTextureSize) aSize.height <= maxTextureSize)
{ {
texture = new TextureClientD3D11(aAllocator, aFormat, aTextureFlags); texture = new TextureClientD3D11(aAllocator, aFormat, aTextureFlags);
} }
if (parentBackend == LayersBackend::LAYERS_D3D9 && if (parentBackend == LayersBackend::LAYERS_D3D9 &&
aMoz2DBackend == gfx::BackendType::CAIRO && moz2DBackend == gfx::BackendType::CAIRO &&
aAllocator->IsSameProcess() && aAllocator->IsSameProcess() &&
aSize.width <= maxTextureSize && aSize.width <= maxTextureSize &&
aSize.height <= maxTextureSize && aSize.height <= maxTextureSize &&
@@ -362,7 +374,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
if (!texture && aFormat == SurfaceFormat::B8G8R8X8 && if (!texture && aFormat == SurfaceFormat::B8G8R8X8 &&
aAllocator->IsSameProcess() && aAllocator->IsSameProcess() &&
aMoz2DBackend == gfx::BackendType::CAIRO && moz2DBackend == gfx::BackendType::CAIRO &&
NS_IsMainThread()) { NS_IsMainThread()) {
if (aAllocator->IsSameProcess()) { if (aAllocator->IsSameProcess()) {
texture = new TextureClientMemoryDIB(aAllocator, aFormat, aTextureFlags); texture = new TextureClientMemoryDIB(aAllocator, aFormat, aTextureFlags);
@@ -378,7 +390,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType(); gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType();
if (parentBackend == LayersBackend::LAYERS_BASIC && if (parentBackend == LayersBackend::LAYERS_BASIC &&
aMoz2DBackend == gfx::BackendType::CAIRO && moz2DBackend == gfx::BackendType::CAIRO &&
type == gfxSurfaceType::Xlib) type == gfxSurfaceType::Xlib)
{ {
texture = new TextureClientX11(aAllocator, aFormat, aTextureFlags); texture = new TextureClientX11(aAllocator, aFormat, aTextureFlags);
@@ -399,7 +411,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
// Don't allow Gralloc texture clients to exceed the maximum texture size. // Don't allow Gralloc texture clients to exceed the maximum texture size.
// BufferTextureClients have code to handle tiling the surface client-side. // BufferTextureClients have code to handle tiling the surface client-side.
if (aSize.width <= maxTextureSize && aSize.height <= maxTextureSize) { if (aSize.width <= maxTextureSize && aSize.height <= maxTextureSize) {
texture = new GrallocTextureClientOGL(aAllocator, aFormat, aMoz2DBackend, texture = new GrallocTextureClientOGL(aAllocator, aFormat, moz2DBackend,
aTextureFlags); aTextureFlags);
} }
} }
@@ -420,7 +432,7 @@ TextureClient::CreateForDrawing(ISurfaceAllocator* aAllocator,
} }
// Can't do any better than a buffer texture client. // Can't do any better than a buffer texture client.
texture = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, aMoz2DBackend); texture = CreateBufferTextureClient(aAllocator, aFormat, aTextureFlags, moz2DBackend);
if (!texture->AllocateForSurface(aSize, aAllocFlags)) { if (!texture->AllocateForSurface(aSize, aAllocFlags)) {
return nullptr; return nullptr;

View File

@@ -138,6 +138,12 @@ protected:
virtual ~TextureReadbackSink() {} virtual ~TextureReadbackSink() {}
}; };
enum class BackendSelector
{
Content,
Canvas
};
/** /**
* TextureClient is a thin abstraction over texture data that need to be shared * TextureClient is a thin abstraction over texture data that need to be shared
* between the content process and the compositor process. It is the * between the content process and the compositor process. It is the
@@ -174,7 +180,7 @@ public:
CreateForDrawing(ISurfaceAllocator* aAllocator, CreateForDrawing(ISurfaceAllocator* aAllocator,
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags flags = ALLOC_DEFAULT); TextureAllocationFlags flags = ALLOC_DEFAULT);

View File

@@ -111,7 +111,7 @@ TextureClientPool::GetTextureClient()
TextureFlags::IMMEDIATE_UPLOAD, ALLOC_DEFAULT); TextureFlags::IMMEDIATE_UPLOAD, ALLOC_DEFAULT);
} else { } else {
textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator, textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator,
mFormat, mSize, gfx::BackendType::NONE, TextureFlags::IMMEDIATE_UPLOAD); mFormat, mSize, BackendSelector::Content, TextureFlags::IMMEDIATE_UPLOAD);
} }
mOutstandingClients++; mOutstandingClients++;

View File

@@ -34,7 +34,7 @@ public:
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
CreateOrRecycleForDrawing(gfx::SurfaceFormat aFormat, CreateOrRecycleForDrawing(gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags flags); TextureAllocationFlags flags);
@@ -141,7 +141,7 @@ already_AddRefed<TextureClient>
TextureClientRecycleAllocatorImp::CreateOrRecycleForDrawing( TextureClientRecycleAllocatorImp::CreateOrRecycleForDrawing(
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags) TextureAllocationFlags aAllocFlags)
{ {
@@ -154,10 +154,6 @@ TextureClientRecycleAllocatorImp::CreateOrRecycleForDrawing(
RefPtr<TextureClientHolder> textureHolder; RefPtr<TextureClientHolder> textureHolder;
if (aMoz2DBackend == gfx::BackendType::NONE) {
aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend();
}
{ {
MutexAutoLock lock(mLock); MutexAutoLock lock(mLock);
if (mDestroyed) { if (mDestroyed) {
@@ -183,7 +179,7 @@ TextureClientRecycleAllocatorImp::CreateOrRecycleForDrawing(
if (!textureHolder) { if (!textureHolder) {
// Allocate new TextureClient // Allocate new TextureClient
RefPtr<TextureClient> texture; RefPtr<TextureClient> texture;
texture = TextureClient::CreateForDrawing(this, aFormat, aSize, aMoz2DBackend, texture = TextureClient::CreateForDrawing(this, aFormat, aSize, aSelector,
aTextureFlags, aAllocFlags); aTextureFlags, aAllocFlags);
if (!texture) { if (!texture) {
return nullptr; return nullptr;
@@ -261,13 +257,13 @@ already_AddRefed<TextureClient>
TextureClientRecycleAllocator::CreateOrRecycleForDrawing( TextureClientRecycleAllocator::CreateOrRecycleForDrawing(
gfx::SurfaceFormat aFormat, gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2DBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags) TextureAllocationFlags aAllocFlags)
{ {
return mAllocator->CreateOrRecycleForDrawing(aFormat, return mAllocator->CreateOrRecycleForDrawing(aFormat,
aSize, aSize,
aMoz2DBackend, aSelector,
aTextureFlags, aTextureFlags,
aAllocFlags); aAllocFlags);
} }

View File

@@ -38,7 +38,7 @@ public:
already_AddRefed<TextureClient> already_AddRefed<TextureClient>
CreateOrRecycleForDrawing(gfx::SurfaceFormat aFormat, CreateOrRecycleForDrawing(gfx::SurfaceFormat aFormat,
gfx::IntSize aSize, gfx::IntSize aSize,
gfx::BackendType aMoz2dBackend, BackendSelector aSelector,
TextureFlags aTextureFlags, TextureFlags aTextureFlags,
TextureAllocationFlags flags = ALLOC_DEFAULT); TextureAllocationFlags flags = ALLOC_DEFAULT);