@@ -627,29 +627,6 @@ EGLint eglGetError(void)
627627 return err;
628628}
629629
630- // Note: Similar implementations of these functions also exist in
631- // gl2.cpp and gl.cpp, and are used by applications that call the
632- // exported entry points directly.
633- typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image);
634- typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image);
635-
636- static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_impl = NULL ;
637- static PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC glEGLImageTargetRenderbufferStorageOES_impl = NULL ;
638-
639- static void glEGLImageTargetTexture2DOES_wrapper (GLenum target, GLeglImageOES image)
640- {
641- GLeglImageOES implImage =
642- (GLeglImageOES)egl_get_image_for_current_context ((EGLImageKHR)image);
643- glEGLImageTargetTexture2DOES_impl (target, implImage);
644- }
645-
646- static void glEGLImageTargetRenderbufferStorageOES_wrapper (GLenum target, GLeglImageOES image)
647- {
648- GLeglImageOES implImage =
649- (GLeglImageOES)egl_get_image_for_current_context ((EGLImageKHR)image);
650- glEGLImageTargetRenderbufferStorageOES_impl (target, implImage);
651- }
652-
653630__eglMustCastToProperFunctionPointerType eglGetProcAddress (const char *procname)
654631{
655632 // eglGetProcAddress() could be the very first function called
@@ -724,16 +701,6 @@ __eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
724701
725702 if (found) {
726703 addr = gExtensionForwarders [slot];
727-
728- if (!strcmp (procname, " glEGLImageTargetTexture2DOES" )) {
729- glEGLImageTargetTexture2DOES_impl = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)addr;
730- addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES_wrapper;
731- }
732- if (!strcmp (procname, " glEGLImageTargetRenderbufferStorageOES" )) {
733- glEGLImageTargetRenderbufferStorageOES_impl = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)addr;
734- addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES_wrapper;
735- }
736-
737704 sGLExtentionMap .add (name, addr);
738705 sGLExtentionSlot ++;
739706 }
@@ -1024,57 +991,18 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay dpy, EGLContext ctx, EGLenum target,
1024991 egl_display_t const * const dp = validate_display (dpy);
1025992 if (!dp) return EGL_NO_IMAGE_KHR;
1026993
1027- if (ctx != EGL_NO_CONTEXT) {
1028- ContextRef _c (dp, ctx);
1029- if (!_c.get ())
1030- return setError (EGL_BAD_CONTEXT, EGL_NO_IMAGE_KHR);
1031- egl_context_t * const c = get_context (ctx);
1032- // since we have an EGLContext, we know which implementation to use
1033- EGLImageKHR image = c->cnx ->egl .eglCreateImageKHR (
1034- dp->disp .dpy , c->context , target, buffer, attrib_list);
1035- if (image == EGL_NO_IMAGE_KHR)
1036- return image;
1037-
1038- egl_image_t * result = new egl_image_t (dpy, ctx);
1039- result->image = image;
1040- return (EGLImageKHR)result;
1041- } else {
1042- // EGL_NO_CONTEXT is a valid parameter
1043-
1044- /* Since we don't have a way to know which implementation to call,
1045- * we're calling all of them. If at least one of the implementation
1046- * succeeded, this is a success.
1047- */
1048-
1049- EGLint currentError = eglGetError ();
1050-
1051- EGLImageKHR implImage = EGL_NO_IMAGE_KHR;
1052- egl_connection_t * const cnx = &gEGLImpl ;
1053- if (cnx->dso && cnx->egl .eglCreateImageKHR ) {
1054- implImage = cnx->egl .eglCreateImageKHR (
1055- dp->disp .dpy , ctx, target, buffer, attrib_list);
1056- }
1057-
1058- if (implImage == EGL_NO_IMAGE_KHR) {
1059- // failure, if there was an error when we entered this function,
1060- // the error flag must not be updated.
1061- // Otherwise, the error is whatever happened in the implementation
1062- // that faulted.
1063- if (currentError != EGL_SUCCESS) {
1064- setError (currentError, EGL_NO_IMAGE_KHR);
1065- }
1066- return EGL_NO_IMAGE_KHR;
1067- } else {
1068- // In case of success, we need to clear all error flags
1069- // (especially those caused by the implementation that didn't
1070- // succeed).
1071- eglGetError ();
1072- }
994+ ContextRef _c (dp, ctx);
995+ egl_context_t * const c = _c.get ();
1073996
1074- egl_image_t * result = new egl_image_t (dpy, ctx);
1075- result->image = implImage;
1076- return (EGLImageKHR)result;
997+ EGLImageKHR result = EGL_NO_IMAGE_KHR;
998+ egl_connection_t * const cnx = &gEGLImpl ;
999+ if (cnx->dso && cnx->egl .eglCreateImageKHR ) {
1000+ result = cnx->egl .eglCreateImageKHR (
1001+ dp->disp .dpy ,
1002+ c ? c->context : EGL_NO_CONTEXT,
1003+ target, buffer, attrib_list);
10771004 }
1005+ return result;
10781006}
10791007
10801008EGLBoolean eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR img)
@@ -1084,27 +1012,10 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
10841012 egl_display_t const * const dp = validate_display (dpy);
10851013 if (!dp) return EGL_FALSE;
10861014
1087- ImageRef _i (dp, img);
1088- if (!_i.get ()) return setError (EGL_BAD_PARAMETER, EGL_FALSE);
1089-
1090- egl_image_t * image = get_image (img);
1091- bool success = false ;
1092-
10931015 egl_connection_t * const cnx = &gEGLImpl ;
1094- if (image->image != EGL_NO_IMAGE_KHR) {
1095- if (cnx->dso && cnx->egl .eglDestroyImageKHR ) {
1096- if (cnx->egl .eglDestroyImageKHR (
1097- dp->disp .dpy , image->image )) {
1098- success = true ;
1099- }
1100- }
1016+ if (cnx->dso && cnx->egl .eglDestroyImageKHR ) {
1017+ cnx->egl .eglDestroyImageKHR (dp->disp .dpy , img);
11011018 }
1102-
1103- if (!success)
1104- return EGL_FALSE;
1105-
1106- _i.terminate ();
1107-
11081019 return EGL_TRUE;
11091020}
11101021
@@ -1120,21 +1031,12 @@ EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_l
11201031 egl_display_t const * const dp = validate_display (dpy);
11211032 if (!dp) return EGL_NO_SYNC_KHR;
11221033
1123- EGLContext ctx = eglGetCurrentContext ();
1124- ContextRef _c (dp, ctx);
1125- if (!_c.get ())
1126- return setError (EGL_BAD_CONTEXT, EGL_NO_SYNC_KHR);
1127-
1128- egl_context_t * const c = get_context (ctx);
11291034 EGLSyncKHR result = EGL_NO_SYNC_KHR;
1130- if (c->cnx ->egl .eglCreateSyncKHR ) {
1131- EGLSyncKHR sync = c->cnx ->egl .eglCreateSyncKHR (
1132- dp->disp .dpy , type, attrib_list);
1133- if (sync == EGL_NO_SYNC_KHR)
1134- return sync;
1135- result = (egl_sync_t *)new egl_sync_t (dpy, ctx, sync);
1035+ egl_connection_t * const cnx = &gEGLImpl ;
1036+ if (cnx->dso && cnx->egl .eglCreateSyncKHR ) {
1037+ result = cnx->egl .eglCreateSyncKHR (dp->disp .dpy , type, attrib_list);
11361038 }
1137- return (EGLSyncKHR) result;
1039+ return result;
11381040}
11391041
11401042EGLBoolean eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync)
@@ -1144,75 +1046,46 @@ EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
11441046 egl_display_t const * const dp = validate_display (dpy);
11451047 if (!dp) return EGL_FALSE;
11461048
1147- SyncRef _s (dp, sync);
1148- if (!_s.get ()) return setError (EGL_BAD_PARAMETER, EGL_FALSE);
1149- egl_sync_t * syncObject = get_sync (sync);
1150-
1151- EGLContext ctx = syncObject->context ;
1152- ContextRef _c (dp, ctx);
1153- if (!_c.get ())
1154- return setError (EGL_BAD_CONTEXT, EGL_FALSE);
1155-
11561049 EGLBoolean result = EGL_FALSE;
1157- egl_context_t * const c = get_context (ctx);
1158- if (c->cnx ->egl .eglDestroySyncKHR ) {
1159- result = c->cnx ->egl .eglDestroySyncKHR (
1160- dp->disp .dpy , syncObject->sync );
1161- if (result)
1162- _s.terminate ();
1050+ egl_connection_t * const cnx = &gEGLImpl ;
1051+ if (cnx->dso && cnx->egl .eglDestroySyncKHR ) {
1052+ result = cnx->egl .eglDestroySyncKHR (dp->disp .dpy , sync);
11631053 }
11641054 return result;
11651055}
11661056
1167- EGLint eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
1057+ EGLint eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync,
1058+ EGLint flags, EGLTimeKHR timeout)
11681059{
11691060 clearError ();
11701061
11711062 egl_display_t const * const dp = validate_display (dpy);
11721063 if (!dp) return EGL_FALSE;
11731064
1174- SyncRef _s (dp, sync);
1175- if (!_s.get ()) return setError (EGL_BAD_PARAMETER, EGL_FALSE);
1176- egl_sync_t * syncObject = get_sync (sync);
1177-
1178- EGLContext ctx = syncObject->context ;
1179- ContextRef _c (dp, ctx);
1180- if (!_c.get ())
1181- return setError (EGL_BAD_CONTEXT, EGL_FALSE);
1182-
1183- egl_context_t * const c = get_context (ctx);
1184- if (c->cnx ->egl .eglClientWaitSyncKHR ) {
1185- return c->cnx ->egl .eglClientWaitSyncKHR (
1186- dp->disp .dpy , syncObject->sync , flags, timeout);
1065+ EGLBoolean result = EGL_FALSE;
1066+ egl_connection_t * const cnx = &gEGLImpl ;
1067+ if (cnx->dso && cnx->egl .eglClientWaitSyncKHR ) {
1068+ result = cnx->egl .eglClientWaitSyncKHR (
1069+ dp->disp .dpy , sync, flags, timeout);
11871070 }
1188-
1189- return EGL_FALSE;
1071+ return result;
11901072}
11911073
1192- EGLBoolean eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
1074+ EGLBoolean eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync,
1075+ EGLint attribute, EGLint *value)
11931076{
11941077 clearError ();
11951078
11961079 egl_display_t const * const dp = validate_display (dpy);
11971080 if (!dp) return EGL_FALSE;
11981081
1199- SyncRef _s (dp, sync);
1200- if (!_s.get ())
1201- return setError (EGL_BAD_PARAMETER, EGL_FALSE);
1202-
1203- egl_sync_t * syncObject = get_sync (sync);
1204- EGLContext ctx = syncObject->context ;
1205- ContextRef _c (dp, ctx);
1206- if (!_c.get ())
1207- return setError (EGL_BAD_CONTEXT, EGL_FALSE);
1208-
1209- egl_context_t * const c = get_context (ctx);
1210- if (c->cnx ->egl .eglGetSyncAttribKHR ) {
1211- return c->cnx ->egl .eglGetSyncAttribKHR (
1212- dp->disp .dpy , syncObject->sync , attribute, value);
1082+ EGLBoolean result = EGL_FALSE;
1083+ egl_connection_t * const cnx = &gEGLImpl ;
1084+ if (cnx->dso && cnx->egl .eglGetSyncAttribKHR ) {
1085+ result = cnx->egl .eglGetSyncAttribKHR (
1086+ dp->disp .dpy , sync, attribute, value);
12131087 }
1214-
1215- return EGL_FALSE;
1088+ return result;
12161089}
12171090
12181091// ----------------------------------------------------------------------------
0 commit comments