evas-gl-drm: Rework gl_drm engine to function again

Summary: Previous gl_drm evas engine code did not work properly (or at
all really). This reworks/refactors the gl_drm engine code to work
again with the changes made to ecore_drm.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-06-03 12:56:35 -04:00
parent 58dbb63ba4
commit ee593050f1
5 changed files with 1170 additions and 319 deletions

View File

@ -1199,8 +1199,7 @@ endif
if BUILD_ENGINE_GL_DRM
dist_installed_evasmainheaders_DATA += modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
GL_DRM_SOURCES = \
modules/evas/engines/gl_drm/evas_drm.c \
modules/evas/engines/gl_drm/evas_drm_main.c \
modules/evas/engines/gl_drm/evas_outbuf.c \
modules/evas/engines/gl_drm/evas_engine.c \
modules/evas/engines/gl_drm/evas_engine.h \
modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h

View File

@ -0,0 +1,36 @@
#ifndef _EVAS_ENGINE_GL_DRM_H
# define _EVAS_ENGINE_GL_DRM_H
# include <Ecore_Drm.h>
# include <gbm.h>
typedef struct _Evas_Engine_Info_GL_Drm Evas_Engine_Info_GL_Drm;
struct _Evas_Engine_Info_GL_Drm
{
/* PRIVATE - don't mess with this baby or evas will poke its tongue out */
/* at you and make nasty noises */
Evas_Engine_Info magic;
struct
{
struct gbm_device *gbm;
struct gbm_surface *surface;
unsigned int rotation, depth;
unsigned int crtc_id, conn_id, buffer_id;
unsigned int format, flags;
Ecore_Drm_Device *dev;
Eina_Bool destination_alpha : 1;
Eina_Bool vsync : 1;
Eina_Bool indirect : 1;
unsigned char swap_mode : 4;
} info;
/* non-blocking or blocking mode */
Evas_Engine_Render_Mode render_mode;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
#ifndef EVAS_ENGINE_H
# define EVAS_ENGINE_H
# include "evas_common_private.h"
# include "evas_macros.h"
# include "evas_private.h"
# include "Evas.h"
# include "Evas_Engine_GL_Drm.h"
# define GL_GLEXT_PROTOTYPES
# include <EGL/egl.h>
# include <EGL/eglext.h>
# include <EGL/eglmesaext.h>
# include <GLES2/gl2.h>
# include <GLES2/gl2ext.h>
# include "../gl_generic/Evas_Engine_GL_Generic.h"
extern int _evas_engine_gl_drm_log_dom;
extern int _extn_have_buffer_age;
# ifdef ERR
# undef ERR
# endif
# define ERR(...) EINA_LOG_DOM_ERR(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
# ifdef DBG
# undef DBG
# endif
# define DBG(...) EINA_LOG_DOM_DBG(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
# ifdef INF
# undef INF
# endif
# define INF(...) EINA_LOG_DOM_INFO(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
# ifdef WRN
# undef WRN
# endif
# define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
# ifdef CRI
# undef CRI
# endif
# define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
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;
struct _Context_3D
{
EGLDisplay display;
EGLContext context;
EGLSurface surface;
};
struct _Outbuf
{
Evas_Engine_Info_GL_Drm *info;
Evas_Engine_GL_Context *gl_context;
int w, h;
unsigned int rotation, depth;
Render_Engine_Swap_Mode swap_mode;
struct gbm_device *gbm;
struct gbm_surface *surface;
struct
{
EGLContext context[1];
EGLSurface surface[1];
EGLConfig config;
EGLDisplay disp;
} egl;
struct
{
int prev_age, frame_cnt;
int curr, last, num;
Ecore_Drm_Fb *buffer[4];
struct gbm_bo *bo[4];
Eina_List *pending_writes;
} priv;
Eina_Bool destination_alpha : 1;
Eina_Bool vsync : 1;
Eina_Bool lost_back : 1;
Eina_Bool surf : 1;
Eina_Bool drew : 1;
};
Outbuf *evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_Mode swap_mode);
void evas_outbuf_free(Outbuf *ob);
void evas_outbuf_use(Outbuf *ob);
void evas_outbuf_resurf(Outbuf *ob);
void evas_outbuf_unsurf(Outbuf *ob);
void evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth);
Render_Engine_Swap_Mode evas_outbuf_buffer_state_get(Outbuf *ob);
int evas_outbuf_rot_get(Outbuf *ob);
Eina_Bool evas_outbuf_update_region_first_rect(Outbuf *ob);
void *evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int *cx, int *cy, int *cw, int *ch);
void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h);
void evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update);
void evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode);
Evas_Engine_GL_Context* evas_outbuf_gl_context_get(Outbuf *ob);
void *evas_outbuf_egl_display_get(Outbuf *ob);
Context_3D *evas_outbuf_gl_context_new(Outbuf *ob);
void evas_outbuf_gl_context_use(Context_3D *ctx);
static inline Eina_Bool
_re_wincheck(Outbuf *ob)
{
if (ob->surf) return EINA_TRUE;
evas_outbuf_resurf(ob);
ob->lost_back = 1;
if (!ob->surf) ERR("GL engine can't re-create window surface!");
return EINA_FALSE;
}
#endif

View File

@ -0,0 +1,656 @@
#include "evas_engine.h"
/* local variables */
static Outbuf *_evas_gl_drm_window = NULL;
static EGLContext context = EGL_NO_CONTEXT;
static int win_count = 0;
static void
_evas_outbuf_cb_pageflip(void *data)
{
Outbuf *ob;
Ecore_Drm_Fb *fb;
if (!(ob = data)) return;
if ((fb = ob->priv.buffer[ob->priv.curr]))
{
fb->pending_flip = EINA_FALSE;
gbm_surface_release_buffer(ob->surface, ob->priv.bo[ob->priv.curr]);
}
ob->priv.last = ob->priv.curr;
ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num;
}
static void
_evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
{
Ecore_Drm_Fb *buff;
buff = ob->priv.buffer[ob->priv.curr];
ob->priv.bo[ob->priv.curr] = gbm_surface_lock_front_buffer(ob->surface);
ecore_drm_fb_dirty(buff, rects, count);
ecore_drm_fb_set(ob->info->info.dev, buff);
ecore_drm_fb_send(ob->info->info.dev, buff, _evas_outbuf_cb_pageflip, ob);
}
static Eina_Bool
_evas_outbuf_make_current(void *data, void *doit)
{
Outbuf *ob;
if (!(ob = data)) return EINA_FALSE;
if (doit)
{
if (!eglMakeCurrent(ob->egl.disp, ob->egl.surface[0],
ob->egl.surface[0], ob->egl.context[0]))
return EINA_FALSE;
}
else
{
if (!eglMakeCurrent(ob->egl.disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT))
return EINA_FALSE;
}
return EINA_TRUE;
}
static Eina_Bool
_evas_outbuf_egl_setup(Outbuf *ob)
{
int ctx_attr[3];
int cfg_attr[40];
int maj = 0, min = 0;
int ncfg = 0, n = 0;
const GLubyte *vendor, *renderer, *version, *glslversion;
Eina_Bool blacklist = EINA_FALSE;
/* setup gbm egl surface */
ctx_attr[0] = EGL_CONTEXT_CLIENT_VERSION;
ctx_attr[1] = 2;
ctx_attr[2] = EGL_NONE;
cfg_attr[n++] = EGL_SURFACE_TYPE;
cfg_attr[n++] = EGL_WINDOW_BIT;
cfg_attr[n++] = EGL_RED_SIZE;
cfg_attr[n++] = 1;
cfg_attr[n++] = EGL_GREEN_SIZE;
cfg_attr[n++] = 1;
cfg_attr[n++] = EGL_BLUE_SIZE;
cfg_attr[n++] = 1;
cfg_attr[n++] = EGL_ALPHA_SIZE;
if (ob->destination_alpha) cfg_attr[n++] = 1;
else cfg_attr[n++] = 0;
cfg_attr[n++] = EGL_RENDERABLE_TYPE;
cfg_attr[n++] = EGL_OPENGL_ES2_BIT;
cfg_attr[n++] = EGL_NONE;
ob->egl.disp = eglGetDisplay((EGLNativeDisplayType)(ob->gbm));
if (ob->egl.disp == EGL_NO_DISPLAY)
{
ERR("eglGetDisplay() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
if (!eglInitialize(ob->egl.disp, &maj, &min))
{
ERR("eglInitialize() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
eglBindAPI(EGL_OPENGL_ES_API);
if (eglGetError() != EGL_SUCCESS)
{
ERR("eglBindAPI() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
if (!eglChooseConfig(ob->egl.disp, cfg_attr, &ob->egl.config,
1, &ncfg) || (ncfg != 1))
{
ERR("eglChooseConfig() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
ob->egl.surface[0] =
eglCreateWindowSurface(ob->egl.disp, ob->egl.config,
(EGLNativeWindowType)ob->surface, NULL);
if (ob->egl.surface[0] == EGL_NO_SURFACE)
{
ERR("eglCreateWindowSurface() fail for %p. code=%#x",
ob->surface, eglGetError());
return EINA_FALSE;
}
ob->egl.context[0] =
eglCreateContext(ob->egl.disp, ob->egl.config, context, ctx_attr);
if (ob->egl.context[0] == EGL_NO_CONTEXT)
{
ERR("eglCreateContext() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
if (context == EGL_NO_CONTEXT) context = ob->egl.context[0];
if (eglMakeCurrent(ob->egl.disp, ob->egl.surface[0],
ob->egl.surface[0], ob->egl.context[0]) == EGL_FALSE)
{
ERR("eglMakeCurrent() fail. code=%#x", eglGetError());
return EINA_FALSE;
}
vendor = glGetString(GL_VENDOR);
renderer = glGetString(GL_RENDERER);
version = glGetString(GL_VERSION);
glslversion = glGetString(GL_SHADING_LANGUAGE_VERSION);
if (!vendor) vendor = (unsigned char *)"-UNKNOWN-";
if (!renderer) renderer = (unsigned char *)"-UNKNOWN-";
if (!version) version = (unsigned char *)"-UNKNOWN-";
if (!glslversion) glslversion = (unsigned char *)"-UNKNOWN-";
if (getenv("EVAS_GL_INFO"))
{
fprintf(stderr, "vendor : %s\n", vendor);
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version : %s\n", version);
fprintf(stderr, "glsl ver: %s\n", glslversion);
}
if (strstr((const char *)vendor, "Mesa Project"))
{
if (strstr((const char *)renderer, "Software Rasterizer"))
blacklist = EINA_TRUE;
}
if (strstr((const char *)renderer, "softpipe"))
blacklist = EINA_TRUE;
if (strstr((const char *)renderer, "llvmpipe"))
blacklist = EINA_TRUE;
if ((blacklist) && (!getenv("EVAS_GL_NO_BLACKLIST")))
{
ERR("OpenGL Driver blacklisted:");
ERR("Vendor: %s", (const char *)vendor);
ERR("Renderer: %s", (const char *)renderer);
ERR("Version: %s", (const char *)version);
return EINA_FALSE;
}
ob->gl_context = glsym_evas_gl_common_context_new();
if (!ob->gl_context) return EINA_FALSE;
#ifdef GL_GLES
ob->gl_context->egldisp = ob->egl.disp;
ob->gl_context->eglctxt = ob->egl.context[0];
#endif
evas_outbuf_use(ob);
glsym_evas_gl_common_context_resize(ob->gl_context,
ob->w, ob->h, ob->rotation);
ob->surf = EINA_TRUE;
return EINA_TRUE;
}
Outbuf *
evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_Mode swap_mode)
{
Outbuf *ob;
char *num;
int i = 0;
/* try to allocate space for outbuf */
if (!(ob = calloc(1, sizeof(Outbuf)))) return NULL;
win_count++;
ob->w = w;
ob->h = h;
ob->info = info;
ob->depth = info->info.depth;
ob->rotation = info->info.rotation;
ob->destination_alpha = info->info.destination_alpha;
ob->vsync = info->info.vsync;
ob->gbm = info->info.gbm;
ob->surface = info->info.surface;
ob->swap_mode = swap_mode;
ob->priv.num = 2;
if ((num = getenv("EVAS_GL_DRM_BUFFERS")))
{
ob->priv.num = atoi(num);
if (ob->priv.num <= 0) ob->priv.num = 1;
else if (ob->priv.num > 4) ob->priv.num = 4;
}
if ((num = getenv("EVAS_GL_DRM_VSYNC")))
ob->vsync = atoi(num);
if (!_evas_outbuf_egl_setup(ob))
{
evas_outbuf_free(ob);
return NULL;
}
for (; i < ob->priv.num; i++)
{
ob->priv.buffer[i] =
ecore_drm_fb_create(ob->info->info.dev, ob->w, ob->h);
if (!ob->priv.buffer[i]) break;
DBG("Evas Engine Created Dumb Buffer");
DBG("\tFb: %d", ob->priv.buffer[i]->id);
DBG("\tHandle: %d", ob->priv.buffer[i]->hdl);
DBG("\tStride: %d", ob->priv.buffer[i]->stride);
DBG("\tSize: %d", ob->priv.buffer[i]->size);
DBG("\tW: %d\tH: %d",
ob->priv.buffer[i]->w, ob->priv.buffer[i]->h);
}
ecore_drm_fb_set(info->info.dev, ob->priv.buffer[0]);
return ob;
}
void
evas_outbuf_free(Outbuf *ob)
{
int i = 0, ref = 0;
win_count--;
evas_outbuf_use(ob);
if (ob == _evas_gl_drm_window) _evas_gl_drm_window = NULL;
if (ob->gl_context)
{
ref = ob->gl_context->references - 1;
glsym_evas_gl_common_context_free(ob->gl_context);
}
eglMakeCurrent(ob->egl.disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (ob->egl.context[0] != context)
eglDestroyContext(ob->egl.disp, ob->egl.context[0]);
if (ob->egl.surface[0] != EGL_NO_SURFACE)
eglDestroySurface(ob->egl.disp, ob->egl.surface[0]);
//#if 0
if (ob->surface)
{
gbm_surface_destroy(ob->surface);
ob->info->info.surface = NULL;
}
//#endif
if (ref == 0)
{
if (context) eglDestroyContext(ob->egl.disp, context);
eglTerminate(ob->egl.disp);
eglReleaseThread();
context = EGL_NO_CONTEXT;
}
for (; i < ob->priv.num; i++)
ecore_drm_fb_destroy(ob->priv.buffer[i]);
free(ob);
}
void
evas_outbuf_use(Outbuf *ob)
{
Eina_Bool force = EINA_FALSE;
glsym_evas_gl_preload_render_lock(_evas_outbuf_make_current, ob);
if (_evas_gl_drm_window)
{
if (eglGetCurrentContext() != _evas_gl_drm_window->egl.context[0])
force = EINA_TRUE;
}
if ((_evas_gl_drm_window != ob) || (force))
{
if (_evas_gl_drm_window)
{
glsym_evas_gl_common_context_use(_evas_gl_drm_window->gl_context);
glsym_evas_gl_common_context_flush(_evas_gl_drm_window->gl_context);
}
_evas_gl_drm_window = ob;
if (ob)
{
if (ob->egl.surface[0] != EGL_NO_SURFACE)
{
if (eglMakeCurrent(ob->egl.disp, ob->egl.surface[0],
ob->egl.surface[0],
ob->egl.context[0]) == EGL_FALSE)
ERR("eglMakeCurrent() failed!");
}
}
}
if (ob) glsym_evas_gl_common_context_use(ob->gl_context);
}
void
evas_outbuf_resurf(Outbuf *ob)
{
if (ob->surf) return;
if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", ob);
ob->egl.surface[0] =
eglCreateWindowSurface(ob->egl.disp, ob->egl.config,
(EGLNativeWindowType)ob->surface, NULL);
if (ob->egl.surface[0] == EGL_NO_SURFACE)
{
ERR("eglCreateWindowSurface() fail for %p. code=%#x",
ob->surface, eglGetError());
return;
}
if (eglMakeCurrent(ob->egl.disp, ob->egl.surface[0], ob->egl.surface[0],
ob->egl.context[0]) == EGL_FALSE)
ERR("eglMakeCurrent() failed!");
ob->surf = EINA_TRUE;
}
void
evas_outbuf_unsurf(Outbuf *ob)
{
if (!ob->surf) return;
if (!getenv("EVAS_GL_WIN_RESURF")) return;
if (getenv("EVAS_GL_INFO")) printf("unsurf %p\n", ob);
if (_evas_gl_drm_window)
glsym_evas_gl_common_context_flush(_evas_gl_drm_window->gl_context);
if (_evas_gl_drm_window == ob)
{
eglMakeCurrent(ob->egl.disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (ob->egl.surface[0] != EGL_NO_SURFACE)
eglDestroySurface(ob->egl.disp, ob->egl.surface[0]);
ob->egl.surface[0] = EGL_NO_SURFACE;
_evas_gl_drm_window = NULL;
}
ob->surf = EINA_FALSE;
}
void
evas_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth)
{
int i = 0;
if (depth == OUTBUF_DEPTH_INHERIT) depth = ob->depth;
/* check for changes */
if ((ob->w == w) && (ob->h == h) &&
(ob->destination_alpha == ob->info->info.destination_alpha) &&
((int)ob->rotation == rot) && (ob->depth == depth))
return;
ob->w = w;
ob->h = h;
ob->depth = depth;
ob->rotation = rot;
/* destroy the old buffers */
for (; i < ob->priv.num; i++)
ecore_drm_fb_destroy(ob->priv.buffer[i]);
for (i = 0; i < ob->priv.num; i++)
{
ob->priv.buffer[i] =
ecore_drm_fb_create(ob->info->info.dev, ob->w, ob->h);
if (!ob->priv.buffer[i])
{
ERR("Failed to create buffer %d", i);
break;
}
}
evas_outbuf_use(ob);
glsym_evas_gl_common_context_resize(ob->gl_context, w, h, rot);
//TODO: need drm gbm surface destroy & re-create.?
}
Render_Engine_Swap_Mode
evas_outbuf_buffer_state_get(Outbuf *ob)
{
if (ob->swap_mode == MODE_AUTO && _extn_have_buffer_age)
{
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->priv.prev_age) swap_mode = MODE_FULL;
ob->priv.prev_age = age;
return swap_mode;
}
return ob->swap_mode;
}
int
evas_outbuf_rot_get(Outbuf *ob)
{
return ob->rotation;
}
Eina_Bool
evas_outbuf_update_region_first_rect(Outbuf *ob)
{
ob->gl_context->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
glsym_evas_gl_preload_render_lock(_evas_outbuf_make_current, ob);
evas_outbuf_use(ob);
if (!_re_wincheck(ob)) return EINA_TRUE;
glsym_evas_gl_common_context_resize(ob->gl_context, ob->w, ob->h, ob->rotation);
glsym_evas_gl_common_context_flush(ob->gl_context);
glsym_evas_gl_common_context_newframe(ob->gl_context);
return EINA_FALSE;
}
void *
evas_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 ((w == ob->w) && (h == ob->h))
ob->gl_context->master_clip.enabled = EINA_FALSE;
else
{
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 ob->gl_context->def_surface;
}
void
evas_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)
{
/* Is it really necessary to flush per region ? Shouldn't we be able to
still do that for the full canvas when doing partial update */
if (!_re_wincheck(ob)) return;
ob->drew = EINA_TRUE;
glsym_evas_gl_common_context_flush(ob->gl_context);
}
void
evas_outbuf_update_region_free(Outbuf *ob EINA_UNUSED, RGBA_Image *update EINA_UNUSED)
{
/* Nothing to do here as we don't really create an image per area */
}
void
evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode render_mode)
{
if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) goto end;
if (!_re_wincheck(ob)) goto end;
if (!ob->drew) goto end;
ob->drew = EINA_FALSE;
evas_outbuf_use(ob);
glsym_evas_gl_common_context_done(ob->gl_context);
if (!ob->vsync)
{
if (ob->info->info.vsync) eglSwapInterval(ob->egl.disp, 1);
else eglSwapInterval(ob->egl.disp, 0);
ob->vsync = 1;
}
/* if (ob->info->callback.pre_swap) */
/* ob->info->callback.pre_swap(ob->info->callback.data, ob->evas); */
// TODO: Check eglSwapBuffersWithDamage for gl_drm and apply
#if 0
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
#endif
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); */
//Flush GL Surface data to Framebuffer
_evas_outbuf_buffer_swap(ob, NULL, 0);
ob->priv.frame_cnt++;
end:
//TODO: Need render unlock after drm page flip?
glsym_evas_gl_preload_render_unlock(_evas_outbuf_make_current, ob);
}
Evas_Engine_GL_Context *
evas_outbuf_gl_context_get(Outbuf *ob)
{
return ob->gl_context;
}
void *
evas_outbuf_egl_display_get(Outbuf *ob)
{
return ob->egl.disp;
}
Context_3D *
evas_outbuf_gl_context_new(Outbuf *ob)
{
Context_3D *ctx;
int context_attrs[3] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
if (!ob) return NULL;
ctx = calloc(1, sizeof(Context_3D));
if (!ctx) return NULL;
ctx->context = eglCreateContext(ob->egl.disp, ob->egl.config,
ob->egl.context[0], context_attrs);
if (!ctx->context)
{
ERR("EGL context creation failed.");
goto error;
}
ctx->display = ob->egl.disp;
ctx->surface = ob->egl.surface[0];
return ctx;
error:
free(ctx);
return NULL;
}
void
evas_outbuf_gl_context_use(Context_3D *ctx)
{
if (eglMakeCurrent(ctx->display, ctx->surface,
ctx->surface, ctx->context) == EGL_FALSE)
ERR("eglMakeCurrent() failed.");
}