Evas (wayland_egl): Fix egl detection in check_engine. (In theory, the

old version of this w/ the 3 includes Should be working, but I've
tested it on 2 machines now, and it fails on both with those lines in
there, so I am removing them).

Make wayland_egl engine Actually work and draw stuff now (too many
code changes to list them all separately). See http://i.imgur.com/i2eBE.png.




SVN revision: 67128
This commit is contained in:
Christopher Michael 2012-01-12 09:01:37 +00:00
parent dd7d556916
commit c0dd6f7975
4 changed files with 178 additions and 312 deletions

View File

@ -923,9 +923,6 @@ if test "x${have_dep}" = "xyes" ; then
[have_egl="yes"], [have_egl="yes"],
[have_egl="no"], [have_egl="no"],
[ [
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <GL/gl.h>
]) ])
if test "x${have_egl}" = "xyes" ; then if test "x${have_egl}" = "xyes" ; then
evas_engine_[]$1[]_cflags="${WAYLAND_EGL_CFLAGS}" evas_engine_[]$1[]_cflags="${WAYLAND_EGL_CFLAGS}"

View File

@ -612,7 +612,9 @@ eng_setup(Evas *e, void *in)
re->w = e->output.w; re->w = e->output.w;
re->h = e->output.h; re->h = e->output.h;
re->win = eng_window_new(re->info->info.display, re->info->info.surface, re->info->info.screen, re->win = eng_window_new(re->info->info.display,
re->info->info.surface,
re->info->info.screen,
re->info->info.depth, re->w, re->h, re->info->info.depth, re->w, re->h,
re->info->indirect, re->info->indirect,
re->info->info.destination_alpha, re->info->info.destination_alpha,
@ -654,6 +656,7 @@ eng_setup(Evas *e, void *in)
if (_re_wincheck(re)) if (_re_wincheck(re))
{ {
if ((re->info->info.display != re->win->disp) || if ((re->info->info.display != re->win->disp) ||
(re->info->info.surface != re->win->surface) ||
(re->info->info.screen != re->win->screen) || (re->info->info.screen != re->win->screen) ||
(re->info->info.depth != re->win->depth) || (re->info->info.depth != re->win->depth) ||
(re->info->info.destination_alpha != re->win->alpha) || (re->info->info.destination_alpha != re->win->alpha) ||
@ -789,6 +792,17 @@ eng_output_resize(void *data, int w, int h)
re->win->w = w; re->win->w = w;
re->win->h = h; re->win->h = h;
eng_window_use(re->win); eng_window_use(re->win);
if (re->win->win)
{
int nw, nh;
wl_egl_window_get_attached_size(re->win->win, &nw, &nh);
printf("Attached Size: %d %d\n", nw, nh);
wl_egl_window_resize(re->win->win, w, h, 0, 0);
wl_egl_window_get_attached_size(re->win->win, &nw, &nh);
printf("Attached Size: %d %d\n\n", nw, nh);
}
evas_gl_common_context_resize(re->win->gl_context, w, h, re->win->rot); evas_gl_common_context_resize(re->win->gl_context, w, h, re->win->rot);
evas_common_tilebuf_free(re->tb); evas_common_tilebuf_free(re->tb);
re->tb = evas_common_tilebuf_new(w, h); re->tb = evas_common_tilebuf_new(w, h);
@ -984,79 +998,23 @@ eng_output_flush(void *data)
else eglSwapInterval(re->win->egl_disp, 0); else eglSwapInterval(re->win->egl_disp, 0);
re->vsync = 1; re->vsync = 1;
} }
if (re->info->callback.pre_swap) if (re->info->callback.pre_swap)
{ re->info->callback.pre_swap(re->info->callback.data, re->evas);
re->info->callback.pre_swap(re->info->callback.data, re->evas);
}
eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]); eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
if (!safe_native) eglWaitGL(); if (!safe_native) eglWaitGL();
if (re->info->callback.post_swap) if (re->info->callback.post_swap)
{ re->info->callback.post_swap(re->info->callback.data, re->evas);
re->info->callback.post_swap(re->info->callback.data, re->evas);
} if (eglGetError() != EGL_SUCCESS)
printf("Error: eglSwapBuffers() fail.\n");
# ifdef FRAMECOUNT # ifdef FRAMECOUNT
double t1 = get_time(); double t1 = get_time();
printf("%1.5f\n", t1 - t0); printf("%1.5f\n", t1 - t0);
# endif # endif
if (eglGetError() != EGL_SUCCESS)
{
printf("Error: eglSwapBuffers() fail.\n");
}
if (re->info->callback.pre_swap)
{
re->info->callback.pre_swap(re->info->callback.data, re->evas);
}
#if 1
if (1)
#else
if ((re->win->draw.x1 == 0) && (re->win->draw.y1 == 0) && (re->win->draw.x2 == (re->win->w - 1)) && (re->win->draw.y2 == (re->win->h - 1)))
#endif
{
#ifdef FRAMECOUNT
double t, t2 = 0.0;
t = get_time();
#endif
eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
#ifdef FRAMECOUNT
t = get_time() - t;
if (!safe_native)
{
t2 = get_time();
eglWaitGL();
t2 = get_time() - t2;
}
printf("swap: %3.5f (%3.5fms), x wait gl: %3.5f (%3.5fms)\n",
t, t * 1000.0, t2, t2 * 1000.0);
#endif
}
else
{
// FIXME: this doesn't work.. why oh why?
// int sx, sy, sw, sh;
// sx = re->win->draw.x1;
// sy = re->win->draw.y1;
// sw = (re->win->draw.x2 - re->win->draw.x1) + 1;
// sh = (re->win->draw.y2 - re->win->draw.y1) + 1;
// sy = re->win->h - sy - sh;
// glBitmap(0, 0, 0, 0, sx, re->win->h - sy, NULL);
// glEnable(GL_SCISSOR_TEST);
// glScissor(sx, sy, sw, sh);
// glDrawBuffer(GL_FRONT);
// glCopyPixels(sx, sy, sw, sh, GL_COLOR);
// glDrawBuffer(GL_BACK);
// glDisable(GL_SCISSOR_TEST);
// glBitmap(0, 0, 0, 0, 0, 0, NULL);
// glFlush();
}
if (re->info->callback.post_swap)
{
re->info->callback.post_swap(re->info->callback.data, re->evas);
}
} }
static void static void
@ -1355,27 +1313,17 @@ _native_bind_cb(void *data, void *image)
Evas_GL_Image *im = image; Evas_GL_Image *im = image;
Native *n = im->native.data; Native *n = im->native.data;
/* if (n->ns.type == EVAS_NATIVE_SURFACE_X11) */ if (n->egl_surface)
/* { */ {
/* #if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX) */ if (glsym_glEGLImageTargetTexture2DOES)
/* if (n->egl_surface) */ {
/* { */ glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface);
/* if (glsym_glEGLImageTargetTexture2DOES) */ if (eglGetError() != EGL_SUCCESS)
/* { */ ERR("glEGLImageTargetTexture2DOES() failed.");
/* glsym_glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, n->egl_surface); */ }
/* if (eglGetError() != EGL_SUCCESS) */ else
/* ERR("glEGLImageTargetTexture2DOES() failed."); */ ERR("Try glEGLImageTargetTexture2DOES on EGL with no support");
/* } */ }
/* else */
/* ERR("Try glEGLImageTargetTexture2DOES on EGL with no support"); */
/* } */
/* #endif */
/* } */
/* else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) */
{
glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
return; return;
data = NULL; data = NULL;
} }
@ -1384,17 +1332,17 @@ static void
_native_unbind_cb(void *data, void *image) _native_unbind_cb(void *data, void *image)
{ {
Evas_GL_Image *im = image; Evas_GL_Image *im = image;
Native *n = im->native.data; /* Native *n = im->native.data; */
/* if (n->ns.type == EVAS_NATIVE_SURFACE_X11) */ /* if (n->ns.type == EVAS_NATIVE_SURFACE_X11) */
/* { */ /* { */
/* // nothing */ /* // nothing */
/* } */ /* } */
/* else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) */ /* else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) */
{ /* { */
glBindTexture(GL_TEXTURE_2D, 0); /* glBindTexture(GL_TEXTURE_2D, 0); */
GLERR(__FUNCTION__, __FILE__, __LINE__, ""); /* GLERR(__FUNCTION__, __FILE__, __LINE__, ""); */
} /* } */
return; return;
data = NULL; data = NULL;
} }
@ -1408,45 +1356,38 @@ _native_free_cb(void *data, void *image)
uint32_t texid; uint32_t texid;
// uint32_t pmid, texid; // uint32_t pmid, texid;
/* if (n->ns.type == EVAS_NATIVE_SURFACE_X11) */ /* eina_hash_del(re->win->gl_context->shared->native_pm_hash, &pmid, im); */
/* { */ if (n->egl_surface)
/* eina_hash_del(re->win->gl_context->shared->native_pm_hash, &pmid, im); */ {
/* if (n->egl_surface) */ if (glsym_eglDestroyImage)
/* { */ {
/* if (glsym_eglDestroyImage) */ glsym_eglDestroyImage(re->win->egl_disp, n->egl_surface);
/* { */ if (eglGetError() != EGL_SUCCESS)
/* glsym_eglDestroyImage(re->win->egl_disp, n->egl_surface); */ ERR("eglDestroyImage() failed.");
/* if (eglGetError() != EGL_SUCCESS) */ }
/* ERR("eglDestroyImage() failed."); */ else
/* } */ ERR("Try eglDestroyImage on EGL with no support");
/* else */ }
/* ERR("Try eglDestroyImage on EGL with no support"); */
/* } */ im->native.data = NULL;
/* } */ im->native.func.data = NULL;
/* else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL) */ im->native.func.bind = NULL;
{ im->native.func.unbind = NULL;
texid = n->ns.data.opengl.texture_id; im->native.func.free = NULL;
eina_hash_del(re->win->gl_context->shared->native_tex_hash, &texid, im); free(n);
}
im->native.data = NULL;
im->native.func.data = NULL;
im->native.func.bind = NULL;
im->native.func.unbind = NULL;
im->native.func.free = NULL;
free(n);
} }
static void * static void *
eng_image_native_set(void *data, void *image, void *native) eng_image_native_set(void *data, void *image, void *native)
{ {
Render_Engine *re = (Render_Engine *)data; Render_Engine *re = (Render_Engine *)data;
Evas_Native_Surface *ns = native; Evas_Native_Surface *ns = native;
Evas_GL_Image *im = image, *im2 = NULL; Evas_GL_Image *im = image, *im2 = NULL;
struct wl_egl_pixmap *pm; Native *n = NULL;
Native *n = NULL; // uint32_t pmid;
uint32_t pmid, texid; // uint32_t texid;
unsigned int tex = 0; unsigned int tex = 0;
unsigned int fbo = 0; unsigned int fbo = 0;
if (!im) if (!im)
{ {
@ -1464,30 +1405,15 @@ eng_image_native_set(void *data, void *image, void *native)
if (ns) if (ns)
{ {
/* if (ns->type == EVAS_NATIVE_SURFACE_X11) */
/* { */
/* vis = ns->data.x11.visual; */ /* vis = ns->data.x11.visual; */
/* pm = ns->data.x11.pixmap; */ /* pm = ns->data.x11.pixmap; */
/* if (im->native.data) */
/* { */
/* Evas_Native_Surface *ens = im->native.data; */
/* if ((ens->data.x11.visual == vis) && */
/* (ens->data.x11.pixmap == pm)) */
/* return im; */
/* } */
/* } */
/* else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL) */
{
tex = ns->data.opengl.texture_id;
fbo = ns->data.opengl.framebuffer_id;
if (im->native.data) if (im->native.data)
{ {
Evas_Native_Surface *ens = im->native.data; Evas_Native_Surface *ens = im->native.data;
if ((ens->data.opengl.texture_id == tex) && /* if ((ens->data.x11.visual == vis) && */
(ens->data.opengl.framebuffer_id == fbo)) /* (ens->data.x11.pixmap == pm)) */
return im; return im;
} }
}
} }
if ((!ns) && (!im->native.data)) return im; if ((!ns) && (!im->native.data)) return im;
@ -1506,131 +1432,79 @@ eng_image_native_set(void *data, void *image, void *native)
/* { */ /* { */
/* pmid = pm; */ /* pmid = pm; */
/* im2 = eina_hash_find(re->win->gl_context->shared->native_pm_hash, &pmid); */ /* im2 = eina_hash_find(re->win->gl_context->shared->native_pm_hash, &pmid); */
/* if (im2 == im) return im; */ if (im2 == im) return im;
/* if (im2) */ if (im2)
/* { */ {
/* n = im2->native.data; */ n = im2->native.data;
/* if (n) */ if (n)
/* { */ {
/* evas_gl_common_image_ref(im2); */ evas_gl_common_image_ref(im2);
/* evas_gl_common_image_free(im); */ evas_gl_common_image_free(im);
/* return im2; */ return im2;
/* } */ }
/* } */ }
/* } */
/* else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL) */
{
texid = tex;
im2 = eina_hash_find(re->win->gl_context->shared->native_tex_hash, &texid);
if (im2 == im) return im;
if (im2)
{
n = im2->native.data;
if (n)
{
evas_gl_common_image_ref(im2);
evas_gl_common_image_free(im);
return im2;
}
}
} im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
im->w, im->h, NULL, im->alpha, im->w, im->h, NULL, im->alpha,
EVAS_COLORSPACE_ARGB8888); EVAS_COLORSPACE_ARGB8888);
evas_gl_common_image_free(im); evas_gl_common_image_free(im);
im = im2; im = im2;
/* if (ns->type == EVAS_NATIVE_SURFACE_X11) */ /* if (native) */
/* { */ /* { */
/* if (native) */ /* n = calloc(1, sizeof(Native)); */
/* { */ /* if (n) */
/* n = calloc(1, sizeof(Native)); */ /* { */
/* if (n) */ /* EGLConfig egl_config; */
/* { */ /* int config_attrs[20]; */
/* EGLConfig egl_config; */ /* int num_config, i = 0; */
/* int config_attrs[20]; */
/* int num_config, i = 0; */
/* eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im); */ /* eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im); */
/* config_attrs[i++] = EGL_RED_SIZE; */ /* config_attrs[i++] = EGL_RED_SIZE; */
/* config_attrs[i++] = 8; */ /* config_attrs[i++] = 8; */
/* config_attrs[i++] = EGL_GREEN_SIZE; */ /* config_attrs[i++] = EGL_GREEN_SIZE; */
/* config_attrs[i++] = 8; */ /* config_attrs[i++] = 8; */
/* config_attrs[i++] = EGL_BLUE_SIZE; */ /* config_attrs[i++] = EGL_BLUE_SIZE; */
/* config_attrs[i++] = 8; */ /* config_attrs[i++] = 8; */
/* config_attrs[i++] = EGL_ALPHA_SIZE; */ /* config_attrs[i++] = EGL_ALPHA_SIZE; */
/* config_attrs[i++] = 8; */ /* config_attrs[i++] = 8; */
/* config_attrs[i++] = EGL_DEPTH_SIZE; */ /* config_attrs[i++] = EGL_DEPTH_SIZE; */
/* config_attrs[i++] = 0; */ /* config_attrs[i++] = 0; */
/* config_attrs[i++] = EGL_STENCIL_SIZE; */ /* config_attrs[i++] = EGL_STENCIL_SIZE; */
/* config_attrs[i++] = 0; */ /* config_attrs[i++] = 0; */
/* config_attrs[i++] = EGL_RENDERABLE_TYPE; */ /* config_attrs[i++] = EGL_RENDERABLE_TYPE; */
/* config_attrs[i++] = EGL_OPENGL_ES2_BIT; */ /* config_attrs[i++] = EGL_OPENGL_ES2_BIT; */
/* config_attrs[i++] = EGL_SURFACE_TYPE; */ /* config_attrs[i++] = EGL_SURFACE_TYPE; */
/* config_attrs[i++] = EGL_PIXMAP_BIT; */ /* config_attrs[i++] = EGL_PIXMAP_BIT; */
/* config_attrs[i++] = EGL_NONE; */ /* config_attrs[i++] = EGL_NONE; */
/* if (!eglChooseConfig(re->win->egl_disp, config_attrs, */ /* if (!eglChooseConfig(re->win->egl_disp, config_attrs, */
/* &egl_config, 1, &num_config)) */ /* &egl_config, 1, &num_config)) */
/* ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config); */ /* ERR("eglChooseConfig() failed for, num_config = %i", num_config); */
/* memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); */ /* memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); */
/* n->pixmap = pm; */ /* n->pixmap = pm; */
/* if (glsym_eglCreateImage) */ /* if (glsym_eglCreateImage) */
/* n->egl_surface = glsym_eglCreateImage(re->win->egl_disp, */ /* n->egl_surface = glsym_eglCreateImage(re->win->egl_disp, */
/* EGL_NO_CONTEXT, */ /* EGL_NO_CONTEXT, */
/* EGL_NATIVE_PIXMAP_KHR, */ /* EGL_NATIVE_PIXMAP_KHR, */
/* (void *)pm, */ /* (void *)pm, */
/* NULL); */ /* NULL); */
/* else */ /* else */
/* ERR("Try eglCreateImage on EGL with no support"); */ /* ERR("Try eglCreateImage on EGL with no support"); */
/* if (!n->egl_surface) */ /* if (!n->egl_surface) */
/* ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm); */ /* ERR("eglCreatePixmapSurface() for 0x%x failed", (unsigned int)pm); */
/* im->native.yinvert = 1; */ /* im->native.yinvert = 1; */
/* im->native.loose = 0; */ /* im->native.loose = 0; */
/* im->native.data = n; */ /* im->native.data = n; */
/* im->native.func.data = re; */ /* im->native.func.data = re; */
/* im->native.func.bind = _native_bind_cb; */ /* im->native.func.bind = _native_bind_cb; */
/* im->native.func.unbind = _native_unbind_cb; */ /* im->native.func.unbind = _native_unbind_cb; */
/* im->native.func.free = _native_free_cb; */ /* im->native.func.free = _native_free_cb; */
/* im->native.target = GL_TEXTURE_2D; */ /* im->native.target = GL_TEXTURE_2D; */
/* im->native.mipmap = 0; */ /* im->native.mipmap = 0; */
/* evas_gl_common_image_native_enable(im); */ /* evas_gl_common_image_native_enable(im); */
/* } */ /* } */
/* } */ /* } */
/* } */
/* else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL) */
{
if (native)
{
n = calloc(1, sizeof(Native));
if (n)
{
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
eina_hash_add(re->win->gl_context->shared->native_tex_hash, &texid, im);
n->pixmap = NULL;
n->egl_surface = 0;
im->native.yinvert = 0;
im->native.loose = 0;
im->native.data = n;
im->native.func.data = re;
im->native.func.bind = _native_bind_cb;
im->native.func.unbind = _native_unbind_cb;
im->native.func.free = _native_free_cb;
im->native.target = GL_TEXTURE_2D;
im->native.mipmap = 0;
// FIXME: need to implement mapping sub texture regions
// x, y, w, h for possible texture atlasing
evas_gl_common_image_native_enable(im);
}
}
}
return im; return im;
} }
@ -1679,11 +1553,6 @@ eng_image_filtered_free(void *im, Filtered_Image *fim)
} }
#endif #endif
//
//
/////////////////////////////////////////////////////////////////////////
static void * static void *
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo) eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
{ {
@ -1793,7 +1662,7 @@ eng_image_size_set(void *data, void *image, int w, int h)
evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0); evas_common_blit_rectangle(im_old->im, im->im, 0, 0, w, h, 0, 0);
evas_common_cpu_end_opt(); evas_common_cpu_end_opt();
} }
*/ */
evas_gl_common_image_free(im_old); evas_gl_common_image_free(im_old);
} }
else else
@ -1862,7 +1731,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
return im; return im;
} }
/* Engine can be fail to create texture after cache drop like eng_image_content_hint_set function, /* Engine can fail to create texture after cache drop like eng_image_content_hint_set function,
so it is need to add code which check im->im's NULL value*/ so it is need to add code which check im->im's NULL value*/
if (!im->im) if (!im->im)

View File

@ -47,6 +47,7 @@ struct _Evas_GL_Wl_Window
{ {
struct wl_display *disp; struct wl_display *disp;
struct wl_egl_window *win; struct wl_egl_window *win;
struct wl_surface *surface;
int w, h; int w, h;
int screen; int screen;
// XVisualInfo *visualinfo; // XVisualInfo *visualinfo;

View File

@ -1,6 +1,6 @@
#include "evas_engine.h" #include "evas_engine.h"
static Evas_GL_Wl_Window *_evas_gl_x11_window = NULL; static Evas_GL_Wl_Window *_evas_gl_wl_window = NULL;
static EGLContext context = EGL_NO_CONTEXT; static EGLContext context = EGL_NO_CONTEXT;
@ -25,10 +25,8 @@ eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen,
win_count++; win_count++;
gw->disp = disp; gw->disp = disp;
// gw->win = win; gw->surface = surface;
gw->screen = screen; gw->screen = screen;
// gw->visual = vis;
// gw->colormap = cmap;
gw->depth = depth; gw->depth = depth;
gw->alpha = alpha; gw->alpha = alpha;
gw->w = w; gw->w = w;
@ -138,20 +136,20 @@ eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen,
eng_window_free(gw); eng_window_free(gw);
return NULL; return NULL;
} }
/* FIXME: !!! */
gw->win = wl_egl_window_create(surface, gw->w, gw->h); gw->win = wl_egl_window_create(gw->surface, gw->w, gw->h);
gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config, gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
(EGLNativeWindowType)gw->win, (EGLNativeWindowType)gw->win,
NULL); NULL);
if (gw->egl_surface[0] == EGL_NO_SURFACE) if (gw->egl_surface[0] == EGL_NO_SURFACE)
{ {
/* FIXME: !! */ ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
/* ERR("eglCreateWindowSurface() fail for %#x. code=%#x", */ (unsigned int)gw->win, eglGetError());
/* (unsigned int)gw->win, eglGetError()); */
eng_window_free(gw); eng_window_free(gw);
return NULL; return NULL;
} }
if (context == EGL_NO_CONTEXT) if (context == EGL_NO_CONTEXT)
context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL, context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
context_attrs); context_attrs);
@ -162,6 +160,7 @@ eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen,
eng_window_free(gw); eng_window_free(gw);
return NULL; return NULL;
} }
if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0], if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0],
gw->egl_context[0]) == EGL_FALSE) gw->egl_context[0]) == EGL_FALSE)
{ {
@ -204,8 +203,8 @@ eng_window_free(Evas_GL_Wl_Window *gw)
win_count--; win_count--;
eng_window_use(gw); eng_window_use(gw);
if (gw == _evas_gl_x11_window) _evas_gl_x11_window = NULL; if (gw == _evas_gl_wl_window) _evas_gl_wl_window = NULL;
if (gw->win) wl_egl_window_destroy(gw->win); // if (gw->win) wl_egl_window_destroy(gw->win);
if (gw->gl_context) if (gw->gl_context)
{ {
ref = gw->gl_context->references - 1; ref = gw->gl_context->references - 1;
@ -216,10 +215,11 @@ eng_window_free(Evas_GL_Wl_Window *gw)
if (ref == 0) if (ref == 0)
{ {
if (context) eglDestroyContext(gw->egl_disp, context); if (context) eglDestroyContext(gw->egl_disp, context);
eglTerminate(gw->egl_disp);
context = EGL_NO_CONTEXT; context = EGL_NO_CONTEXT;
} }
eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (ref == 0) eglTerminate(gw->egl_disp);
eglReleaseThread();
free(gw); free(gw);
} }
@ -228,36 +228,36 @@ eng_window_use(Evas_GL_Wl_Window *gw)
{ {
Eina_Bool force_use = EINA_FALSE; Eina_Bool force_use = EINA_FALSE;
if (_evas_gl_x11_window) if (_evas_gl_wl_window)
{ {
if ((eglGetCurrentContext() != if ((eglGetCurrentContext() !=
_evas_gl_x11_window->egl_context[0]) || _evas_gl_wl_window->egl_context[0]) ||
(eglGetCurrentSurface(EGL_READ) != (eglGetCurrentSurface(EGL_READ) !=
_evas_gl_x11_window->egl_surface[0]) || _evas_gl_wl_window->egl_surface[0]) ||
(eglGetCurrentSurface(EGL_DRAW) != (eglGetCurrentSurface(EGL_DRAW) !=
_evas_gl_x11_window->egl_surface[0])) _evas_gl_wl_window->egl_surface[0]))
force_use = EINA_TRUE; force_use = EINA_TRUE;
} }
if ((_evas_gl_x11_window != gw) || (force_use)) if ((_evas_gl_wl_window != gw) || (force_use))
{ {
if (_evas_gl_x11_window) if (_evas_gl_wl_window)
{ {
evas_gl_common_context_use(_evas_gl_x11_window->gl_context); evas_gl_common_context_use(_evas_gl_wl_window->gl_context);
evas_gl_common_context_flush(_evas_gl_x11_window->gl_context); evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
} }
_evas_gl_x11_window = gw; _evas_gl_wl_window = gw;
if (gw) if (gw)
{ {
// EGL / GLES // EGL / GLES
if (gw->egl_surface[0] != EGL_NO_SURFACE) if (gw->egl_surface[0] != EGL_NO_SURFACE)
{ {
if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0],
gw->egl_surface[0], gw->egl_surface[0],
gw->egl_context[0]) == EGL_FALSE) gw->egl_context[0]) == EGL_FALSE)
{ {
ERR("eglMakeCurrent() failed!"); ERR("eglMakeCurrent() failed!");
} }
} }
} }
} }
if (gw) evas_gl_common_context_use(gw->gl_context); if (gw) evas_gl_common_context_use(gw->gl_context);
@ -270,15 +270,15 @@ eng_window_unsurf(Evas_GL_Wl_Window *gw)
if (!getenv("EVAS_GL_WIN_RESURF")) return; if (!getenv("EVAS_GL_WIN_RESURF")) return;
if (getenv("EVAS_GL_INFO")) printf("unsurf %p\n", gw); if (getenv("EVAS_GL_INFO")) printf("unsurf %p\n", gw);
if (_evas_gl_x11_window) if (_evas_gl_wl_window)
evas_gl_common_context_flush(_evas_gl_x11_window->gl_context); evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
if (_evas_gl_x11_window == gw) if (_evas_gl_wl_window == gw)
{ {
eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (gw->egl_surface[0] != EGL_NO_SURFACE) if (gw->egl_surface[0] != EGL_NO_SURFACE)
eglDestroySurface(gw->egl_disp, gw->egl_surface[0]); eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
gw->egl_surface[0] = EGL_NO_SURFACE; gw->egl_surface[0] = EGL_NO_SURFACE;
_evas_gl_x11_window = NULL; _evas_gl_wl_window = NULL;
} }
gw->surf = 0; gw->surf = 0;
} }
@ -289,15 +289,14 @@ eng_window_resurf(Evas_GL_Wl_Window *gw)
if (gw->surf) return; if (gw->surf) return;
if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", gw); if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", gw);
/* FIXME !! */ gw->egl_surface[0] =
/* gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config, */ eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
/* (EGLNativeWindowType)gw->win, */ (EGLNativeWindowType)gw->win, NULL);
/* NULL); */
if (gw->egl_surface[0] == EGL_NO_SURFACE) if (gw->egl_surface[0] == EGL_NO_SURFACE)
{ {
/* FIXME: !! */ ERR("eglCreateWindowSurface() fail for %#x. code=%#x",
/* ERR("eglCreateWindowSurface() fail for %#x. code=%#x", */ (unsigned int)gw->win, eglGetError());
/* (unsigned int)gw->win, eglGetError()); */
return; return;
} }
if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0], if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0],