Bug 1265824 - Pass the texture direct mapping info to all texture creating functions r=mattwoodrow

The client side can't get the GL context in CompositorOGL. So, it can't know
the texture direct mapping capability directly. This patch adds the texture
direct mapping info in TextureFactoryIdentifier. Then, the client side could
get the info form the TextureFactoryIdentifier.

MozReview-Commit-ID: KEazDVg0p9Y
This commit is contained in:
Doug Thayer
2018-05-02 18:20:25 -07:00
parent f6c2a5f203
commit cfaa7181b8
14 changed files with 92 additions and 12 deletions

View File

@@ -660,7 +660,9 @@ TextureClient::UpdateFromSurface(gfx::SourceSurface* aSurface)
already_AddRefed<TextureClient>
TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
TextureClient::CreateSimilar(LayersBackend aLayersBackend,
TextureFlags aFlags,
TextureAllocationFlags aAllocFlags) const
{
MOZ_ASSERT(IsValid());
@@ -670,7 +672,10 @@ TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags,
}
LockActor();
TextureData* data = mData->CreateSimilar(mAllocator, aLayersBackend, aFlags, aAllocFlags);
TextureData* data = mData->CreateSimilar(mAllocator,
aLayersBackend,
aFlags,
aAllocFlags);
UnlockActor();
if (!data) {
@@ -1060,6 +1065,9 @@ TextureClient::CreateForDrawing(KnowsCompositor* aAllocator,
TextureAllocationFlags aAllocFlags)
{
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
if (aAllocator->SupportsTextureDirectMapping()) {
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
}
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
aFormat, aSize,
layersBackend,
@@ -1226,6 +1234,16 @@ TextureClient::CreateForRawBufferAccess(KnowsCompositor* aAllocator,
TextureFlags aTextureFlags,
TextureAllocationFlags aAllocFlags)
{
// If we exceed the max texture size for the GPU, then just fall back to no
// texture direct mapping. If it becomes a problem we can implement tiling
// logic inside DirectMapTextureSource to allow this.
bool supportsTextureDirectMapping = aAllocator->SupportsTextureDirectMapping() &&
std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize();
if (supportsTextureDirectMapping) {
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
} else {
aAllocFlags = TextureAllocationFlags(aAllocFlags & ~ALLOC_ALLOW_DIRECT_MAPPING);
}
return CreateForRawBufferAccess(aAllocator->GetTextureForwarder(),
aFormat, aSize, aMoz2DBackend,
aAllocator->GetCompositorBackendType(),