Skip to content
Permalink
Browse files

add missing parts of Bug 1138967 - Part 3

  • Loading branch information...
rmottola committed Jan 11, 2019
1 parent d8d834e commit f7dfd58658595b9c5251b9258c625a7eeebdfbf6
Showing with 97 additions and 14 deletions.
  1. +5 −14 gfx/layers/IMFYCbCrImage.h
  2. +92 −0 gfx/layers/d3d11/TextureD3D11.h
@@ -16,14 +16,12 @@ namespace layers {
class IMFYCbCrImage : public PlanarYCbCrImage
{
public:
IMFYCbCrImage(IMFMediaBuffer* aBuffer, IMF2DBuffer* a2DBuffer)
: PlanarYCbCrImage(nullptr)
, mBuffer(aBuffer)
, m2DBuffer(a2DBuffer)
{}
IMFYCbCrImage(IMFMediaBuffer* aBuffer, IMF2DBuffer* a2DBuffer);

virtual bool IsValid() { return true; }

virtual TextureClient* GetTextureClient(CompositableClient* aClient) MOZ_OVERRIDE;

protected:
virtual uint8_t* AllocateBuffer(uint32_t aSize) override {
MOZ_CRASH("Can't do manual allocations with IMFYCbCrImage");
@@ -32,18 +30,11 @@ class IMFYCbCrImage : public PlanarYCbCrImage

TextureClient* GetD3D9TextureClient(CompositableClient* aClient);

~IMFYCbCrImage()
{
if (m2DBuffer) {
m2DBuffer->Unlock2D();
}
else {
mBuffer->Unlock();
}
}
~IMFYCbCrImage();

RefPtr<IMFMediaBuffer> mBuffer;
RefPtr<IMF2DBuffer> m2DBuffer;
RefPtr<TextureClient> mTextureClient;
};

} // namepace layers
@@ -21,6 +21,59 @@ namespace layers {

class CompositorD3D11;

class DXGIYCbCrTextureClientD3D11 : public TextureClient
{
public:
DXGIYCbCrTextureClientD3D11(ISurfaceAllocator* aAllocator,
TextureFlags aFlags);

virtual ~DXGIYCbCrTextureClientD3D11();

// TextureClient

virtual bool IsAllocated() const MOZ_OVERRIDE{ return !!mTextures[0]; }

virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE;

virtual void Unlock() MOZ_OVERRIDE;

virtual bool IsLocked() const MOZ_OVERRIDE{ return mIsLocked; }

virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;

void InitWith(ID3D11Texture2D* aTextureY,
ID3D11Texture2D* aTextureCb,
ID3D11Texture2D* aTextureCr,
const gfx::IntSize& aSize)
{
MOZ_ASSERT(aTextureY && aTextureCb && aTextureCr);
MOZ_ASSERT(!mTextures[0]);
mTextures[0] = aTextureY;
mTextures[1] = aTextureCb;
mTextures[2] = aTextureCr;
mSize = aSize;
}

virtual gfx::IntSize GetSize() const
{
return mSize;
}

virtual bool HasInternalBuffer() const MOZ_OVERRIDE{ return true; }

// This TextureClient should not be used in a context where we use CreateSimilar
// (ex. component alpha) because the underlying texture data is always created by
// an external producer.
virtual TemporaryRef<TextureClient>
CreateSimilar(TextureFlags, TextureAllocationFlags) const MOZ_OVERRIDE{ return nullptr; }

private:
RefPtr<ID3D11Texture2D> mTextures[3];
gfx::IntSize mSize;
bool mIsLocked;
};


/**
* A TextureClient to share a D3D10 texture with the compositor thread.
* The corresponding TextureHost is DXGITextureHostD3D11
@@ -317,6 +370,45 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost
bool mIsLocked;
};

class DXGIYCbCrTextureHostD3D11 : public TextureHost

This comment has been minimized.

Copy link
@roytam1

roytam1 Jan 11, 2019

this duplicates L334-371

This comment has been minimized.

Copy link
@rmottola

rmottola Jan 22, 2019

Author Owner

What do you mean, Roy?

This comment has been minimized.

Copy link
@roytam1

roytam1 Jan 22, 2019

@rmottola

class DXGIYCbCrTextureHostD3D11 : public TextureHost
and
class DXGIYCbCrTextureHostD3D11 : public TextureHost
are the same, and duplicated class will break build.

This comment has been minimized.

Copy link
@rmottola

rmottola Jan 26, 2019

Author Owner

@roytam1 sorry, didn't get you meant "lines": I fixed that ! dumb copy&paste error because the patch had to be applied manually.

{
public:
DXGIYCbCrTextureHostD3D11(TextureFlags aFlags,
const SurfaceDescriptorDXGIYCbCr& aDescriptor);

virtual TextureSource* GetTextureSources() MOZ_OVERRIDE;

virtual void DeallocateDeviceData() MOZ_OVERRIDE{}

virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;

virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE{ return gfx::SurfaceFormat::YUV; }

virtual bool Lock() MOZ_OVERRIDE;

virtual void Unlock() MOZ_OVERRIDE;

virtual gfx::IntSize GetSize() const MOZ_OVERRIDE{ return mSize; }

virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
{
return nullptr;
}

protected:
ID3D11Device* GetDevice();

bool OpenSharedHandle();

RefPtr<ID3D11Texture2D> mTextures[3];
RefPtr<DataTextureSourceD3D11> mTextureSources[3];

RefPtr<CompositorD3D11> mCompositor;
gfx::IntSize mSize;
WindowsHandle mHandles[3];
bool mIsLocked;
};

class CompositingRenderTargetD3D11 : public CompositingRenderTarget,
public TextureSourceD3D11
{

0 comments on commit f7dfd58

Please sign in to comment.
You can’t perform that action at this time.