summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-12-19 15:27:44 -0600
committerDerek Foreman <derekf@osg.samsung.com>2016-12-19 15:52:58 -0600
commit2e6f93ccda3945b83f2f4c683c407592c2034e91 (patch)
treecd290dfa2e7b022598eecdf67fc6d0c789c205e8 /src
parent74a456253a2365911222b602cd4b77da33f9c6d5 (diff)
gl_drm: Use common eglCreateImage implementation
Refactor to reduce copy and paste.
Diffstat (limited to 'src')
-rw-r--r--src/modules/evas/engines/gl_drm/evas_engine.c48
1 files changed, 11 insertions, 37 deletions
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c
index 4c4f4cccde..7132804cc3 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.c
+++ b/src/modules/evas/engines/gl_drm/evas_engine.c
@@ -72,8 +72,7 @@ glsym_func_void_ptr glsym_evas_gl_common_current_context_get = NULL;
72 72
73/* dynamic loaded local egl function pointers */ 73/* dynamic loaded local egl function pointers */
74_eng_fn (*glsym_eglGetProcAddress)(const char *a) = NULL; 74_eng_fn (*glsym_eglGetProcAddress)(const char *a) = NULL;
75EGLImage (*glsym_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const EGLAttrib *e) = NULL; 75EGLImage (*glsym_evas_gl_common_eglCreateImage) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, const EGLAttrib *e) = NULL;
76EGLImage (*glsym_eglCreateImageKHR) (EGLDisplay a, EGLContext b, EGLenum c, EGLClientBuffer d, EGLint *e) = NULL;
77void (*glsym_eglDestroyImage)(EGLDisplay a, void *b) = NULL; 76void (*glsym_eglDestroyImage)(EGLDisplay a, void *b) = NULL;
78void (*glsym_glEGLImageTargetTexture2DOES)(int a, void *b) = NULL; 77void (*glsym_glEGLImageTargetTexture2DOES)(int a, void *b) = NULL;
79unsigned int (*glsym_eglSwapBuffersWithDamage)(EGLDisplay a, void *b, const EGLint *d, EGLint c) = NULL; 78unsigned 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)
149 return EINA_TRUE; 148 return EINA_TRUE;
150} 149}
151 150
152static EGLImage
153_eflCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
154{
155 if (glsym_eglCreateImage)
156 return glsym_eglCreateImage(dpy, ctx, target, buffer, attrib_list);
157 if (glsym_eglCreateImageKHR)
158 {
159 int count, i;
160 EGLint *ints = NULL;
161
162 if (attrib_list)
163 {
164 for (count = 0; attrib_list[count] != EGL_NONE; count += 2);
165 count++;
166 ints = alloca(count * sizeof(EGLint));
167 for (i = 0; i < count; i++)
168 ints[i] = attrib_list[i];
169 }
170 return glsym_eglCreateImageKHR(dpy, ctx, target, buffer, ints);
171 }
172 return NULL;
173}
174
175/* local functions */ 151/* local functions */
176static void 152static void
177gl_symbols(void) 153gl_symbols(void)
@@ -208,15 +184,13 @@ gl_symbols(void)
208 LINK2GENERIC(evas_gl_symbols); 184 LINK2GENERIC(evas_gl_symbols);
209 185
210 LINK2GENERIC(eglGetProcAddress); 186 LINK2GENERIC(eglGetProcAddress);
187 LINK2GENERIC(evas_gl_common_eglCreateImage);
211 188
212#define FINDSYM(dst, sym, typ) \ 189#define FINDSYM(dst, sym, typ) \
213 if (!dst) dst = (typ)glsym_eglGetProcAddress(sym); 190 if (!dst) dst = (typ)glsym_eglGetProcAddress(sym);
214 191
215 glsym_evas_gl_symbols((void*)glsym_eglGetProcAddress); 192 glsym_evas_gl_symbols((void*)glsym_eglGetProcAddress);
216 193
217 FINDSYM(glsym_eglCreateImageKHR, "eglCreateImageKHR", glsym_func_void_ptr);
218 FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
219
220 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void); 194 FINDSYM(glsym_eglDestroyImage, "eglDestroyImageKHR", glsym_func_void);
221 FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void); 195 FINDSYM(glsym_eglDestroyImage, "eglDestroyImage", glsym_func_void);
222 196
@@ -628,7 +602,7 @@ import_simple_dmabuf(EGLDisplay display, struct dmabuf_attributes *attributes)
628 int atti = 0; 602 int atti = 0;
629 603
630 if (!dmabuf_present) return NULL; 604 if (!dmabuf_present) return NULL;
631 if (!glsym_eglCreateImage && !glsym_eglCreateImageKHR) return NULL; 605 if (!glsym_eglDestroyImage) return NULL;
632 606
633 /* This requires the Mesa commit in 607 /* This requires the Mesa commit in
634 * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or 608 * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or
@@ -678,9 +652,9 @@ import_simple_dmabuf(EGLDisplay display, struct dmabuf_attributes *attributes)
678 652
679 attribs[atti++] = EGL_NONE; 653 attribs[atti++] = EGL_NONE;
680 654
681 return _eflCreateImage(display, EGL_NO_CONTEXT, 655 return glsym_evas_gl_common_eglCreateImage(display, EGL_NO_CONTEXT,
682 EGL_LINUX_DMA_BUF_EXT, 656 EGL_LINUX_DMA_BUF_EXT,
683 NULL, attribs); 657 NULL, attribs);
684} 658}
685 659
686static void 660static void
@@ -1318,11 +1292,11 @@ eng_image_native_set(void *data, void *image, void *native)
1318 &wlid, img); 1292 &wlid, img);
1319 1293
1320 n->ns_data.wl_surface.wl_buf = wl_buf; 1294 n->ns_data.wl_surface.wl_buf = wl_buf;
1321 if (glsym_eglCreateImage || glsym_eglCreateImageKHR) 1295 if (glsym_eglDestroyImage)
1322 n->ns_data.wl_surface.surface = _eflCreateImage(ob->egl.disp, 1296 n->ns_data.wl_surface.surface = glsym_evas_gl_common_eglCreateImage(ob->egl.disp,
1323 NULL, 1297 NULL,
1324 EGL_WAYLAND_BUFFER_WL, 1298 EGL_WAYLAND_BUFFER_WL,
1325 wl_buf, attribs); 1299 wl_buf, attribs);
1326 else 1300 else
1327 { 1301 {
1328 ERR("Try eglCreateImage on EGL with no support"); 1302 ERR("Try eglCreateImage on EGL with no support");