gl_drm: Use common eglCreateImage implementation

Refactor to reduce copy and paste.
This commit is contained in:
Derek Foreman 2016-12-19 15:27:44 -06:00
parent 74a456253a
commit 2e6f93ccda
1 changed files with 11 additions and 37 deletions

View File

@ -72,8 +72,7 @@ glsym_func_void_ptr glsym_evas_gl_common_current_context_get = NULL;
/* dynamic loaded local egl function pointers */
_eng_fn (*glsym_eglGetProcAddress)(const char *a) = NULL;
EGLImage (*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const EGLAttrib *e) = NULL;
EGLImage (*glsym_eglCreateImageKHR) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, EGLint *e) = NULL;
EGLImage (*glsym_evas_gl_common_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const EGLAttrib *e) = NULL;
void (*glsym_eglDestroyImage)(EGLDisplay a, void *b) = NULL;
void (*glsym_glEGLImageTargetTexture2DOES)(int a, void *b) = NULL;
unsigned int (*glsym_eglSwapBuffersWithDamage)(EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL;
@ -149,29 +148,6 @@ eng_gbm_shutdown(Evas_Engine_Info_GL_Drm *info)
return EINA_TRUE;
}
static EGLImage
_eflCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
{
if (glsym_eglCreateImage)
return glsym_eglCreateImage(dpy, ctx, target, buffer, attrib_list);
if (glsym_eglCreateImageKHR)
{
int count, i;
EGLint *ints = NULL;
if (attrib_list)
{
for (count = 0; attrib_list[count] != EGL_NONE; count += 2);
count++;
ints = alloca(count * sizeof(EGLint));
for (i = 0; i < count; i++)
ints[i] = attrib_list[i];
}
return glsym_eglCreateImageKHR(dpy, ctx, target, buffer, ints);
}
return NULL;
}
/* local functions */
static void
gl_symbols(void)
@ -208,15 +184,13 @@ gl_symbols(void)
LINK2GENERIC(evas_gl_symbols);
LINK2GENERIC(eglGetProcAddress);
LINK2GENERIC(evas_gl_common_eglCreateImage);
#define FINDSYM(dst, sym, typ) \
if (!dst) dst = (typ)glsym_eglGetProcAddress(sym);
glsym_evas_gl_symbols((void*)glsym_eglGetProcAddress);
FINDSYM(glsym_eglCreateImageKHR, "eglCreateImageKHR", glsym_func_void_ptr);
FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
@ -628,7 +602,7 @@ import_simple_dmabuf(EGLDisplay display, struct dmabuf_attributes *attributes)
int atti = 0;
if (!dmabuf_present) return NULL;
if (!glsym_eglCreateImage && !glsym_eglCreateImageKHR) return NULL;
if (!glsym_eglDestroyImage) return NULL;
/* This requires the Mesa commit in
* Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or
@ -678,9 +652,9 @@ import_simple_dmabuf(EGLDisplay display, struct dmabuf_attributes *attributes)
attribs[atti++] = EGL_NONE;
return _eflCreateImage(display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
NULL, attribs);
return glsym_evas_gl_common_eglCreateImage(display, EGL_NO_CONTEXT,
EGL_LINUX_DMA_BUF_EXT,
NULL, attribs);
}
static void
@ -1318,11 +1292,11 @@ eng_image_native_set(void *data, void *image, void *native)
&wlid, img);
n->ns_data.wl_surface.wl_buf = wl_buf;
if (glsym_eglCreateImage || glsym_eglCreateImageKHR)
n->ns_data.wl_surface.surface = _eflCreateImage(ob->egl.disp,
NULL,
EGL_WAYLAND_BUFFER_WL,
wl_buf, attribs);
if (glsym_eglDestroyImage)
n->ns_data.wl_surface.surface = glsym_evas_gl_common_eglCreateImage(ob->egl.disp,
NULL,
EGL_WAYLAND_BUFFER_WL,
wl_buf, attribs);
else
{
ERR("Try eglCreateImage on EGL with no support");