Merge branch 'devs/devilhorns/wayland_egl'

Fix wayland_egl engine to work again (see Phab Ticket T1478).

Previous (french) changes had broken the wayland_egl engine. This
rewrites the wayland_egl engine to function again, this time using
gl_generic and glsym_evas_gl calls.
This commit is contained in:
Chris Michael 2014-08-06 14:29:36 -04:00
commit c4db47f68c
4 changed files with 1008 additions and 2427 deletions

View File

@ -11,7 +11,8 @@ typedef enum _Evas_Engine_Info_Wayland_Egl_Swap_Mode
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_FULL = 1,
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_COPY = 2,
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_DOUBLE = 3,
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_TRIPLE = 4
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_TRIPLE = 4,
EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_QUADRUPLE = 5
} Evas_Engine_Info_Wayland_Egl_Swap_Mode;
struct _Evas_Engine_Info_Wayland_Egl
@ -25,6 +26,7 @@ struct _Evas_Engine_Info_Wayland_Egl
{
struct wl_display *display;
struct wl_surface *surface;
struct wl_egl_window *win;
int depth, screen, rotation, edges;
unsigned int destination_alpha : 1;
} info;
@ -39,8 +41,8 @@ struct _Evas_Engine_Info_Wayland_Egl
/* non-blocking or blocking mode */
Evas_Engine_Render_Mode render_mode;
unsigned char vsync : 1;
unsigned char indirect : 1;
Eina_Bool vsync : 1;
Eina_Bool indirect : 1;
unsigned char swap_mode : 4;
};

File diff suppressed because it is too large Load Diff

View File

@ -2,25 +2,22 @@
# define EVAS_ENGINE_H
# include "config.h"
# include "evas_common_private.h"
# include "evas_private.h"
# include "Evas.h"
# include "Evas_Engine_Wayland_Egl.h"
/* NB: This already includes wayland-client.h */
# include <wayland-egl.h>
# ifdef GL_GLES
# include <EGL/egl.h>
/* NB: These are already included from gl_common */
/* # include <GLES2/gl2.h> */
/* # include <GLES2/gl2ext.h> */
# endif
# include "evas_common_private.h"
# include "evas_private.h"
# include "evas_gl_common.h"
# include "Evas.h"
# include "Evas_Engine_Wayland_Egl.h"
# define GL_GLEXT_PROTOTYPES
# include <EGL/egl.h>
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# include "../gl_generic/Evas_Engine_GL_Generic.h"
extern int _evas_engine_wl_egl_log_dom;
# ifdef ERR
@ -48,9 +45,13 @@ extern int _evas_engine_wl_egl_log_dom;
# endif
# define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_wl_egl_log_dom, __VA_ARGS__)
typedef struct _Evas_GL_Wl_Window Evas_GL_Wl_Window;
# ifndef EGL_BUFFER_AGE_EXT
# define EGL_BUFFER_AGE_EXT 0x313d
# endif
struct _Evas_GL_Wl_Window
typedef struct _Outbuf Outbuf;
struct _Outbuf
{
struct wl_display *disp;
struct wl_egl_window *win;
@ -58,28 +59,83 @@ struct _Evas_GL_Wl_Window
int w, h;
int depth, screen, rot, alpha;
Evas *evas;
Evas_Engine_Info_Wayland_Egl *info;
Evas_Engine_GL_Context *gl_context;
Render_Engine_Swap_Mode swap_mode;
int prev_age, vsync;
int frame_cnt;
struct
{
Eina_Bool drew : 1;
} draw;
#ifdef GL_GLES
EGLContext egl_context[1];
EGLSurface egl_surface[1];
EGLConfig egl_config;
EGLDisplay egl_disp;
#endif
Eina_Bool lost_back : 1;
Eina_Bool surf : 1;
};
Evas_GL_Wl_Window *eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen, int depth, int w, int h, int indirect, int alpha, int rot);
void eng_window_free(Evas_GL_Wl_Window *gw);
void eng_window_use(Evas_GL_Wl_Window *gw);
void eng_window_unsurf(Evas_GL_Wl_Window *gw);
void eng_window_resurf(Evas_GL_Wl_Window *gw);
Eina_Bool eng_window_make_current(void *data, void *doit);
struct _Context_3D
{
EGLDisplay display;
EGLContext context;
EGLSurface surface;
};
extern Eina_Bool extn_have_buffer_age;
extern Eina_Bool extn_have_y_inverted;
extern Evas_GL_Common_Context_New glsym_evas_gl_common_context_new;
extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_flush;
extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_free;
extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_use;
extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_newframe;
extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_done;
extern Evas_GL_Common_Context_Resize_Call glsym_evas_gl_common_context_resize;
extern Evas_GL_Common_Buffer_Dump_Call glsym_evas_gl_common_buffer_dump;
extern Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_lock;
extern Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock;
extern unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c);
Outbuf *eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen, int depth, int w, int h, int indirect, int alpha, int rot, Render_Engine_Swap_Mode swap_mode);
void eng_window_free(Outbuf *gw);
void eng_window_use(Outbuf *gw);
void eng_window_unsurf(Outbuf *gw);
void eng_window_resurf(Outbuf *gw);
void eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
int eng_outbuf_rotation_get(Outbuf *ob);
Render_Engine_Swap_Mode eng_outbuf_swap_mode_get(Outbuf *ob);
Eina_Bool eng_outbuf_region_first_rect(Outbuf *ob);
void *eng_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch);
void eng_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
void eng_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h);
void eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode);
Evas_Engine_GL_Context *eng_outbuf_gl_context_get(Outbuf *ob);
void *eng_outbuf_egl_display_get(Outbuf *ob);
Eina_Bool eng_preload_make_current(void *data, void *doit);
Context_3D *eng_gl_context_new(Outbuf *win);
void eng_gl_context_free(Context_3D *context);
void eng_gl_context_use(Context_3D *context);
static inline int
_re_wincheck(Outbuf *ob)
{
if (ob->surf) return 1;
eng_window_resurf(ob);
ob->lost_back = EINA_TRUE;
if (!ob->surf)
ERR("Wayland EGL Engine cannot recreate window surface");
return 0;
}
#endif

View File

@ -3,14 +3,14 @@
/* local function prototypes */
/* local variables */
static Evas_GL_Wl_Window *_evas_gl_wl_window = NULL;
static Outbuf *_evas_gl_wl_window = NULL;
static EGLContext context = EGL_NO_CONTEXT;
static int win_count = 0;
Evas_GL_Wl_Window *
eng_window_new(struct wl_display *display, struct wl_surface *surface, int screen, int depth, int w, int h, int indirect EINA_UNUSED, int alpha, int rot)
Outbuf *
eng_window_new(struct wl_display *disp, struct wl_surface *surface, int screen, int depth, int w, int h, int indirect EINA_UNUSED, int alpha, int rot, Render_Engine_Swap_Mode swap_mode)
{
Evas_GL_Wl_Window *gw;
Outbuf *gw;
int context_attrs[3];
int config_attrs[40];
int major_version, minor_version;
@ -19,11 +19,11 @@ eng_window_new(struct wl_display *display, struct wl_surface *surface, int scree
Eina_Bool blacklist = EINA_FALSE;
/* try to allocate space for our window */
if (!(gw = calloc(1, sizeof(Evas_GL_Wl_Window))))
if (!(gw = calloc(1, sizeof(Outbuf))))
return NULL;
win_count++;
gw->disp = display;
gw->disp = disp;
gw->surface = surface;
gw->screen = screen;
gw->depth = depth;
@ -31,6 +31,7 @@ eng_window_new(struct wl_display *display, struct wl_surface *surface, int scree
gw->h = h;
gw->alpha = alpha;
gw->rot = rot;
gw->swap_mode = swap_mode;
context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
context_attrs[1] = 2;
@ -164,7 +165,7 @@ eng_window_new(struct wl_display *display, struct wl_surface *surface, int scree
return NULL;
}
if (!(gw->gl_context = evas_gl_common_context_new()))
if (!(gw->gl_context = glsym_evas_gl_common_context_new()))
{
eng_window_free(gw);
return NULL;
@ -174,7 +175,7 @@ eng_window_new(struct wl_display *display, struct wl_surface *surface, int scree
gw->gl_context->eglctxt = gw->egl_context[0];
eng_window_use(gw);
evas_gl_common_context_resize(gw->gl_context, w, h, rot);
glsym_evas_gl_common_context_resize(gw->gl_context, w, h, rot);
gw->surf = EINA_TRUE;
@ -182,7 +183,7 @@ eng_window_new(struct wl_display *display, struct wl_surface *surface, int scree
}
void
eng_window_free(Evas_GL_Wl_Window *gw)
eng_window_free(Outbuf *gw)
{
int ref = 0;
@ -194,7 +195,7 @@ eng_window_free(Evas_GL_Wl_Window *gw)
if (gw->gl_context)
{
ref = gw->gl_context->references - 1;
evas_gl_common_context_free(gw->gl_context);
glsym_evas_gl_common_context_free(gw->gl_context);
}
eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE,
@ -220,11 +221,11 @@ eng_window_free(Evas_GL_Wl_Window *gw)
}
void
eng_window_use(Evas_GL_Wl_Window *gw)
eng_window_use(Outbuf *gw)
{
Eina_Bool force = EINA_FALSE;
evas_gl_preload_render_lock(eng_window_make_current, gw);
glsym_evas_gl_preload_render_lock(eng_preload_make_current, gw);
if (_evas_gl_wl_window)
{
@ -236,8 +237,8 @@ eng_window_use(Evas_GL_Wl_Window *gw)
{
if (_evas_gl_wl_window)
{
evas_gl_common_context_use(_evas_gl_wl_window->gl_context);
evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
glsym_evas_gl_common_context_use(_evas_gl_wl_window->gl_context);
glsym_evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
}
_evas_gl_wl_window = gw;
@ -254,24 +255,25 @@ eng_window_use(Evas_GL_Wl_Window *gw)
}
}
if (gw) evas_gl_common_context_use(gw->gl_context);
if (gw) glsym_evas_gl_common_context_use(gw->gl_context);
}
void
eng_window_unsurf(Evas_GL_Wl_Window *gw)
eng_window_unsurf(Outbuf *gw)
{
if (!gw->surf) return;
if (!getenv("EVAS_GL_WIN_RESURF")) return;
if (getenv("EVAS_GL_INFO")) printf("unsurf %p\n", gw);
if (_evas_gl_wl_window)
evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
glsym_evas_gl_common_context_flush(_evas_gl_wl_window->gl_context);
if (_evas_gl_wl_window == gw)
{
eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
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;
_evas_gl_wl_window = NULL;
@ -281,7 +283,7 @@ eng_window_unsurf(Evas_GL_Wl_Window *gw)
}
void
eng_window_resurf(Evas_GL_Wl_Window *gw)
eng_window_resurf(Outbuf *gw)
{
if (gw->surf) return;
if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", gw);
@ -304,25 +306,192 @@ eng_window_resurf(Evas_GL_Wl_Window *gw)
gw->surf = EINA_TRUE;
}
Eina_Bool
eng_window_make_current(void *data, void *doit)
void
eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth EINA_UNUSED)
{
Evas_GL_Wl_Window *gw;
ob->w = w;
ob->h = h;
ob->rot = rot;
eng_window_use(ob);
glsym_evas_gl_common_context_resize(ob->gl_context, w, h, rot);
}
if (!(gw = data)) return EINA_FALSE;
int
eng_outbuf_rotation_get(Outbuf *ob)
{
return ob->rot;
}
if (doit)
Render_Engine_Swap_Mode
eng_outbuf_swap_mode_get(Outbuf *ob)
{
if ((ob->swap_mode == MODE_AUTO) && (extn_have_buffer_age))
{
if (!eglMakeCurrent(gw->egl_disp, gw->egl_surface[0],
gw->egl_surface[0], gw->egl_context[0]))
return EINA_FALSE;
Render_Engine_Swap_Mode swap_mode;
EGLint age = 0;
if (!eglQuerySurface(ob->egl_disp, ob->egl_surface[0],
EGL_BUFFER_AGE_EXT, &age))
age = 0;
if (age == 1) swap_mode = MODE_COPY;
else if (age == 2) swap_mode = MODE_DOUBLE;
else if (age == 3) swap_mode = MODE_TRIPLE;
else if (age == 4) swap_mode = MODE_QUADRUPLE;
else swap_mode = MODE_FULL;
if ((int)age != ob->prev_age) swap_mode = MODE_FULL;
ob->prev_age = age;
return swap_mode;
}
return ob->swap_mode;
}
Eina_Bool
eng_outbuf_region_first_rect(Outbuf *ob)
{
ob->gl_context->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
glsym_evas_gl_preload_render_lock(eng_preload_make_current, ob);
eng_window_use(ob);
if (!_re_wincheck(ob)) return EINA_TRUE;
glsym_evas_gl_common_context_resize(ob->gl_context, ob->w, ob->h, ob->rot);
glsym_evas_gl_common_context_flush(ob->gl_context);
glsym_evas_gl_common_context_newframe(ob->gl_context);
return EINA_FALSE;
}
void *
eng_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx EINA_UNUSED, int *cy EINA_UNUSED, int *cw EINA_UNUSED, int *ch EINA_UNUSED)
{
if ((ob->w == w) && (ob->h == h))
ob->gl_context->master_clip.enabled = EINA_FALSE;
else
{
if (!eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT))
return EINA_FALSE;
ob->gl_context->master_clip.enabled = EINA_TRUE;
ob->gl_context->master_clip.x = x;
ob->gl_context->master_clip.y = y;
ob->gl_context->master_clip.w = w;
ob->gl_context->master_clip.h = h;
}
return EINA_TRUE;
return ob->gl_context->def_surface;
}
void
eng_outbuf_update_region_free(Outbuf *ob EINA_UNUSED, RGBA_Image *update EINA_UNUSED)
{
}
void
eng_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update EINA_UNUSED, int x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
{
if (!_re_wincheck(ob)) return;
ob->draw.drew = EINA_TRUE;
glsym_evas_gl_common_context_flush(ob->gl_context);
}
void
eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode)
{
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) goto end;
if (!_re_wincheck(ob)) goto end;
if (!ob->draw.drew) goto end;
ob->draw.drew = EINA_FALSE;
eng_window_use(ob);
glsym_evas_gl_common_context_done(ob->gl_context);
if (!ob->vsync)
{
if (ob->info->vsync) eglSwapInterval(ob->egl_disp, 1);
else eglSwapInterval(ob->egl_disp, 0);
ob->vsync = EINA_TRUE;
}
if (ob->info->callback.pre_swap)
ob->info->callback.pre_swap(ob->info->callback.data, ob->evas);
if ((glsym_eglSwapBuffersWithDamage) && (ob->swap_mode != MODE_FULL))
{
EGLint num = 0, *result = NULL, i = 0;
Tilebuf_Rect *r;
// if partial swaps can be done use re->rects
num = eina_inlist_count(EINA_INLIST_GET(rects));
if (num > 0)
{
result = alloca(sizeof(EGLint) * 4 * num);
EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
{
int gw, gh;
gw = ob->gl_context->w;
gh = ob->gl_context->h;
switch (ob->rot)
{
case 0:
result[i + 0] = r->x;
result[i + 1] = gh - (r->y + r->h);
result[i + 2] = r->w;
result[i + 3] = r->h;
break;
case 90:
result[i + 0] = r->y;
result[i + 1] = r->x;
result[i + 2] = r->h;
result[i + 3] = r->w;
break;
case 180:
result[i + 0] = gw - (r->x + r->w);
result[i + 1] = r->y;
result[i + 2] = r->w;
result[i + 3] = r->h;
break;
case 270:
result[i + 0] = gh - (r->y + r->h);
result[i + 1] = gw - (r->x + r->w);
result[i + 2] = r->h;
result[i + 3] = r->w;
break;
default:
result[i + 0] = r->x;
result[i + 1] = gh - (r->y + r->h);
result[i + 2] = r->w;
result[i + 3] = r->h;
break;
}
i += 4;
}
glsym_eglSwapBuffersWithDamage(ob->egl_disp, ob->egl_surface[0],
result, num);
}
}
else
eglSwapBuffers(ob->egl_disp, ob->egl_surface[0]);
if (ob->info->callback.post_swap)
ob->info->callback.post_swap(ob->info->callback.data, ob->evas);
end:
glsym_evas_gl_preload_render_unlock(eng_preload_make_current, ob);
}
Evas_Engine_GL_Context *
eng_outbuf_gl_context_get(Outbuf *ob)
{
return ob->gl_context;
}
void *
eng_outbuf_egl_display_get(Outbuf *ob)
{
return ob->egl_disp;
}