Bug 887791 - Add a TextureClient implementation for MacIOSurface. r=nical

This commit is contained in:
Matt Woodrow 2013-11-01 14:54:14 +13:00
parent 5aa30ea720
commit a03577262a
3 changed files with 62 additions and 1 deletions

View File

@ -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

View File

@ -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)

View File

@ -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<MacIOSurface> mSurface;
};
#endif
class DeprecatedTextureClientSharedOGL : public DeprecatedTextureClient
{