Bug 860615 - Add SharedTextureHandle support to GLContextCGL. r=jgilbert

This commit is contained in:
Matt Woodrow 2013-04-17 14:21:06 +12:00
parent ca690f5eec
commit 26c10d73fa
2 changed files with 46 additions and 1 deletions

View File

@ -439,6 +439,9 @@ public:
TextureID
#ifdef MOZ_WIDGET_ANDROID
, SurfaceTexture
#endif
#ifdef XP_MACOSX
, IOSurface
#endif
};

View File

@ -17,6 +17,7 @@
#include "prenv.h"
#include "mozilla/Preferences.h"
#include "GeckoProfiler.h"
#include "mozilla/gfx/MacIOSurface.h"
using namespace mozilla::gfx;
@ -177,6 +178,39 @@ public:
GLContext* aContext,
TextureImage::Flags aFlags = TextureImage::NoFlags);
virtual SharedTextureHandle CreateSharedHandle(SharedTextureShareType shareType,
void* buffer,
SharedTextureBufferType bufferType)
{
return GLContextProviderCGL::CreateSharedHandle(shareType, buffer, bufferType);
}
virtual void ReleaseSharedHandle(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
if (sharedHandle) {
reinterpret_cast<MacIOSurface*>(sharedHandle)->Release();
}
}
virtual bool GetSharedHandleDetails(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle,
SharedHandleDetails& details)
{
details.mTarget = LOCAL_GL_TEXTURE_RECTANGLE_ARB;
details.mProgramType = RGBARectLayerProgramType;
return true;
}
virtual bool AttachSharedHandle(SharedTextureShareType shareType,
SharedTextureHandle sharedHandle)
{
MacIOSurface* surf = reinterpret_cast<MacIOSurface*>(sharedHandle);
surf->CGLTexImageIOSurface2D(mContext, LOCAL_GL_RGBA, LOCAL_GL_BGRA,
LOCAL_GL_UNSIGNED_INT_8_8_8_8_REV, 0);
return true;
}
NSOpenGLContext *mContext;
GLuint mTempTextureName;
};
@ -419,7 +453,15 @@ GLContextProviderCGL::CreateSharedHandle(GLContext::SharedTextureShareType share
void* buffer,
GLContext::SharedTextureBufferType bufferType)
{
return 0;
if (shareType != GLContext::SameProcess ||
bufferType != GLContext::IOSurface) {
return 0;
}
MacIOSurface* surf = static_cast<MacIOSurface*>(buffer);
surf->AddRef();
return (SharedTextureHandle)surf;
}
void