Evas GL: Add APIs to get current surface/context
- evas_gl_current_surface_get - evas_gl_current_context_get @feature
This commit is contained in:
parent
68ca82e83f
commit
cb5e88d20f
|
@ -596,6 +596,36 @@ EAPI Evas_GL_API *evas_gl_api_get (Evas_GL *evas_gl) EINA
|
|||
*/
|
||||
EAPI int evas_gl_error_get (Evas_GL *evas_gl) EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Returns the Evas GL context object in use or set by @ref evas_gl_make_current.
|
||||
*
|
||||
* @param[in] evas_gl The given Evas_GL object
|
||||
*
|
||||
* @return The current context for the calling thread, or @c NULL in case of
|
||||
* failure and when there is no current context in this thread.
|
||||
*
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI Evas_GL_Context *evas_gl_current_context_get (Evas_GL *evas_gl) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
* @brief Returns the Evas GL surface object in use or set by @ref evas_gl_make_current
|
||||
*
|
||||
* @param evas_gl The given Evas_GL object
|
||||
*
|
||||
* @return The current surface for the calling thread, or @c NULL in case of
|
||||
* failure and when there is no current surface in this thread.
|
||||
*
|
||||
* This can be used to get a handle to the current surface, so as to switch
|
||||
* between contexts back and forth. Note that the OpenGL driver may stall when
|
||||
* doing so.
|
||||
*
|
||||
* @see evas_gl_make_current
|
||||
*
|
||||
* @since 1.12
|
||||
*/
|
||||
EAPI Evas_GL_Surface *evas_gl_current_surface_get (Evas_GL *evas_gl) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1);
|
||||
|
||||
#if !defined(__gl_h_) && !defined(__gl2_h_)
|
||||
# define __gl_h_
|
||||
# define __gl2_h_
|
||||
|
|
|
@ -365,6 +365,68 @@ evas_gl_make_current(Evas_GL *evas_gl, Evas_GL_Surface *surf, Evas_GL_Context *c
|
|||
return ret;
|
||||
}
|
||||
|
||||
EAPI Evas_GL_Context *
|
||||
evas_gl_current_context_get(Evas_GL *evas_gl)
|
||||
{
|
||||
Evas_GL_Context *comp;
|
||||
void *internal_ctx;
|
||||
Eina_List *li;
|
||||
|
||||
// Magic
|
||||
MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
|
||||
return NULL;
|
||||
MAGIC_CHECK_END();
|
||||
|
||||
internal_ctx = evas_gl->evas->engine.func->gl_current_context_get(evas_gl->evas->engine.data.output);
|
||||
if (!internal_ctx)
|
||||
return NULL;
|
||||
|
||||
LKL(evas_gl->lck);
|
||||
EINA_LIST_FOREACH(evas_gl->contexts, li, comp)
|
||||
{
|
||||
if (comp->data == internal_ctx)
|
||||
{
|
||||
LKU(evas_gl->lck);
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
ERR("The currently bound context could not be found.");
|
||||
LKU(evas_gl->lck);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Evas_GL_Surface *
|
||||
evas_gl_current_surface_get(Evas_GL *evas_gl)
|
||||
{
|
||||
Evas_GL_Surface *comp;
|
||||
void *internal_sfc;
|
||||
Eina_List *li;
|
||||
|
||||
// Magic
|
||||
MAGIC_CHECK(evas_gl, Evas_GL, MAGIC_EVAS_GL);
|
||||
return NULL;
|
||||
MAGIC_CHECK_END();
|
||||
|
||||
internal_sfc = evas_gl->evas->engine.func->gl_current_surface_get(evas_gl->evas->engine.data.output);
|
||||
if (!internal_sfc)
|
||||
return NULL;
|
||||
|
||||
LKL(evas_gl->lck);
|
||||
EINA_LIST_FOREACH(evas_gl->surfaces, li, comp)
|
||||
{
|
||||
if (comp->data == internal_sfc)
|
||||
{
|
||||
LKU(evas_gl->lck);
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
|
||||
ERR("The currently bound surface could not be found.");
|
||||
LKU(evas_gl->lck);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI const char *
|
||||
evas_gl_string_query(Evas_GL *evas_gl, int name)
|
||||
{
|
||||
|
|
|
@ -1245,6 +1245,8 @@ struct _Evas_Func
|
|||
Eina_Bool (*gl_surface_read_pixels) (void *data, void *surface, int x, int y, int w, int h, Evas_Colorspace cspace, void *pixels);
|
||||
Eina_Bool (*gl_surface_unlock) (void *data, void *surface);
|
||||
int (*gl_error_get) (void *data);
|
||||
void *(*gl_current_context_get) (void *data);
|
||||
void *(*gl_current_surface_get) (void *data);
|
||||
|
||||
int (*image_load_error_get) (void *data, void *image);
|
||||
int (*font_run_end_get) (void *data, Evas_Font_Set *font, Evas_Font_Instance **script_fi, Evas_Font_Instance **cur_fi, Evas_Script_Type script, const Eina_Unicode *text, int run_len);
|
||||
|
|
|
@ -1147,6 +1147,8 @@ eng_gl_make_current(void *data, void *surface, void *context)
|
|||
EVGL_Surface *sfc = (EVGL_Surface *)surface;
|
||||
EVGL_Context *ctx = (EVGL_Context *)context;
|
||||
|
||||
// TODO: Add check for main thread before flush
|
||||
|
||||
EVGLINIT(data, 0);
|
||||
if ((sfc) && (ctx))
|
||||
{
|
||||
|
@ -1166,6 +1168,20 @@ eng_gl_make_current(void *data, void *surface, void *context)
|
|||
return evgl_make_current(data, sfc, ctx);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_gl_current_surface_get(void *data EINA_UNUSED)
|
||||
{
|
||||
EVGL_Context *ctx;
|
||||
|
||||
ctx = _evgl_current_context_get();
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
// Note: We could verify with a call to eglGetCurrentSurface
|
||||
|
||||
return ctx->current_sfc;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_gl_string_query(void *data, int name)
|
||||
{
|
||||
|
@ -1782,6 +1798,11 @@ module_open(Evas_Module *em)
|
|||
ORD(gl_surface_lock);
|
||||
ORD(gl_surface_read_pixels);
|
||||
ORD(gl_surface_unlock);
|
||||
//ORD(gl_error_get);
|
||||
//ORD(gl_surface_query);
|
||||
// gl_current_context_get is in engine
|
||||
ORD(gl_current_surface_get);
|
||||
//ORD(gl_rotation_angle_get);
|
||||
|
||||
ORD(image_load_error_get);
|
||||
|
||||
|
|
|
@ -1264,6 +1264,28 @@ eng_output_dump(void *data)
|
|||
_re_winfree(re);
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_gl_current_context_get(void *data EINA_UNUSED)
|
||||
{
|
||||
EVGL_Context *ctx;
|
||||
|
||||
ctx = _evgl_current_context_get();
|
||||
if (!ctx)
|
||||
return NULL;
|
||||
|
||||
#ifdef GL_GLES
|
||||
if (eglGetCurrentContext() == (ctx->context))
|
||||
return ctx;
|
||||
else
|
||||
return NULL;
|
||||
#else
|
||||
if (glXGetCurrentContext() == (ctx->context))
|
||||
return ctx;
|
||||
else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int
|
||||
eng_gl_error_get(void *data EINA_UNUSED)
|
||||
{
|
||||
|
|
|
@ -3003,6 +3003,8 @@ static Evas_Func func =
|
|||
NULL, // need software mesa for gl rendering <- gl_surface_read_pixels
|
||||
NULL, // need software mesa for gl rendering <- gl_surface_unlock
|
||||
NULL, // need software mesa for gl rendering <- gl_error_get
|
||||
NULL, // need software mesa for gl rendering <- gl_current_context_get
|
||||
NULL, // need software mesa for gl rendering <- gl_current_surface_get
|
||||
eng_image_load_error_get,
|
||||
eng_font_run_font_end_get,
|
||||
eng_image_animated_get,
|
||||
|
|
Loading…
Reference in New Issue