mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 973892 - part 2) Specify the moz2d backend when creating a TextureClient. r=Bas
This commit is contained in:
parent
dc64acd28e
commit
da82a09e89
@ -65,7 +65,9 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
: gfxContentType::COLOR_ALPHA;
|
||||
gfxImageFormat format
|
||||
= gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
|
||||
mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
|
||||
mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format),
|
||||
TEXTURE_FLAGS_DEFAULT,
|
||||
gfxPlatform::GetPlatform()->GetPreferredCanvasBackend());
|
||||
MOZ_ASSERT(mBuffer->AsTextureClientSurface());
|
||||
mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
|
||||
|
||||
@ -100,10 +102,12 @@ CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
||||
}
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
||||
CanvasClient2D::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags,
|
||||
gfx::BackendType aMoz2DBackend)
|
||||
{
|
||||
return CompositableClient::CreateBufferTextureClient(aFormat,
|
||||
mTextureInfo.mTextureFlags | aFlags);
|
||||
mTextureInfo.mTextureFlags | aFlags,
|
||||
aMoz2DBackend);
|
||||
}
|
||||
|
||||
CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder,
|
||||
|
@ -90,7 +90,8 @@ public:
|
||||
|
||||
virtual TemporaryRef<BufferTextureClient>
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT) MOZ_OVERRIDE;
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
|
||||
gfx::BackendType aMoz2DBackend = gfx::BackendType::NONE) MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnDetach() MOZ_OVERRIDE
|
||||
{
|
||||
|
@ -179,7 +179,8 @@ CompositableClient::CreateDeprecatedTextureClient(DeprecatedTextureClientType aD
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
TextureFlags aTextureFlags,
|
||||
gfx::BackendType aMoz2DBackend)
|
||||
{
|
||||
// XXX - Once bug 908196 is fixed, we can use gralloc textures here which will
|
||||
// improve performances of videos using SharedPlanarYCbCrImage on b2g.
|
||||
@ -192,10 +193,14 @@ CompositableClient::CreateBufferTextureClient(SurfaceFormat aFormat,
|
||||
// }
|
||||
//#endif
|
||||
if (gfxPlatform::GetPlatform()->PreferMemoryOverShmem()) {
|
||||
RefPtr<BufferTextureClient> result = new MemoryTextureClient(this, aFormat, aTextureFlags);
|
||||
RefPtr<BufferTextureClient> result = new MemoryTextureClient(this, aFormat,
|
||||
aMoz2DBackend,
|
||||
aTextureFlags);
|
||||
return result.forget();
|
||||
}
|
||||
RefPtr<BufferTextureClient> result = new ShmemTextureClient(this, aFormat, aTextureFlags);
|
||||
RefPtr<BufferTextureClient> result = new ShmemTextureClient(this, aFormat,
|
||||
aMoz2DBackend,
|
||||
aTextureFlags);
|
||||
return result.forget();
|
||||
}
|
||||
|
||||
@ -234,17 +239,26 @@ DisableGralloc(SurfaceFormat aFormat)
|
||||
|
||||
TemporaryRef<TextureClient>
|
||||
CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags)
|
||||
TextureFlags aTextureFlags,
|
||||
gfx::BackendType aMoz2DBackend)
|
||||
{
|
||||
if (aMoz2DBackend == gfx::BackendType::NONE) {
|
||||
aMoz2DBackend = gfxPlatform::GetPlatform()->GetContentBackend();
|
||||
}
|
||||
|
||||
RefPtr<TextureClient> result;
|
||||
|
||||
#ifdef XP_WIN
|
||||
LayersBackend parentBackend = GetForwarder()->GetCompositorBackendType();
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D11 && gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D11 &&
|
||||
(aMoz2DBackend == gfx::BackendType::DIRECT2D ||
|
||||
aMoz2DBackend == gfx::BackendType::DIRECT2D1_1) &&
|
||||
gfxWindowsPlatform::GetPlatform()->GetD2DDevice() &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
|
||||
result = new TextureClientD3D11(aFormat, aTextureFlags);
|
||||
}
|
||||
if (parentBackend == LayersBackend::LAYERS_D3D9 &&
|
||||
aMoz2DBackend == gfx::BackendType::CAIRO &&
|
||||
!GetForwarder()->ForwardsToDifferentProcess() &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK)) {
|
||||
if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
|
||||
@ -261,6 +275,7 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType();
|
||||
|
||||
if (parentBackend == LayersBackend::LAYERS_BASIC &&
|
||||
aMoz2DBackend == gfx::BackendType::CAIRO &&
|
||||
type == gfxSurfaceType::Xlib &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK))
|
||||
{
|
||||
@ -268,6 +283,7 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
}
|
||||
#ifdef GL_PROVIDER_GLX
|
||||
if (parentBackend == LayersBackend::LAYERS_OPENGL &&
|
||||
aMoz2DBackend == gfx::BackendType::CAIRO &&
|
||||
type == gfxSurfaceType::Xlib &&
|
||||
!(aTextureFlags & TEXTURE_ALLOC_FALLBACK) &&
|
||||
aFormat != SurfaceFormat::A8 &&
|
||||
@ -286,7 +302,7 @@ CompositableClient::CreateTextureClientForDrawing(SurfaceFormat aFormat,
|
||||
|
||||
// Can't do any better than a buffer texture client.
|
||||
if (!result) {
|
||||
result = CreateBufferTextureClient(aFormat, aTextureFlags);
|
||||
result = CreateBufferTextureClient(aFormat, aTextureFlags, aMoz2DBackend);
|
||||
}
|
||||
|
||||
MOZ_ASSERT(!result || result->AsTextureClientDrawTarget(),
|
||||
|
@ -84,15 +84,22 @@ public:
|
||||
CreateDeprecatedTextureClient(DeprecatedTextureClientType aDeprecatedTextureClientType,
|
||||
gfxContentType aContentType = gfxContentType::SENTINEL);
|
||||
|
||||
// Creates a TextureClient that can be mapped in memory and access through a
|
||||
// raw pointer.
|
||||
// Generally it is best to use CreateTextureClientForDrawing and draw into
|
||||
// the texture through Moz2D.
|
||||
virtual TemporaryRef<BufferTextureClient>
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT);
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
|
||||
gfx::BackendType aMoz2DBackend = gfx::BackendType::NONE);
|
||||
|
||||
// If we return a non-null TextureClient, then AsTextureClientDrawTarget will
|
||||
// always be non-null.
|
||||
// If aBackend is NONE, default to the content backend type.
|
||||
TemporaryRef<TextureClient>
|
||||
CreateTextureClientForDrawing(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aTextureFlags);
|
||||
TextureFlags aTextureFlags,
|
||||
gfx::BackendType aMoz2DBackend = gfx::BackendType::NONE);
|
||||
|
||||
virtual void SetDescriptorFromReply(TextureIdentifier aTextureId,
|
||||
const SurfaceDescriptor& aDescriptor)
|
||||
|
@ -311,9 +311,11 @@ ImageClientSingle::AddTextureClient(TextureClient* aTexture)
|
||||
}
|
||||
|
||||
TemporaryRef<BufferTextureClient>
|
||||
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
|
||||
ImageClientSingle::CreateBufferTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags,
|
||||
gfx::BackendType aMoz2DBackend)
|
||||
{
|
||||
return CompositableClient::CreateBufferTextureClient(aFormat, mTextureFlags | aFlags);
|
||||
return CompositableClient::CreateBufferTextureClient(aFormat, mTextureFlags | aFlags,
|
||||
aMoz2DBackend);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -92,7 +92,8 @@ public:
|
||||
|
||||
virtual TemporaryRef<BufferTextureClient>
|
||||
CreateBufferTextureClient(gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT) MOZ_OVERRIDE;
|
||||
TextureFlags aFlags = TEXTURE_FLAGS_DEFAULT,
|
||||
gfx::BackendType aMoz2DBackend = gfx::BackendType::NONE) MOZ_OVERRIDE;
|
||||
|
||||
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE;
|
||||
|
||||
|
@ -365,8 +365,9 @@ ShmemTextureClient::GetBufferSize() const
|
||||
|
||||
ShmemTextureClient::ShmemTextureClient(CompositableClient* aCompositable,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
gfx::BackendType aBackend,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureClient(aCompositable, aFormat, aFlags)
|
||||
: BufferTextureClient(aCompositable, aFormat, aBackend, aFlags)
|
||||
, mAllocated(false)
|
||||
{
|
||||
MOZ_COUNT_CTOR(ShmemTextureClient);
|
||||
@ -411,8 +412,9 @@ MemoryTextureClient::Allocate(uint32_t aSize)
|
||||
|
||||
MemoryTextureClient::MemoryTextureClient(CompositableClient* aCompositable,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
gfx::BackendType aBackend,
|
||||
TextureFlags aFlags)
|
||||
: BufferTextureClient(aCompositable, aFormat, aFlags)
|
||||
: BufferTextureClient(aCompositable, aFormat, aBackend, aFlags)
|
||||
, mBuffer(nullptr)
|
||||
, mBufSize(0)
|
||||
{
|
||||
@ -432,10 +434,12 @@ MemoryTextureClient::~MemoryTextureClient()
|
||||
|
||||
BufferTextureClient::BufferTextureClient(CompositableClient* aCompositable,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
gfx::BackendType aBackend,
|
||||
TextureFlags aFlags)
|
||||
: TextureClient(aFlags)
|
||||
, mCompositable(aCompositable)
|
||||
, mFormat(aFormat)
|
||||
, mBackend(aBackend)
|
||||
, mUsingFallbackDrawTarget(false)
|
||||
, mLocked(false)
|
||||
{}
|
||||
@ -538,15 +542,15 @@ BufferTextureClient::GetAsDrawTarget()
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mUsingFallbackDrawTarget == false);
|
||||
mDrawTarget = serializer.GetAsDrawTarget(gfxPlatform::GetPlatform()->GetContentBackend());
|
||||
mDrawTarget = serializer.GetAsDrawTarget(mBackend);
|
||||
if (mDrawTarget) {
|
||||
return mDrawTarget;
|
||||
}
|
||||
|
||||
// fallback path, probably because the Moz2D backend can't create a
|
||||
// DrawTarget around raw memory. This is going to be slow :(
|
||||
mDrawTarget = gfxPlatform::GetPlatform()->CreateOffscreenContentDrawTarget(
|
||||
serializer.GetSize(), serializer.GetFormat());
|
||||
mDrawTarget = gfx::Factory::CreateDrawTarget(mBackend, serializer.GetSize(),
|
||||
serializer.GetFormat());
|
||||
if (!mDrawTarget) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -341,7 +341,7 @@ class BufferTextureClient : public TextureClient
|
||||
{
|
||||
public:
|
||||
BufferTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags);
|
||||
gfx::BackendType aBackend, TextureFlags aFlags);
|
||||
|
||||
virtual ~BufferTextureClient();
|
||||
|
||||
@ -401,6 +401,7 @@ protected:
|
||||
CompositableClient* mCompositable;
|
||||
gfx::SurfaceFormat mFormat;
|
||||
gfx::IntSize mSize;
|
||||
gfx::BackendType mBackend;
|
||||
OpenMode mOpenMode;
|
||||
bool mUsingFallbackDrawTarget;
|
||||
bool mLocked;
|
||||
@ -414,7 +415,7 @@ class ShmemTextureClient : public BufferTextureClient
|
||||
{
|
||||
public:
|
||||
ShmemTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags);
|
||||
gfx::BackendType aBackend, TextureFlags aFlags);
|
||||
|
||||
~ShmemTextureClient();
|
||||
|
||||
@ -449,7 +450,7 @@ class MemoryTextureClient : public BufferTextureClient
|
||||
{
|
||||
public:
|
||||
MemoryTextureClient(CompositableClient* aCompositable, gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags);
|
||||
gfx::BackendType aBackend, TextureFlags aFlags);
|
||||
|
||||
~MemoryTextureClient();
|
||||
|
||||
|
@ -219,6 +219,7 @@ TEST(Layers, TextureSerialization) {
|
||||
RefPtr<TextureClient> client
|
||||
= new MemoryTextureClient(nullptr,
|
||||
mozilla::gfx::ImageFormatToSurfaceFormat(surface->Format()),
|
||||
gfx::BackendType::NONE,
|
||||
TEXTURE_DEALLOCATE_CLIENT);
|
||||
|
||||
TestTextureClientSurface(client, surface);
|
||||
@ -255,6 +256,7 @@ TEST(Layers, TextureYCbCrSerialization) {
|
||||
RefPtr<TextureClient> client
|
||||
= new MemoryTextureClient(nullptr,
|
||||
mozilla::gfx::SurfaceFormat::YUV,
|
||||
gfx::BackendType::NONE,
|
||||
TEXTURE_DEALLOCATE_CLIENT);
|
||||
|
||||
TestTextureClientYCbCr(client, clientData);
|
||||
|
Loading…
Reference in New Issue
Block a user