Bug 1053563 - Use a static create function to replace InitWith for TextureClient. r=nical
This commit is contained in:
@@ -43,12 +43,11 @@ TextureClient*
|
|||||||
D3D11ShareHandleImage::GetTextureClient(CompositableClient* aClient)
|
D3D11ShareHandleImage::GetTextureClient(CompositableClient* aClient)
|
||||||
{
|
{
|
||||||
if (!mTextureClient) {
|
if (!mTextureClient) {
|
||||||
RefPtr<TextureClientD3D11> textureClient =
|
mTextureClient = TextureClientD3D11::Create(aClient->GetForwarder(),
|
||||||
new TextureClientD3D11(aClient->GetForwarder(),
|
|
||||||
mFormat,
|
mFormat,
|
||||||
TextureFlags::DEFAULT);
|
TextureFlags::DEFAULT,
|
||||||
textureClient->InitWith(mTexture, mSize);
|
mTexture,
|
||||||
mTextureClient = textureClient;
|
mSize);
|
||||||
}
|
}
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,12 +202,12 @@ D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
|
|||||||
{
|
{
|
||||||
EnsureSynchronized();
|
EnsureSynchronized();
|
||||||
if (!mTextureClient) {
|
if (!mTextureClient) {
|
||||||
RefPtr<SharedTextureClientD3D9> textureClient =
|
mTextureClient = SharedTextureClientD3D9::Create(aClient->GetForwarder(),
|
||||||
new SharedTextureClientD3D9(aClient->GetForwarder(),
|
|
||||||
gfx::SurfaceFormat::B8G8R8X8,
|
gfx::SurfaceFormat::B8G8R8X8,
|
||||||
TextureFlags::DEFAULT);
|
TextureFlags::DEFAULT,
|
||||||
textureClient->InitWith(mTexture, mShareHandle, mDesc);
|
mTexture,
|
||||||
mTextureClient = textureClient;
|
mShareHandle,
|
||||||
|
mDesc);
|
||||||
}
|
}
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,12 +190,17 @@ IMFYCbCrImage::GetD3D9TextureClient(CompositableClient* aClient)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<DXGIYCbCrTextureClient> texClient =
|
mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(),
|
||||||
new DXGIYCbCrTextureClient(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
TextureFlags::DEFAULT,
|
||||||
texClient->InitWith(textureY, textureCb, textureCr,
|
textureY,
|
||||||
shareHandleY, shareHandleCb, shareHandleCr,
|
textureCb,
|
||||||
GetSize(), mData.mYSize, mData.mCbCrSize);
|
textureCr,
|
||||||
mTextureClient = texClient;
|
shareHandleY,
|
||||||
|
shareHandleCb,
|
||||||
|
shareHandleCr,
|
||||||
|
GetSize(),
|
||||||
|
mData.mYSize,
|
||||||
|
mData.mCbCrSize);
|
||||||
|
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
@@ -268,12 +273,17 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
|
|||||||
textureCr->QueryInterface((IDXGIResource**)byRef(resource));
|
textureCr->QueryInterface((IDXGIResource**)byRef(resource));
|
||||||
hr = resource->GetSharedHandle(&shareHandleCr);
|
hr = resource->GetSharedHandle(&shareHandleCr);
|
||||||
|
|
||||||
RefPtr<DXGIYCbCrTextureClient> texClient =
|
mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(),
|
||||||
new DXGIYCbCrTextureClient(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
TextureFlags::DEFAULT,
|
||||||
texClient->InitWith(textureY, textureCb, textureCr,
|
textureY,
|
||||||
shareHandleY, shareHandleCb, shareHandleCr,
|
textureCb,
|
||||||
GetSize(), mData.mYSize, mData.mCbCrSize);
|
textureCr,
|
||||||
mTextureClient = texClient;
|
shareHandleY,
|
||||||
|
shareHandleCb,
|
||||||
|
shareHandleCr,
|
||||||
|
GetSize(),
|
||||||
|
mData.mYSize,
|
||||||
|
mData.mCbCrSize);
|
||||||
|
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ TextureClient*
|
|||||||
MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
|
MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
|
||||||
{
|
{
|
||||||
if (!mTextureClient) {
|
if (!mTextureClient) {
|
||||||
RefPtr<MacIOSurfaceTextureClientOGL> buffer =
|
mTextureClient = MacIOSurfaceTextureClientOGL::Create(aClient->GetForwarder(),
|
||||||
new MacIOSurfaceTextureClientOGL(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
TextureFlags::DEFAULT,
|
||||||
buffer->InitWith(mSurface);
|
mSurface);
|
||||||
mTextureClient = buffer;
|
|
||||||
}
|
}
|
||||||
return mTextureClient;
|
return mTextureClient;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,22 @@ TextureClientD3D11::~TextureClientD3D11()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
TemporaryRef<TextureClientD3D11>
|
||||||
|
TextureClientD3D11::Create(ISurfaceAllocator* aAllocator,
|
||||||
|
gfx::SurfaceFormat aFormat,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
ID3D11Texture2D* aTexture,
|
||||||
|
gfx::IntSize aSize)
|
||||||
|
{
|
||||||
|
RefPtr<TextureClientD3D11> texture = new TextureClientD3D11(aAllocator,
|
||||||
|
aFormat,
|
||||||
|
aFlags);
|
||||||
|
texture->mTexture = aTexture;
|
||||||
|
texture->mSize = aSize;
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
TemporaryRef<TextureClient>
|
TemporaryRef<TextureClient>
|
||||||
TextureClientD3D11::CreateSimilar(TextureFlags aFlags,
|
TextureClientD3D11::CreateSimilar(TextureFlags aFlags,
|
||||||
TextureAllocationFlags aAllocFlags) const
|
TextureAllocationFlags aAllocFlags) const
|
||||||
@@ -534,6 +550,34 @@ DXGIYCbCrTextureClient::~DXGIYCbCrTextureClient()
|
|||||||
MOZ_COUNT_DTOR(DXGIYCbCrTextureClient);
|
MOZ_COUNT_DTOR(DXGIYCbCrTextureClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
TemporaryRef<DXGIYCbCrTextureClient>
|
||||||
|
DXGIYCbCrTextureClient::Create(ISurfaceAllocator* aAllocator,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
IUnknown* aTextureY,
|
||||||
|
IUnknown* aTextureCb,
|
||||||
|
IUnknown* aTextureCr,
|
||||||
|
HANDLE aHandleY,
|
||||||
|
HANDLE aHandleCb,
|
||||||
|
HANDLE aHandleCr,
|
||||||
|
const gfx::IntSize& aSize,
|
||||||
|
const gfx::IntSize& aSizeY,
|
||||||
|
const gfx::IntSize& aSizeCbCr)
|
||||||
|
{
|
||||||
|
RefPtr<DXGIYCbCrTextureClient> texture =
|
||||||
|
new DXGIYCbCrTextureClient(aAllocator, aFlags);
|
||||||
|
texture->mHandles[0] = aHandleY;
|
||||||
|
texture->mHandles[1] = aHandleCb;
|
||||||
|
texture->mHandles[2] = aHandleCr;
|
||||||
|
texture->mHoldRefs[0] = aTextureY;
|
||||||
|
texture->mHoldRefs[1] = aTextureCb;
|
||||||
|
texture->mHoldRefs[2] = aTextureCr;
|
||||||
|
texture->mSize = aSize;
|
||||||
|
texture->mSizeY = aSizeY;
|
||||||
|
texture->mSizeCbCr = aSizeCbCr;
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DXGIYCbCrTextureClient::Lock(OpenMode)
|
DXGIYCbCrTextureClient::Lock(OpenMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,11 +32,13 @@ public:
|
|||||||
|
|
||||||
virtual ~TextureClientD3D11();
|
virtual ~TextureClientD3D11();
|
||||||
|
|
||||||
void InitWith(ID3D11Texture2D* aTexture, const gfx::IntSize& aSize)
|
// Creates a TextureClient and init width.
|
||||||
{
|
static TemporaryRef<TextureClientD3D11>
|
||||||
mTexture = aTexture;
|
Create(ISurfaceAllocator* aAllocator,
|
||||||
mSize = aSize;
|
gfx::SurfaceFormat aFormat,
|
||||||
}
|
TextureFlags aFlags,
|
||||||
|
ID3D11Texture2D* aTexture,
|
||||||
|
gfx::IntSize aSize);
|
||||||
|
|
||||||
// TextureClient
|
// TextureClient
|
||||||
|
|
||||||
@@ -90,6 +92,20 @@ public:
|
|||||||
|
|
||||||
virtual ~DXGIYCbCrTextureClient();
|
virtual ~DXGIYCbCrTextureClient();
|
||||||
|
|
||||||
|
// Creates a TextureClient and init width.
|
||||||
|
static TemporaryRef<DXGIYCbCrTextureClient>
|
||||||
|
Create(ISurfaceAllocator* aAllocator,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
IUnknown* aTextureY,
|
||||||
|
IUnknown* aTextureCb,
|
||||||
|
IUnknown* aTextureCr,
|
||||||
|
HANDLE aHandleY,
|
||||||
|
HANDLE aHandleCb,
|
||||||
|
HANDLE aHandleCr,
|
||||||
|
const gfx::IntSize& aSize,
|
||||||
|
const gfx::IntSize& aSizeY,
|
||||||
|
const gfx::IntSize& aSizeCbCr);
|
||||||
|
|
||||||
// TextureClient
|
// TextureClient
|
||||||
|
|
||||||
virtual bool IsAllocated() const override{ return !!mHoldRefs[0]; }
|
virtual bool IsAllocated() const override{ return !!mHoldRefs[0]; }
|
||||||
@@ -102,27 +118,6 @@ public:
|
|||||||
|
|
||||||
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
||||||
|
|
||||||
void InitWith(IUnknown* aTextureY,
|
|
||||||
IUnknown* aTextureCb,
|
|
||||||
IUnknown* aTextureCr,
|
|
||||||
HANDLE aHandleY,
|
|
||||||
HANDLE aHandleCb,
|
|
||||||
HANDLE aHandleCr,
|
|
||||||
const gfx::IntSize& aSize,
|
|
||||||
const gfx::IntSize& aSizeY,
|
|
||||||
const gfx::IntSize& aSizeCbCr)
|
|
||||||
{
|
|
||||||
mHandles[0] = aHandleY;
|
|
||||||
mHandles[1] = aHandleCb;
|
|
||||||
mHandles[2] = aHandleCr;
|
|
||||||
mHoldRefs[0] = aTextureY;
|
|
||||||
mHoldRefs[1] = aTextureCb;
|
|
||||||
mHoldRefs[2] = aTextureCr;
|
|
||||||
mSize = aSize;
|
|
||||||
mSizeY = aSizeY;
|
|
||||||
mSizeCbCr = aSizeCbCr;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual gfx::IntSize GetSize() const
|
virtual gfx::IntSize GetSize() const
|
||||||
{
|
{
|
||||||
return mSize;
|
return mSize;
|
||||||
|
|||||||
@@ -762,6 +762,29 @@ SharedTextureClientD3D9::~SharedTextureClientD3D9()
|
|||||||
MOZ_COUNT_DTOR(SharedTextureClientD3D9);
|
MOZ_COUNT_DTOR(SharedTextureClientD3D9);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
TemporaryRef<SharedTextureClientD3D9>
|
||||||
|
SharedTextureClientD3D9::Create(ISurfaceAllocator* aAllocator,
|
||||||
|
gfx::SurfaceFormat aFormat,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
IDirect3DTexture9* aTexture,
|
||||||
|
HANDLE aSharedHandle,
|
||||||
|
D3DSURFACE_DESC aDesc)
|
||||||
|
{
|
||||||
|
RefPtr<SharedTextureClientD3D9> texture =
|
||||||
|
new SharedTextureClientD3D9(aAllocator,
|
||||||
|
aFormat,
|
||||||
|
aFlags);
|
||||||
|
MOZ_ASSERT(!texture->mTexture);
|
||||||
|
texture->mTexture = aTexture;
|
||||||
|
texture->mHandle = aSharedHandle;
|
||||||
|
texture->mDesc = aDesc;
|
||||||
|
if (texture->mTexture) {
|
||||||
|
gfxWindowsPlatform::sD3D9SharedTextureUsed += texture->mDesc.Width * texture->mDesc.Height * 4;
|
||||||
|
}
|
||||||
|
return texture;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SharedTextureClientD3D9::Lock(OpenMode)
|
SharedTextureClientD3D9::Lock(OpenMode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -248,6 +248,15 @@ public:
|
|||||||
|
|
||||||
virtual ~SharedTextureClientD3D9();
|
virtual ~SharedTextureClientD3D9();
|
||||||
|
|
||||||
|
// Creates a TextureClient and init width.
|
||||||
|
static TemporaryRef<SharedTextureClientD3D9>
|
||||||
|
Create(ISurfaceAllocator* aAllocator,
|
||||||
|
gfx::SurfaceFormat aFormat,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
IDirect3DTexture9* aTexture,
|
||||||
|
HANDLE aSharedHandle,
|
||||||
|
D3DSURFACE_DESC aDesc);
|
||||||
|
|
||||||
// TextureClient
|
// TextureClient
|
||||||
|
|
||||||
virtual bool IsAllocated() const override { return !!mTexture; }
|
virtual bool IsAllocated() const override { return !!mTexture; }
|
||||||
@@ -260,17 +269,6 @@ public:
|
|||||||
|
|
||||||
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) override;
|
||||||
|
|
||||||
void InitWith(IDirect3DTexture9* aTexture, HANDLE aSharedHandle, D3DSURFACE_DESC aDesc)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!mTexture);
|
|
||||||
mTexture = aTexture;
|
|
||||||
mHandle = aSharedHandle;
|
|
||||||
mDesc = aDesc;
|
|
||||||
if (mTexture) {
|
|
||||||
gfxWindowsPlatform::sD3D9SharedTextureUsed += mDesc.Width * mDesc.Height * 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual gfx::IntSize GetSize() const
|
virtual gfx::IntSize GetSize() const
|
||||||
{
|
{
|
||||||
return gfx::IntSize(mDesc.Width, mDesc.Height);
|
return gfx::IntSize(mDesc.Width, mDesc.Height);
|
||||||
|
|||||||
@@ -59,16 +59,6 @@ GrallocTextureClientOGL::CreateSimilar(TextureFlags aFlags,
|
|||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
GrallocTextureClientOGL::InitWith(MaybeMagicGrallocBufferHandle aHandle, gfx::IntSize aSize)
|
|
||||||
{
|
|
||||||
MOZ_ASSERT(!IsAllocated());
|
|
||||||
MOZ_ASSERT(IsValid());
|
|
||||||
mGrallocHandle = aHandle;
|
|
||||||
mGraphicBuffer = GetGraphicBufferFrom(aHandle);
|
|
||||||
mSize = aSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
GrallocTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
GrallocTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ public:
|
|||||||
|
|
||||||
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) override;
|
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) override;
|
||||||
|
|
||||||
void InitWith(MaybeMagicGrallocBufferHandle aDesc, gfx::IntSize aSize);
|
|
||||||
|
|
||||||
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }
|
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }
|
||||||
|
|
||||||
gfx::IntSize GetSize() const override { return mSize; }
|
gfx::IntSize GetSize() const override { return mSize; }
|
||||||
|
|||||||
@@ -22,12 +22,18 @@ MacIOSurfaceTextureClientOGL::~MacIOSurfaceTextureClientOGL()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
// static
|
||||||
MacIOSurfaceTextureClientOGL::InitWith(MacIOSurface* aSurface)
|
TemporaryRef<MacIOSurfaceTextureClientOGL>
|
||||||
|
MacIOSurfaceTextureClientOGL::Create(ISurfaceAllocator* aAllocator,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
MacIOSurface* aSurface)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(IsValid());
|
RefPtr<MacIOSurfaceTextureClientOGL> texture =
|
||||||
MOZ_ASSERT(!IsAllocated());
|
new MacIOSurfaceTextureClientOGL(aAllocator, aFlags);
|
||||||
mSurface = aSurface;
|
MOZ_ASSERT(texture->IsValid());
|
||||||
|
MOZ_ASSERT(!texture->IsAllocated());
|
||||||
|
texture->mSurface = aSurface;
|
||||||
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -21,7 +21,11 @@ public:
|
|||||||
|
|
||||||
virtual ~MacIOSurfaceTextureClientOGL();
|
virtual ~MacIOSurfaceTextureClientOGL();
|
||||||
|
|
||||||
void InitWith(MacIOSurface* aSurface);
|
// Creates a TextureClient and init width.
|
||||||
|
static TemporaryRef<MacIOSurfaceTextureClientOGL>
|
||||||
|
Create(ISurfaceAllocator* aAllocator,
|
||||||
|
TextureFlags aFlags,
|
||||||
|
MacIOSurface* aSurface);
|
||||||
|
|
||||||
virtual bool Lock(OpenMode aMode) override;
|
virtual bool Lock(OpenMode aMode) override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user