Bug 1289640 - Part 4: Make SourceSurfaceImage::GetTextureClient use the threadsafe upload with D3D11 so that we no longer rely on having a separate device. r=nical
This commit is contained in:
@@ -1106,6 +1106,68 @@ TextureClient::CreateForDrawing(TextureForwarder* aAllocator,
|
||||
moz2DBackend, aTextureFlags, aAllocFlags);
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<TextureClient>
|
||||
TextureClient::CreateFromSurface(TextureForwarder* aAllocator,
|
||||
gfx::SourceSurface* aSurface,
|
||||
LayersBackend aLayersBackend,
|
||||
BackendSelector aSelector,
|
||||
TextureFlags aTextureFlags,
|
||||
TextureAllocationFlags aAllocFlags)
|
||||
{
|
||||
aAllocator = aAllocator->AsTextureForwarder();
|
||||
|
||||
gfx::BackendType moz2DBackend = BackendTypeForBackendSelector(aLayersBackend, aSelector);
|
||||
|
||||
// also test the validity of aAllocator
|
||||
MOZ_ASSERT(aAllocator && aAllocator->IPCOpen());
|
||||
if (!aAllocator || !aAllocator->IPCOpen()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gfx::IntSize size = aSurface->GetSize();
|
||||
|
||||
if (!gfx::Factory::AllowedSurfaceSize(size)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextureData* data = nullptr;
|
||||
#if defined(XP_WIN)
|
||||
int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
|
||||
|
||||
if (aLayersBackend == LayersBackend::LAYERS_D3D11 &&
|
||||
(moz2DBackend == gfx::BackendType::DIRECT2D ||
|
||||
moz2DBackend == gfx::BackendType::DIRECT2D1_1 ||
|
||||
(!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
|
||||
DeviceManagerD3D11::Get()->GetContentDevice())) &&
|
||||
size.width <= maxTextureSize &&
|
||||
size.height <= maxTextureSize)
|
||||
{
|
||||
data = D3D11TextureData::Create(aSurface, aAllocFlags);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data) {
|
||||
return MakeAndAddRef<TextureClient>(data, aTextureFlags, aAllocator);
|
||||
}
|
||||
|
||||
// Fall back to using UpdateFromSurface
|
||||
|
||||
RefPtr<TextureClient> client = CreateForDrawing(aAllocator, aSurface->GetFormat(), size,
|
||||
aLayersBackend, aSelector, aTextureFlags, aAllocFlags);
|
||||
if (!client) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
TextureClientAutoLock autoLock(client, OpenMode::OPEN_WRITE_ONLY);
|
||||
if (!autoLock.Succeeded()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
client->UpdateFromSurface(aSurface);
|
||||
return client.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<TextureClient>
|
||||
TextureClient::CreateForRawBufferAccess(ClientIPCAllocator* aAllocator,
|
||||
|
||||
Reference in New Issue
Block a user