Skip to content

Commit 70579d5

Browse files
pixelflingerAndroid (Google) Code Review
authored andcommitted
Merge "Don't wrap EGLImageKHR and EGLSyncKHR anymore"
2 parents 91ec0b7 + 508c165 commit 70579d5

File tree

9 files changed

+39
-289
lines changed

9 files changed

+39
-289
lines changed

opengl/libs/EGL/egl.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -202,34 +202,6 @@ egl_connection_t* validate_display_config(EGLDisplay dpy, EGLConfig,
202202

203203
// ----------------------------------------------------------------------------
204204

205-
EGLImageKHR egl_get_image_for_current_context(EGLImageKHR image)
206-
{
207-
EGLContext context = egl_tls_t::getContext();
208-
if (context == EGL_NO_CONTEXT || image == EGL_NO_IMAGE_KHR)
209-
return EGL_NO_IMAGE_KHR;
210-
211-
egl_context_t const * const c = get_context(context);
212-
if (c == NULL) // this should never happen, by construction
213-
return EGL_NO_IMAGE_KHR;
214-
215-
egl_display_t* display = egl_display_t::get(c->dpy);
216-
if (display == NULL) // this should never happen, by construction
217-
return EGL_NO_IMAGE_KHR;
218-
219-
ImageRef _i(display, image);
220-
if (!_i.get())
221-
return EGL_NO_IMAGE_KHR;
222-
223-
// here we don't validate the context because if it's been marked for
224-
// termination, this call should still succeed since it's internal to
225-
// EGL.
226-
227-
egl_image_t const * const i = get_image(image);
228-
return i->image;
229-
}
230-
231-
// ----------------------------------------------------------------------------
232-
233205
const GLubyte * egl_get_string_for_current_context(GLenum name) {
234206
// NOTE: returning NULL here will fall-back to the default
235207
// implementation.

opengl/libs/EGL/eglApi.cpp

Lines changed: 35 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -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

10801008
EGLBoolean 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

11401042
EGLBoolean 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
// ----------------------------------------------------------------------------

opengl/libs/EGL/egl_object.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -173,40 +173,10 @@ class egl_context_t: public egl_object_t {
173173
String8 gl_extensions;
174174
};
175175

176-
class egl_image_t: public egl_object_t {
177-
protected:
178-
~egl_image_t() {}
179-
public:
180-
typedef egl_object_t::LocalRef<egl_image_t, EGLImageKHR> Ref;
181-
182-
egl_image_t(EGLDisplay dpy, EGLContext context) :
183-
egl_object_t(get_display(dpy)),
184-
dpy(dpy), context(context), image(EGL_NO_IMAGE_KHR) { }
185-
EGLDisplay dpy;
186-
EGLContext context;
187-
EGLImageKHR image;
188-
};
189-
190-
class egl_sync_t: public egl_object_t {
191-
protected:
192-
~egl_sync_t() {}
193-
public:
194-
typedef egl_object_t::LocalRef<egl_sync_t, EGLSyncKHR> Ref;
195-
196-
egl_sync_t(EGLDisplay dpy, EGLContext context, EGLSyncKHR sync) :
197-
egl_object_t(get_display(dpy)), dpy(dpy), context(context), sync(sync) {
198-
}
199-
EGLDisplay dpy;
200-
EGLContext context;
201-
EGLSyncKHR sync;
202-
};
203-
204176
// ----------------------------------------------------------------------------
205177

206178
typedef egl_surface_t::Ref SurfaceRef;
207179
typedef egl_context_t::Ref ContextRef;
208-
typedef egl_image_t::Ref ImageRef;
209-
typedef egl_sync_t::Ref SyncRef;
210180

211181
// ----------------------------------------------------------------------------
212182

@@ -225,16 +195,6 @@ egl_context_t* get_context(EGLContext context) {
225195
return egl_to_native_cast<egl_context_t>(context);
226196
}
227197

228-
static inline
229-
egl_image_t* get_image(EGLImageKHR image) {
230-
return egl_to_native_cast<egl_image_t>(image);
231-
}
232-
233-
static inline
234-
egl_sync_t* get_sync(EGLSyncKHR sync) {
235-
return egl_to_native_cast<egl_sync_t>(sync);
236-
}
237-
238198
// ----------------------------------------------------------------------------
239199
}; // namespace android
240200
// ----------------------------------------------------------------------------

opengl/libs/GLES2/gl2.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,27 +124,3 @@ const GLubyte * glGetString(GLenum name)
124124
}
125125
return ret;
126126
}
127-
128-
/*
129-
* These GL calls are special because they need to EGL to retrieve some
130-
* informations before they can execute.
131-
*/
132-
133-
extern "C" void __glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image);
134-
extern "C" void __glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image);
135-
136-
137-
void glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
138-
{
139-
GLeglImageOES implImage =
140-
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
141-
__glEGLImageTargetTexture2DOES(target, implImage);
142-
}
143-
144-
void glEGLImageTargetRenderbufferStorageOES(GLenum target, GLeglImageOES image)
145-
{
146-
GLeglImageOES implImage =
147-
(GLeglImageOES)egl_get_image_for_current_context((EGLImageKHR)image);
148-
__glEGLImageTargetRenderbufferStorageOES(target, implImage);
149-
}
150-

opengl/libs/GLES2/gl2ext_api.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
void API_ENTRY(__glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
1+
void API_ENTRY(glEGLImageTargetTexture2DOES)(GLenum target, GLeglImageOES image) {
22
CALL_GL_API(glEGLImageTargetTexture2DOES, target, image);
33
}
4-
void API_ENTRY(__glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
4+
void API_ENTRY(glEGLImageTargetRenderbufferStorageOES)(GLenum target, GLeglImageOES image) {
55
CALL_GL_API(glEGLImageTargetRenderbufferStorageOES, target, image);
66
}
77
void API_ENTRY(glGetProgramBinaryOES)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary) {

0 commit comments

Comments
 (0)