зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1053563 - Use a static create function to replace InitWith for TextureClient. r=nical
This commit is contained in:
Родитель
e9be5ee0b5
Коммит
b6a9cb595a
|
@ -43,12 +43,11 @@ TextureClient*
|
|||
D3D11ShareHandleImage::GetTextureClient(CompositableClient* aClient)
|
||||
{
|
||||
if (!mTextureClient) {
|
||||
RefPtr<TextureClientD3D11> textureClient =
|
||||
new TextureClientD3D11(aClient->GetForwarder(),
|
||||
mFormat,
|
||||
TextureFlags::DEFAULT);
|
||||
textureClient->InitWith(mTexture, mSize);
|
||||
mTextureClient = textureClient;
|
||||
mTextureClient = TextureClientD3D11::Create(aClient->GetForwarder(),
|
||||
mFormat,
|
||||
TextureFlags::DEFAULT,
|
||||
mTexture,
|
||||
mSize);
|
||||
}
|
||||
return mTextureClient;
|
||||
}
|
||||
|
|
|
@ -202,12 +202,12 @@ D3D9SurfaceImage::GetTextureClient(CompositableClient* aClient)
|
|||
{
|
||||
EnsureSynchronized();
|
||||
if (!mTextureClient) {
|
||||
RefPtr<SharedTextureClientD3D9> textureClient =
|
||||
new SharedTextureClientD3D9(aClient->GetForwarder(),
|
||||
gfx::SurfaceFormat::B8G8R8X8,
|
||||
TextureFlags::DEFAULT);
|
||||
textureClient->InitWith(mTexture, mShareHandle, mDesc);
|
||||
mTextureClient = textureClient;
|
||||
mTextureClient = SharedTextureClientD3D9::Create(aClient->GetForwarder(),
|
||||
gfx::SurfaceFormat::B8G8R8X8,
|
||||
TextureFlags::DEFAULT,
|
||||
mTexture,
|
||||
mShareHandle,
|
||||
mDesc);
|
||||
}
|
||||
return mTextureClient;
|
||||
}
|
||||
|
|
|
@ -190,12 +190,17 @@ IMFYCbCrImage::GetD3D9TextureClient(CompositableClient* aClient)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<DXGIYCbCrTextureClient> texClient =
|
||||
new DXGIYCbCrTextureClient(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
||||
texClient->InitWith(textureY, textureCb, textureCr,
|
||||
shareHandleY, shareHandleCb, shareHandleCr,
|
||||
GetSize(), mData.mYSize, mData.mCbCrSize);
|
||||
mTextureClient = texClient;
|
||||
mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(),
|
||||
TextureFlags::DEFAULT,
|
||||
textureY,
|
||||
textureCb,
|
||||
textureCr,
|
||||
shareHandleY,
|
||||
shareHandleCb,
|
||||
shareHandleCr,
|
||||
GetSize(),
|
||||
mData.mYSize,
|
||||
mData.mCbCrSize);
|
||||
|
||||
return mTextureClient;
|
||||
}
|
||||
|
@ -268,12 +273,17 @@ IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
|
|||
textureCr->QueryInterface((IDXGIResource**)byRef(resource));
|
||||
hr = resource->GetSharedHandle(&shareHandleCr);
|
||||
|
||||
RefPtr<DXGIYCbCrTextureClient> texClient =
|
||||
new DXGIYCbCrTextureClient(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
||||
texClient->InitWith(textureY, textureCb, textureCr,
|
||||
shareHandleY, shareHandleCb, shareHandleCr,
|
||||
GetSize(), mData.mYSize, mData.mCbCrSize);
|
||||
mTextureClient = texClient;
|
||||
mTextureClient = DXGIYCbCrTextureClient::Create(aClient->GetForwarder(),
|
||||
TextureFlags::DEFAULT,
|
||||
textureY,
|
||||
textureCb,
|
||||
textureCr,
|
||||
shareHandleY,
|
||||
shareHandleCb,
|
||||
shareHandleCr,
|
||||
GetSize(),
|
||||
mData.mYSize,
|
||||
mData.mCbCrSize);
|
||||
|
||||
return mTextureClient;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,9 @@ TextureClient*
|
|||
MacIOSurfaceImage::GetTextureClient(CompositableClient* aClient)
|
||||
{
|
||||
if (!mTextureClient) {
|
||||
RefPtr<MacIOSurfaceTextureClientOGL> buffer =
|
||||
new MacIOSurfaceTextureClientOGL(aClient->GetForwarder(), TextureFlags::DEFAULT);
|
||||
buffer->InitWith(mSurface);
|
||||
mTextureClient = buffer;
|
||||
mTextureClient = MacIOSurfaceTextureClientOGL::Create(aClient->GetForwarder(),
|
||||
TextureFlags::DEFAULT,
|
||||
mSurface);
|
||||
}
|
||||
return mTextureClient;
|
||||
}
|
||||
|
|
|
@ -212,6 +212,22 @@ TextureClientD3D11::~TextureClientD3D11()
|
|||
#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>
|
||||
TextureClientD3D11::CreateSimilar(TextureFlags aFlags,
|
||||
TextureAllocationFlags aAllocFlags) const
|
||||
|
@ -534,6 +550,34 @@ DXGIYCbCrTextureClient::~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
|
||||
DXGIYCbCrTextureClient::Lock(OpenMode)
|
||||
{
|
||||
|
|
|
@ -32,11 +32,13 @@ public:
|
|||
|
||||
virtual ~TextureClientD3D11();
|
||||
|
||||
void InitWith(ID3D11Texture2D* aTexture, const gfx::IntSize& aSize)
|
||||
{
|
||||
mTexture = aTexture;
|
||||
mSize = aSize;
|
||||
}
|
||||
// Creates a TextureClient and init width.
|
||||
static TemporaryRef<TextureClientD3D11>
|
||||
Create(ISurfaceAllocator* aAllocator,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
TextureFlags aFlags,
|
||||
ID3D11Texture2D* aTexture,
|
||||
gfx::IntSize aSize);
|
||||
|
||||
// TextureClient
|
||||
|
||||
|
@ -90,6 +92,20 @@ public:
|
|||
|
||||
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
|
||||
|
||||
virtual bool IsAllocated() const override{ return !!mHoldRefs[0]; }
|
||||
|
@ -102,27 +118,6 @@ public:
|
|||
|
||||
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
|
||||
{
|
||||
return mSize;
|
||||
|
|
|
@ -762,6 +762,29 @@ SharedTextureClientD3D9::~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
|
||||
SharedTextureClientD3D9::Lock(OpenMode)
|
||||
{
|
||||
|
|
|
@ -248,6 +248,15 @@ public:
|
|||
|
||||
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
|
||||
|
||||
virtual bool IsAllocated() const override { return !!mTexture; }
|
||||
|
@ -260,17 +269,6 @@ public:
|
|||
|
||||
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
|
||||
{
|
||||
return gfx::IntSize(mDesc.Width, mDesc.Height);
|
||||
|
|
|
@ -59,16 +59,6 @@ GrallocTextureClientOGL::CreateSimilar(TextureFlags aFlags,
|
|||
return tex;
|
||||
}
|
||||
|
||||
void
|
||||
GrallocTextureClientOGL::InitWith(MaybeMagicGrallocBufferHandle aHandle, gfx::IntSize aSize)
|
||||
{
|
||||
MOZ_ASSERT(!IsAllocated());
|
||||
MOZ_ASSERT(IsValid());
|
||||
mGrallocHandle = aHandle;
|
||||
mGraphicBuffer = GetGraphicBufferFrom(aHandle);
|
||||
mSize = aSize;
|
||||
}
|
||||
|
||||
bool
|
||||
GrallocTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
|
||||
{
|
||||
|
|
|
@ -60,8 +60,6 @@ public:
|
|||
|
||||
virtual void WaitForBufferOwnership(bool aWaitReleaseFence = true) override;
|
||||
|
||||
void InitWith(MaybeMagicGrallocBufferHandle aDesc, gfx::IntSize aSize);
|
||||
|
||||
void SetTextureFlags(TextureFlags aFlags) { AddFlags(aFlags); }
|
||||
|
||||
gfx::IntSize GetSize() const override { return mSize; }
|
||||
|
|
|
@ -22,12 +22,18 @@ MacIOSurfaceTextureClientOGL::~MacIOSurfaceTextureClientOGL()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
MacIOSurfaceTextureClientOGL::InitWith(MacIOSurface* aSurface)
|
||||
// static
|
||||
TemporaryRef<MacIOSurfaceTextureClientOGL>
|
||||
MacIOSurfaceTextureClientOGL::Create(ISurfaceAllocator* aAllocator,
|
||||
TextureFlags aFlags,
|
||||
MacIOSurface* aSurface)
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
MOZ_ASSERT(!IsAllocated());
|
||||
mSurface = aSurface;
|
||||
RefPtr<MacIOSurfaceTextureClientOGL> texture =
|
||||
new MacIOSurfaceTextureClientOGL(aAllocator, aFlags);
|
||||
MOZ_ASSERT(texture->IsValid());
|
||||
MOZ_ASSERT(!texture->IsAllocated());
|
||||
texture->mSurface = aSurface;
|
||||
return texture;
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
@ -21,7 +21,11 @@ public:
|
|||
|
||||
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;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче