From 358d2369f868cf62c8f3836d19cb7dce971cca4a Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 7 Jan 2014 17:20:22 +0100 Subject: [PATCH] Bug 900244 - Implement a shared D3D9 TextureClient. r=nical --- gfx/layers/d3d9/TextureD3D9.h | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/gfx/layers/d3d9/TextureD3D9.h b/gfx/layers/d3d9/TextureD3D9.h index baf2d95169c..6b7bc4f25ad 100644 --- a/gfx/layers/d3d9/TextureD3D9.h +++ b/gfx/layers/d3d9/TextureD3D9.h @@ -159,6 +159,55 @@ protected: bool mIterating; }; +class SharedTextureClientD3D9 : public TextureClient +{ +public: + SharedTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags) + : TextureClient(aFlags) + , mFormat(aFormat) + {} + + virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mTexture; } + + virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE + { + MOZ_ASSERT(IsValid()); + if (!IsAllocated()) { + return false; + } + + aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat); + return true; + } + + void InitWith(IDirect3DTexture9* aTexture, HANDLE aSharedHandle, D3DSURFACE_DESC aDesc) + { + MOZ_ASSERT(!mTexture); + mTexture = aTexture; + mHandle = aSharedHandle; + mDesc = aDesc; + } + + virtual gfx::IntSize GetSize() const + { + return gfx::IntSize(mDesc.Width, mDesc.Height); + } + + virtual TextureClientData* DropTextureData() MOZ_OVERRIDE + { + mTexture = nullptr; + MarkInvalid(); + return nullptr; + } + +private: + nsRefPtr mTexture; + gfx::SurfaceFormat mFormat; + HANDLE mHandle; + D3DSURFACE_DESC mDesc; +}; + + class CompositingRenderTargetD3D9 : public CompositingRenderTarget, public TextureSourceD3D9 {