diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 46679b7460b..8cdac5cdb01 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -51,6 +51,12 @@ struct SurfaceDescriptorD3D10 { bool hasAlpha; }; +struct SurfaceDescriptorMacIOSurface { + uint32_t surface; + double scaleFactor; + bool hasAlpha; +}; + struct SharedTextureDescriptor { SharedTextureShareType shareType; SharedTextureHandle handle; @@ -176,6 +182,7 @@ union SurfaceDescriptor { SurfaceDescriptorX11; SharedTextureDescriptor; SurfaceStreamDescriptor; + SurfaceDescriptorMacIOSurface; NewSurfaceDescriptorGralloc; YCbCrImage; // XXX - deprecated SurfaceDescriptorGralloc; // XXX - deprecated diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp index b7c63d65c5e..038907ff69c 100644 --- a/gfx/layers/opengl/TextureClientOGL.cpp +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -66,7 +66,20 @@ SharedTextureClientOGL::IsAllocated() const return mHandle != 0; } - +#ifdef XP_MACOSX +bool +MacIOSurfaceTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) +{ + MOZ_ASSERT(IsValid()); + if (!IsAllocated()) { + return false; + } + aOutDescriptor = SurfaceDescriptorMacIOSurface(mSurface->GetIOSurfaceID(), + mSurface->GetContentsScaleFactor(), + mSurface->HasAlpha()); + return true; +} +#endif DeprecatedTextureClientSharedOGL::DeprecatedTextureClientSharedOGL(CompositableForwarder* aForwarder, const TextureInfo& aTextureInfo) diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index f60729ff959..ba19b228d45 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -13,6 +13,9 @@ #include "mozilla/layers/CompositorTypes.h" #include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor #include "mozilla/layers/TextureClient.h" // for DeprecatedTextureClient, etc +#ifdef XP_MACOSX +#include "mozilla/gfx/MacIOSurface.h" +#endif namespace mozilla { namespace layers { @@ -57,6 +60,44 @@ protected: bool mInverted; }; +#ifdef XP_MACOSX +class MacIOSurfaceTextureClientOGL : public TextureClient +{ +public: + MacIOSurfaceTextureClientOGL(TextureFlags aFlags) + : TextureClient(aFlags) + {} + + virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; } + + virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE; + + void InitWith(MacIOSurface* aSurface) + { + MOZ_ASSERT(IsValid()); + MOZ_ASSERT(!IsAllocated()); + mSurface = aSurface; + } + + virtual gfx::IntSize GetSize() const + { + return gfx::IntSize(mSurface->GetDevicePixelWidth(), mSurface->GetDevicePixelHeight()); + } + + virtual TextureClientData* DropTextureData() MOZ_OVERRIDE + { + // MacIOSurface has proper cross-process refcounting so we can just drop + // our reference now, and the data will stay alive (at least) until the host + // has also been torn down. + mSurface = nullptr; + MarkInvalid(); + return nullptr; + } + +protected: + RefPtr mSurface; +}; +#endif class DeprecatedTextureClientSharedOGL : public DeprecatedTextureClient {