Don't wrap EGLImageKHR and EGLSyncKHR anymore

this simplify our EGL wrapper implementation a lot.
This wrapping is no longer needed now that we can only
support a single underlaying EGL implementation.

Change-Id: I8213df7ac69daac447f1fe6e37044b78aac4e9a9
This commit is contained in:
Mathias Agopian 2012-02-14 17:14:36 -08:00
parent f234ad0081
commit 7c0441ac27
9 changed files with 39 additions and 289 deletions

View File

@ -202,34 +202,6 @@ egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig,
// ----------------------------------------------------------------------------
EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image)
{
EGLContext context = egl_tls_t::getContext();
if (context == EGL_NO_CONTEXT || image == EGL_NO_IMAGE_KHR)
return EGL_NO_IMAGE_KHR;
egl_context_t const * const c = get_context(context);
if (c == NULL) // this should never happen, by construction
return EGL_NO_IMAGE_KHR;
egl_display_t* display = egl_display_t::get(c->dpy);
if (display == NULL) // this should never happen, by construction
return EGL_NO_IMAGE_KHR;
ImageRef _i(display, image);
if (!_i.get())
return EGL_NO_IMAGE_KHR;
// here we don't validate the context because if it's been marked for
// termination, this call should still succeed since it's internal to
// EGL.
egl_image_t const * const i = get_image(image);
return i->image;
}
// ----------------------------------------------------------------------------
const GLubyte * egl_get_string_for_current_context(GLenum name) {
// NOTE: returning NULL here will fall-back to the default
// implementation.

View File

@ -627,29 +627,6 @@ EGLint eglGetError(void)
return err;
}
// Note: Similar implementations of these functions also exist in
// gl2.cpp and gl.cpp, and are used by applications that call the
// exported entry points directly.
typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_impl = NULL;
static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_impl = NULL;
static void glEGLImageTargetTexture2DOES_wrapper(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
glEGLImageTargetTexture2DOES_impl(target, implImage);
}
static void glEGLImageTargetRenderbufferStorageOES_wrapper(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
glEGLImageTargetRenderbufferStorageOES_impl(target, implImage);
}
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
// eglGetProcAddress() could be the very first function called
@ -724,16 +701,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
if (found) {
addr = gExtensionForwarders[slot];
if (!strcmp(procname, "glEGLImageTargetTexture2DOES")) {
glEGLImageTargetTexture2DOES_impl = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)addr;
addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES_wrapper;
}
if (!strcmp(procname, "glEGLImageTargetRenderbufferStorageOES")) {
glEGLImageTargetRenderbufferStorageOES_impl = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)addr;
addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES_wrapper;
}
sGLExtentionMap.add(name, addr);
sGLExtentionSlot++;
}
@ -1024,57 +991,18 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_NO_IMAGE_KHR;
if (ctx != EGL_NO_CONTEXT) {
ContextRef _c(dp, ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
egl_context_t * const c = get_context(ctx);
// since we have an EGLContext, we know which implementation to use
EGLImageKHR image = c->cnx->egl.eglCreateImageKHR(
dp->disp.dpy, c->context, target, buffer, attrib_list);
if (image == EGL_NO_IMAGE_KHR)
return image;
egl_image_t* result = new egl_image_t(dpy, ctx);
result->image = image;
return (EGLImageKHR)result;
} else {
// EGL_NO_CONTEXT is a valid parameter
ContextRef _c(dp, ctx);
egl_context_t * const c = _c.get();
/* Since we don't have a way to know which implementation to call,
* we're calling all of them. If at least one of the implementation
* succeeded, this is a success.
*/
EGLint currentError = eglGetError();
EGLImageKHR implImage = EGL_NO_IMAGE_KHR;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateImageKHR) {
implImage = cnx->egl.eglCreateImageKHR(
dp->disp.dpy, ctx, target, buffer, attrib_list);
}
if (implImage == EGL_NO_IMAGE_KHR) {
// failure, if there was an error when we entered this function,
// the error flag must not be updated.
// Otherwise, the error is whatever happened in the implementation
// that faulted.
if (currentError != EGL_SUCCESS) {
setError(currentError, EGL_NO_IMAGE_KHR);
}
return EGL_NO_IMAGE_KHR;
} else {
// In case of success, we need to clear all error flags
// (especially those caused by the implementation that didn't
// succeed).
eglGetError();
}
egl_image_t* result = new egl_image_t(dpy, ctx);
result->image = implImage;
return (EGLImageKHR)result;
EGLImageKHR result = EGL_NO_IMAGE_KHR;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateImageKHR) {
result = cnx->egl.eglCreateImageKHR(
dp->disp.dpy,
c ? c->context : EGL_NO_CONTEXT,
target, buffer, attrib_list);
}
return result;
}
EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
@ -1084,27 +1012,10 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
ImageRef _i(dp, img);
if (!_i.get()) return setError(EGL_BAD_PARAMETER, EGL_FALSE);
egl_image_t* image = get_image(img);
bool success = false;
egl_connection_t* const cnx = &gEGLImpl;
if (image->image != EGL_NO_IMAGE_KHR) {
if (cnx->dso && cnx->egl.eglDestroyImageKHR) {
if (cnx->egl.eglDestroyImageKHR(
dp->disp.dpy, image->image)) {
success = true;
}
}
if (cnx->dso && cnx->egl.eglDestroyImageKHR) {
cnx->egl.eglDestroyImageKHR(dp->disp.dpy, img);
}
if (!success)
return EGL_FALSE;
_i.terminate();
return EGL_TRUE;
}
@ -1120,21 +1031,12 @@ EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_l
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_NO_SYNC_KHR;
EGLContext ctx = eglGetCurrentContext();
ContextRef _c(dp, ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_NO_SYNC_KHR);
egl_context_t * const c = get_context(ctx);
EGLSyncKHR result = EGL_NO_SYNC_KHR;
if (c->cnx->egl.eglCreateSyncKHR) {
EGLSyncKHR sync = c->cnx->egl.eglCreateSyncKHR(
dp->disp.dpy, type, attrib_list);
if (sync == EGL_NO_SYNC_KHR)
return sync;
result = (egl_sync_t*)new egl_sync_t(dpy, ctx, sync);
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglCreateSyncKHR) {
result = cnx->egl.eglCreateSyncKHR(dp->disp.dpy, type, attrib_list);
}
return (EGLSyncKHR)result;
return result;
}
EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
@ -1144,75 +1046,46 @@ EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SyncRef _s(dp, sync);
if (!_s.get()) return setError(EGL_BAD_PARAMETER, EGL_FALSE);
egl_sync_t* syncObject = get_sync(sync);
EGLContext ctx = syncObject->context;
ContextRef _c(dp, ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
EGLBoolean result = EGL_FALSE;
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglDestroySyncKHR) {
result = c->cnx->egl.eglDestroySyncKHR(
dp->disp.dpy, syncObject->sync);
if (result)
_s.terminate();
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglDestroySyncKHR) {
result = cnx->egl.eglDestroySyncKHR(dp->disp.dpy, sync);
}
return result;
}
EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync,
EGLint flags, EGLTimeKHR timeout)
{
clearError();
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SyncRef _s(dp, sync);
if (!_s.get()) return setError(EGL_BAD_PARAMETER, EGL_FALSE);
egl_sync_t* syncObject = get_sync(sync);
EGLContext ctx = syncObject->context;
ContextRef _c(dp, ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglClientWaitSyncKHR) {
return c->cnx->egl.eglClientWaitSyncKHR(
dp->disp.dpy, syncObject->sync, flags, timeout);
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglClientWaitSyncKHR) {
result = cnx->egl.eglClientWaitSyncKHR(
dp->disp.dpy, sync, flags, timeout);
}
return EGL_FALSE;
return result;
}
EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync,
EGLint attribute, EGLint *value)
{
clearError();
egl_display_t const * const dp = validate_display(dpy);
if (!dp) return EGL_FALSE;
SyncRef _s(dp, sync);
if (!_s.get())
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
egl_sync_t* syncObject = get_sync(sync);
EGLContext ctx = syncObject->context;
ContextRef _c(dp, ctx);
if (!_c.get())
return setError(EGL_BAD_CONTEXT, EGL_FALSE);
egl_context_t * const c = get_context(ctx);
if (c->cnx->egl.eglGetSyncAttribKHR) {
return c->cnx->egl.eglGetSyncAttribKHR(
dp->disp.dpy, syncObject->sync, attribute, value);
EGLBoolean result = EGL_FALSE;
egl_connection_t* const cnx = &gEGLImpl;
if (cnx->dso && cnx->egl.eglGetSyncAttribKHR) {
result = cnx->egl.eglGetSyncAttribKHR(
dp->disp.dpy, sync, attribute, value);
}
return EGL_FALSE;
return result;
}
// ----------------------------------------------------------------------------

View File

@ -173,40 +173,10 @@ public:
String8 gl_extensions;
};
class egl_image_t: public egl_object_t {
protected:
~egl_image_t() {}
public:
typedef egl_object_t::LocalRef<egl_image_t, EGLImageKHR> Ref;
egl_image_t(EGLDisplay dpy, EGLContext context) :
egl_object_t(get_display(dpy)),
dpy(dpy), context(context), image(EGL_NO_IMAGE_KHR) { }
EGLDisplay dpy;
EGLContext context;
EGLImageKHR image;
};
class egl_sync_t: public egl_object_t {
protected:
~egl_sync_t() {}
public:
typedef egl_object_t::LocalRef<egl_sync_t, EGLSyncKHR> Ref;
egl_sync_t(EGLDisplay dpy, EGLContext context, EGLSyncKHR sync) :
egl_object_t(get_display(dpy)), dpy(dpy), context(context), sync(sync) {
}
EGLDisplay dpy;
EGLContext context;
EGLSyncKHR sync;
};
// ----------------------------------------------------------------------------
typedef egl_surface_t::Ref SurfaceRef;
typedef egl_context_t::Ref ContextRef;
typedef egl_image_t::Ref ImageRef;
typedef egl_sync_t::Ref SyncRef;
// ----------------------------------------------------------------------------
@ -225,16 +195,6 @@ egl_context_t* get_context(EGLContext context) {
return egl_to_native_cast<egl_context_t>(context);
}
static inline
egl_image_t* get_image(EGLImageKHR image) {
return egl_to_native_cast<egl_image_t>(image);
}
static inline
egl_sync_t* get_sync(EGLSyncKHR sync) {
return egl_to_native_cast<egl_sync_t>(sync);
}
// ----------------------------------------------------------------------------
}; // namespace android
// ----------------------------------------------------------------------------

View File

@ -124,27 +124,3 @@ const GLubyte * glGetString(GLenum name)
}
return ret;
}
/*
* These GL calls are special because they need to EGL to retrieve some
* informations before they can execute.
*/
extern "C" void __glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
extern "C" void __glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
__glEGLImageTargetTexture2DOES(target, implImage);
}
void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
__glEGLImageTargetRenderbufferStorageOES(target, implImage);
}

View File

@ -1,7 +1,7 @@
void API_ENTRY(__glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
}
void API_ENTRY(__glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
}
void API_ENTRY(glGetProgramBinaryOES)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) {

View File

@ -179,27 +179,3 @@ const GLubyte * glGetString(GLenum name)
}
return ret;
}
/*
* These GL calls are special because they need to EGL to retrieve some
* informations before they can execute.
*/
extern "C" void __glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
extern "C" void __glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
__glEGLImageTargetTexture2DOES(target, implImage);
}
void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
{
GLeglImageOES implImage =
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
__glEGLImageTargetRenderbufferStorageOES(target, implImage);
}

View File

@ -31,10 +31,10 @@ void API_ENTRY(glDrawTexfOES)(GLfloat x, GLfloat y, GLfloat z, GLfloat width, GL
void API_ENTRY(glDrawTexfvOES)(const GLfloat *coords) {
CALL_GL_API(glDrawTexfvOES, coords);
}
void API_ENTRY(__glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
}
void API_ENTRY(__glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
}
void API_ENTRY(glAlphaFuncxOES)(GLenum func, GLclampx ref) {

View File

@ -30,7 +30,6 @@ namespace android {
// ----------------------------------------------------------------------------
EGLAPI const GLubyte * egl_get_string_for_current_context(GLenum name);
EGLAPI EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image);
// ----------------------------------------------------------------------------
}; // namespace android

View File

@ -37,12 +37,6 @@ while (my $line = <>) {
#printf("%s", $line);
my $prefix = "";
if ($name eq "glEGLImageTargetTexture2DOES") {
$prefix = "__";
}
if ($name eq "glEGLImageTargetRenderbufferStorageOES") {
$prefix = "__";
}
if ($name eq "glGetString") {
$prefix = "__";
}