Bug 762259 - Drop vendor suffixes from EGLImage for internal uses - r=bjacob

This commit is contained in:
Jeff Gilbert 2012-06-12 14:36:10 -07:00
parent fa0ec2aecb
commit 726669562c
7 changed files with 73 additions and 65 deletions

View File

@ -74,6 +74,7 @@ static const char *sExtensionNames[] = {
"GL_ARB_robustness",
"GL_EXT_robustness",
"GL_ARB_sync",
"GL_OES_EGL_image",
NULL
};
@ -461,6 +462,20 @@ GLContext::InitWithPrefix(const char *prefix, bool trygl)
mSymbols.fGetSynciv = nsnull;
}
}
if (IsExtensionSupported(OES_EGL_image)) {
SymLoadStruct imageSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fImageTargetTexture2D, { "glEGLImageTargetTexture2DOES", nsnull } },
{ nsnull, { nsnull } },
};
if (!LoadSymbols(&imageSymbols[0], trygl, prefix)) {
NS_ERROR("GL supports ARB_sync without supplying its functions.");
MarkExtensionUnsupported(OES_EGL_image);
mSymbols.fImageTargetTexture2D = nsnull;
}
}
// Load developer symbols, don't fail if we can't find them.
SymLoadStruct auxSymbols[] = {

View File

@ -1503,6 +1503,7 @@ public:
ARB_robustness,
EXT_robustness,
ARB_sync,
OES_EGL_image,
Extensions_Max
};
@ -3007,6 +3008,14 @@ public:
AFTER_GL_CALL;
}
// OES_EGL_image (GLES)
void fImageTargetTexture2D(GLenum target, GLeglImage image)
{
BEFORE_GL_CALL;
mSymbols.fImageTargetTexture2D(target, image);
AFTER_GL_CALL;
}
#ifdef DEBUG
void THEBES_API CreatedProgram(GLContext *aOrigin, GLuint aName);
void THEBES_API CreatedShader(GLContext *aOrigin, GLuint aName);

View File

@ -776,7 +776,7 @@ public:
, mSurface(nsnull)
, mConfig(nsnull)
, mTexture(aTexture)
, mImageKHR(nsnull)
, mEGLImage(nsnull)
, mTextureState(Created)
, mBound(false)
, mIsLocked(false)
@ -1104,7 +1104,7 @@ public:
LOCAL_EGL_NONE
};
sEGLLibrary.fLockSurfaceKHR(EGL_DISPLAY(), mSurface, lock_attribs);
sEGLLibrary.fLockSurface(EGL_DISPLAY(), mSurface, lock_attribs);
mIsLocked = true;
@ -1132,7 +1132,7 @@ public:
return;
}
sEGLLibrary.fUnlockSurfaceKHR(EGL_DISPLAY(), mSurface);
sEGLLibrary.fUnlockSurface(EGL_DISPLAY(), mSurface);
mIsLocked = false;
}
@ -1202,21 +1202,21 @@ public:
mConfig = nsnull;
if (sEGLLibrary.HasKHRImagePixmap() && sEGLLibrary.HasKHRImageTexture2D()) {
mImageKHR =
sEGLLibrary.fCreateImageKHR(EGL_DISPLAY(),
EGL_NO_CONTEXT,
LOCAL_EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)xsurface->XDrawable(),
NULL);
mEGLImage =
sEGLLibrary.fCreateImage(EGL_DISPLAY(),
EGL_NO_CONTEXT,
LOCAL_EGL_NATIVE_PIXMAP_KHR,
(EGLClientBuffer)xsurface->XDrawable(),
nsnull);
if (!mImageKHR) {
if (!mEGLImage) {
printf_stderr("couldn't create EGL image: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
return false;
}
mGLContext->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
sEGLLibrary.fImageTargetTexture2DOES(LOCAL_GL_TEXTURE_2D, mImageKHR);
sEGLLibrary.fDestroyImageKHR(EGL_DISPLAY(), mImageKHR);
mImageKHR = NULL;
mGLContext->fImageTargetTexture2D(LOCAL_GL_TEXTURE_2D, mEGLImage);
sEGLLibrary.fDestroyImage(EGL_DISPLAY(), mEGLImage);
mEGLImage = nsnull;
} else {
if (!CreateEGLSurface(xsurface)) {
printf_stderr("ProviderEGL Failed create EGL surface: ERROR (0x%04x)\n", sEGLLibrary.fGetError());
@ -1247,7 +1247,7 @@ protected:
EGLSurface mSurface;
EGLConfig mConfig;
GLuint mTexture;
EGLImageKHR mImageKHR;
EGLImage mEGLImage;
TextureState mTextureState;
bool mBound;

View File

@ -354,9 +354,7 @@ struct GLContextSymbols
typedef GLenum (GLAPIENTRY * PFNGLGETGRAPHICSRESETSTATUS) (void);
PFNGLGETGRAPHICSRESETSTATUS fGetGraphicsResetStatus;
/*
* ARB_sync extension
*/
// ARB_sync
typedef GLsync (GLAPIENTRY * PFNGLFENCESYNC) (GLenum condition, GLbitfield flags);
PFNGLFENCESYNC fFenceSync;
typedef realGLboolean (GLAPIENTRY * PFNGLISSYNC) (GLsync sync);
@ -371,6 +369,10 @@ struct GLContextSymbols
PFNGLGETINTEGER64V fGetInteger64v;
typedef void (GLAPIENTRY * PFNGLGETSYNCIV) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
PFNGLGETSYNCIV fGetSynciv;
// OES_egl_image
typedef void (GLAPIENTRY * PFNGLIMAGETARGETTEXTURE2D)(GLenum target, GLeglImage image);
PFNGLIMAGETARGETTEXTURE2D fImageTargetTexture2D;
};
}

View File

@ -40,10 +40,12 @@ typedef ptrdiff_t GLintptr;
#include "mozilla/StandardInteger.h"
// ARB_sync
typedef struct __GLsync *GLsync;
typedef struct __GLsync* GLsync;
typedef int64_t GLint64;
typedef uint64_t GLuint64;
// OES_EGL_image (GLES)
typedef void* GLeglImage;
#ifndef GLAPIENTRY
# ifdef WIN32

View File

@ -201,41 +201,36 @@ GLLibraryEGL::EnsureInitialized()
}
if (hasKHRImage) {
GLLibraryLoader::SymLoadStruct khrSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fCreateImageKHR, { "eglCreateImageKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fDestroyImageKHR, { "eglDestroyImageKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fImageTargetTexture2DOES, { "glEGLImageTargetTexture2DOES", NULL } },
GLLibraryLoader::SymLoadStruct imageSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fCreateImage, { "eglCreateImageKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fDestroyImage, { "eglDestroyImageKHR", NULL } },
{ NULL, { NULL } }
};
GLLibraryLoader::LoadSymbols(mEGLLibrary, &khrSymbols[0],
(GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress);
GLLibraryLoader::LoadSymbols(mEGLLibrary, &imageSymbols[0],
(GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress);
}
if (mHave_EGL_KHR_lock_surface) {
GLLibraryLoader::SymLoadStruct lockSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fLockSurfaceKHR, { "eglLockSurfaceKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fUnlockSurfaceKHR, { "eglUnlockSurfaceKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fLockSurface, { "eglLockSurfaceKHR", NULL } },
{ (PRFuncPtr*) &mSymbols.fUnlockSurface, { "eglUnlockSurfaceKHR", NULL } },
{ NULL, { NULL } }
};
GLLibraryLoader::LoadSymbols(mEGLLibrary, &lockSymbols[0],
(GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress);
if (!mSymbols.fLockSurfaceKHR) {
(GLLibraryLoader::PlatformLookupFunction)mSymbols.fGetProcAddress);
if (!mSymbols.fLockSurface) {
mHave_EGL_KHR_lock_surface = false;
}
}
if (!mSymbols.fCreateImageKHR) {
if (!mSymbols.fCreateImage) {
mHave_EGL_KHR_image_base = false;
mHave_EGL_KHR_image_pixmap = false;
mHave_EGL_KHR_gl_texture_2D_image = false;
}
if (!mSymbols.fImageTargetTexture2DOES) {
mHave_EGL_KHR_gl_texture_2D_image = false;
}
if (strstr(extensions, "EGL_ANGLE_surface_d3d_texture_2d_share_handle")) {
GLLibraryLoader::SymLoadStruct d3dSymbols[] = {
{ (PRFuncPtr*) &mSymbols.fQuerySurfacePointerANGLE, { "eglQuerySurfacePointerANGLE", NULL } },

View File

@ -23,8 +23,7 @@ typedef void *EGLDisplay;
typedef void *EGLSurface;
typedef void *EGLClientBuffer;
typedef void *EGLCastToRelevantPtr;
typedef void *EGLImageKHR;
typedef void *GLeglImageOES;
typedef void *EGLImage;
#if defined(XP_WIN)
@ -310,35 +309,35 @@ public:
return b;
}
EGLImageKHR fCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
EGLImage fCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
BEFORE_GL_CALL;
EGLImageKHR i = mSymbols.fCreateImageKHR(dpy, ctx, target, buffer, attrib_list);
EGLImage i = mSymbols.fCreateImage(dpy, ctx, target, buffer, attrib_list);
AFTER_GL_CALL;
return i;
}
EGLBoolean fDestroyImageKHR(EGLDisplay dpy, EGLImageKHR image)
EGLBoolean fDestroyImage(EGLDisplay dpy, EGLImage image)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fDestroyImageKHR(dpy, image);
EGLBoolean b = mSymbols.fDestroyImage(dpy, image);
AFTER_GL_CALL;
return b;
}
// New extension which allow us to lock texture and get raw image pointer
EGLBoolean fLockSurfaceKHR(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list)
EGLBoolean fLockSurface(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fLockSurfaceKHR(dpy, surface, attrib_list);
EGLBoolean b = mSymbols.fLockSurface(dpy, surface, attrib_list);
AFTER_GL_CALL;
return b;
}
EGLBoolean fUnlockSurfaceKHR(EGLDisplay dpy, EGLSurface surface)
EGLBoolean fUnlockSurface(EGLDisplay dpy, EGLSurface surface)
{
BEFORE_GL_CALL;
EGLBoolean b = mSymbols.fUnlockSurfaceKHR(dpy, surface);
EGLBoolean b = mSymbols.fUnlockSurface(dpy, surface);
AFTER_GL_CALL;
return b;
}
@ -359,15 +358,6 @@ public:
return b;
}
// This is EGL specific GL ext symbol "glEGLImageTargetTexture2DOES"
// Lets keep it here for now.
void fImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
BEFORE_GL_CALL;
mSymbols.fImageTargetTexture2DOES(target, image);
AFTER_GL_CALL;
}
EGLDisplay Display() {
return mEGLDisplay;
}
@ -456,26 +446,21 @@ public:
pfnBindTexImage fBindTexImage;
typedef EGLBoolean (GLAPIENTRY * pfnReleaseTexImage)(EGLDisplay, EGLSurface surface, EGLint buffer);
pfnReleaseTexImage fReleaseTexImage;
typedef EGLImageKHR (GLAPIENTRY * pfnCreateImageKHR)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
pfnCreateImageKHR fCreateImageKHR;
typedef EGLBoolean (GLAPIENTRY * pfnDestroyImageKHR)(EGLDisplay dpy, EGLImageKHR image);
pfnDestroyImageKHR fDestroyImageKHR;
typedef EGLImage (GLAPIENTRY * pfnCreateImage)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
pfnCreateImage fCreateImage;
typedef EGLBoolean (GLAPIENTRY * pfnDestroyImage)(EGLDisplay dpy, EGLImage image);
pfnDestroyImage fDestroyImage;
// New extension which allow us to lock texture and get raw image pointer
typedef EGLBoolean (GLAPIENTRY * pfnLockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
pfnLockSurfaceKHR fLockSurfaceKHR;
typedef EGLBoolean (GLAPIENTRY * pfnUnlockSurfaceKHR)(EGLDisplay dpy, EGLSurface surface);
pfnUnlockSurfaceKHR fUnlockSurfaceKHR;
typedef EGLBoolean (GLAPIENTRY * pfnLockSurface)(EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list);
pfnLockSurface fLockSurface;
typedef EGLBoolean (GLAPIENTRY * pfnUnlockSurface)(EGLDisplay dpy, EGLSurface surface);
pfnUnlockSurface fUnlockSurface;
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurface)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
pfnQuerySurface fQuerySurface;
typedef EGLBoolean (GLAPIENTRY * pfnQuerySurfacePointerANGLE)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value);
pfnQuerySurfacePointerANGLE fQuerySurfacePointerANGLE;
// This is EGL specific GL ext symbol "glEGLImageTargetTexture2DOES"
// Lets keep it here for now.
typedef void (GLAPIENTRY * pfnImageTargetTexture2DOES)(GLenum target, GLeglImageOES image);
pfnImageTargetTexture2DOES fImageTargetTexture2DOES;
} mSymbols;
private: