forked from enlightenment/efl
Added new Evas GL api called evas_gl_config_new/free()
to ensure backward compatibility. Previously, the user simply declared a Evas_GL_Config object but this can cause problems if more config options are added. So, we have Evas allocate the config object for the user so it can handle addition in the future. Also, added some safety code around _extensions_init SVN revision: 67141
This commit is contained in:
parent
71e63d268f
commit
20b3d52669
|
@ -622,4 +622,15 @@
|
||||||
|
|
||||||
* Add EvasGL support to software backend using OSMesa. Requires OSMesa
|
* Add EvasGL support to software backend using OSMesa. Requires OSMesa
|
||||||
library. Due to caveats in OSMesa, surface config stays with a
|
library. Due to caveats in OSMesa, surface config stays with a
|
||||||
context
|
context rather than with a surface. So for now, the config of a
|
||||||
|
surface remains with the first context that it binds to. May need
|
||||||
|
to come up with a different solution in the near future.
|
||||||
|
|
||||||
|
2012-01-12 Sung W. Park (sung_)
|
||||||
|
|
||||||
|
* Add new api evas_gl_config_new/free() to ensure backward compatibility.
|
||||||
|
Previously, the user simply declared a Evas_GL_Config object but this
|
||||||
|
can cause issues if new configs are added. Now we have evas allocate it
|
||||||
|
for you.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ typedef enum _Evas_GL_Depth_Bits
|
||||||
EVAS_GL_DEPTH_BIT_8 = 1,
|
EVAS_GL_DEPTH_BIT_8 = 1,
|
||||||
EVAS_GL_DEPTH_BIT_16 = 2,
|
EVAS_GL_DEPTH_BIT_16 = 2,
|
||||||
EVAS_GL_DEPTH_BIT_24 = 3,
|
EVAS_GL_DEPTH_BIT_24 = 3,
|
||||||
EVAS_GL_DEPTH_BIT_32 = 4,
|
EVAS_GL_DEPTH_BIT_32 = 4
|
||||||
} Evas_GL_Depth_Bits;
|
} Evas_GL_Depth_Bits;
|
||||||
|
|
||||||
typedef enum _Evas_GL_Stencil_Bits
|
typedef enum _Evas_GL_Stencil_Bits
|
||||||
|
@ -38,14 +38,21 @@ typedef enum _Evas_GL_Stencil_Bits
|
||||||
EVAS_GL_STENCIL_BIT_2 = 2,
|
EVAS_GL_STENCIL_BIT_2 = 2,
|
||||||
EVAS_GL_STENCIL_BIT_4 = 3,
|
EVAS_GL_STENCIL_BIT_4 = 3,
|
||||||
EVAS_GL_STENCIL_BIT_8 = 4,
|
EVAS_GL_STENCIL_BIT_8 = 4,
|
||||||
EVAS_GL_STENCIL_BIT_16 = 5,
|
EVAS_GL_STENCIL_BIT_16 = 5
|
||||||
} Evas_GL_Stencil_Bits;
|
} Evas_GL_Stencil_Bits;
|
||||||
|
|
||||||
|
typedef enum _Evas_GL_Options_Bits
|
||||||
|
{
|
||||||
|
EVAS_GL_OPTIONS_NONE = 0,
|
||||||
|
EVAS_GL_OPTIONS_DIRECT = (1<<0)
|
||||||
|
} Evas_GL_Options_Bits;
|
||||||
|
|
||||||
struct _Evas_GL_Config
|
struct _Evas_GL_Config
|
||||||
{
|
{
|
||||||
Evas_GL_Color_Format color_format;
|
Evas_GL_Color_Format color_format;
|
||||||
Evas_GL_Depth_Bits depth_bits;
|
Evas_GL_Depth_Bits depth_bits;
|
||||||
Evas_GL_Stencil_Bits stencil_bits;
|
Evas_GL_Stencil_Bits stencil_bits;
|
||||||
|
Evas_GL_Options_Bits options_bits;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define EVAS_GL_EXTENSIONS 1
|
#define EVAS_GL_EXTENSIONS 1
|
||||||
|
@ -73,6 +80,7 @@ typedef struct _GLData
|
||||||
{
|
{
|
||||||
Evas_GL_Context *ctx;
|
Evas_GL_Context *ctx;
|
||||||
Evas_GL_Surface *sfc;
|
Evas_GL_Surface *sfc;
|
||||||
|
Evas_GL_Config *cfg;
|
||||||
Evas_GL *evasgl;
|
Evas_GL *evasgl;
|
||||||
Evas_GL_API *glapi;
|
Evas_GL_API *glapi;
|
||||||
GLuint program;
|
GLuint program;
|
||||||
|
@ -93,13 +101,6 @@ static GLuint load_shader (GLData *gld, GLenum type, const char *shader_src)
|
||||||
int
|
int
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
// config for the surface for evas_gl
|
|
||||||
Evas_GL_Config config =
|
|
||||||
{
|
|
||||||
EVAS_GL_RGBA_8888,
|
|
||||||
EVAS_GL_DEPTH_NONE,
|
|
||||||
EVAS_GL_STENCIL_NONE
|
|
||||||
};
|
|
||||||
// a size by default
|
// a size by default
|
||||||
int w = 256, h = 256;
|
int w = 256, h = 256;
|
||||||
// some variables we will use
|
// some variables we will use
|
||||||
|
@ -124,8 +125,16 @@ main(int argc, char **argv)
|
||||||
// get the evas gl handle for doing gl things
|
// get the evas gl handle for doing gl things
|
||||||
gld->evasgl = evas_gl_new(canvas);
|
gld->evasgl = evas_gl_new(canvas);
|
||||||
gld->glapi = evas_gl_api_get(gld->evasgl);
|
gld->glapi = evas_gl_api_get(gld->evasgl);
|
||||||
|
|
||||||
|
// Set a surface config
|
||||||
|
gld->cfg = evas_gl_config_new();
|
||||||
|
gld->cfg->color_format = EVAS_GL_RGBA_8888;
|
||||||
|
//gld->cfg->depth_bits = EVAS_GL_DEPTH_NONE; // Othe config options
|
||||||
|
//gld->cfg->stencil_bits = EVAS_GL_STENCIL_NONE;
|
||||||
|
//gld->cfg->options_bits = EVAS_GL_OPTIONS_NONE;
|
||||||
|
|
||||||
// create a surface and context
|
// create a surface and context
|
||||||
gld->sfc = evas_gl_surface_create(gld->evasgl, &config, w, h);
|
gld->sfc = evas_gl_surface_create(gld->evasgl, gld->cfg, w, h);
|
||||||
gld->ctx = evas_gl_context_create(gld->evasgl, NULL);
|
gld->ctx = evas_gl_context_create(gld->evasgl, NULL);
|
||||||
//-//
|
//-//
|
||||||
//-//-//-// END GL INIT BLOB
|
//-//-//-// END GL INIT BLOB
|
||||||
|
@ -207,6 +216,7 @@ on_del(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
||||||
|
|
||||||
evas_gl_surface_destroy(gld->evasgl, gld->sfc);
|
evas_gl_surface_destroy(gld->evasgl, gld->sfc);
|
||||||
evas_gl_context_destroy(gld->evasgl, gld->ctx);
|
evas_gl_context_destroy(gld->evasgl, gld->ctx);
|
||||||
|
evas_gl_config_free(gld->cfg);
|
||||||
evas_gl_free(gld->evasgl);
|
evas_gl_free(gld->evasgl);
|
||||||
free(gld);
|
free(gld);
|
||||||
}
|
}
|
||||||
|
@ -388,6 +398,22 @@ EAPI Evas_GL *evas_gl_new (Evas *e) EINA_WARN_UNU
|
||||||
*/
|
*/
|
||||||
EAPI void evas_gl_free (Evas_GL *evas_gl) EINA_ARG_NONNULL(1);
|
EAPI void evas_gl_free (Evas_GL *evas_gl) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allocates a new config object for the user to fill out.
|
||||||
|
*
|
||||||
|
* As long as the Evas creates a config object for the user, it takes care
|
||||||
|
* of the backward compatibility issue.
|
||||||
|
*/
|
||||||
|
EAPI Evas_GL_Config *evas_gl_config_new ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Frees a config object created from evas_gl_config_new.
|
||||||
|
*
|
||||||
|
* As long as the Evas creates a config object for the user, it takes care
|
||||||
|
* of the backward compatibility issue.
|
||||||
|
*/
|
||||||
|
EAPI void evas_gl_config_free (Evas_GL_Config *cfg) EINA_ARG_NONNULL(1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns new Evas_GL_Surface object for GL Rendering.
|
* Creates and returns new Evas_GL_Surface object for GL Rendering.
|
||||||
*
|
*
|
||||||
|
|
|
@ -37,6 +37,13 @@ evas_gl_new(Evas *e)
|
||||||
evas_gl->magic = MAGIC_EVAS_GL;
|
evas_gl->magic = MAGIC_EVAS_GL;
|
||||||
evas_gl->evas = e;
|
evas_gl->evas = e;
|
||||||
|
|
||||||
|
if (!evas_gl->evas->engine.func->gl_context_create)
|
||||||
|
{
|
||||||
|
ERR("GL engine not available\n");
|
||||||
|
free(evas_gl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return evas_gl;
|
return evas_gl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +67,24 @@ evas_gl_free(Evas_GL *evas_gl)
|
||||||
free(evas_gl);
|
free(evas_gl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EAPI Evas_GL_Config *
|
||||||
|
evas_gl_config_new()
|
||||||
|
{
|
||||||
|
Evas_GL_Config *cfg;
|
||||||
|
|
||||||
|
cfg = calloc(1, sizeof(Evas_GL_Config));
|
||||||
|
|
||||||
|
if (!cfg) return NULL;
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI void
|
||||||
|
evas_gl_config_free(Evas_GL_Config *cfg)
|
||||||
|
{
|
||||||
|
if (cfg) free(cfg);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI Evas_GL_Surface *
|
EAPI Evas_GL_Surface *
|
||||||
evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *config, int width, int height)
|
evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *config, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -77,6 +102,8 @@ evas_gl_surface_create(Evas_GL *evas_gl, Evas_GL_Config *config, int width, int
|
||||||
|
|
||||||
surf = calloc(1, sizeof(Evas_GL_Surface));
|
surf = calloc(1, sizeof(Evas_GL_Surface));
|
||||||
|
|
||||||
|
if (!surf) return NULL;
|
||||||
|
|
||||||
surf->data = evas_gl->evas->engine.func->gl_surface_create(evas_gl->evas->engine.data.output, config, width, height);
|
surf->data = evas_gl->evas->engine.func->gl_surface_create(evas_gl->evas->engine.data.output, config, width, height);
|
||||||
|
|
||||||
if (!surf->data)
|
if (!surf->data)
|
||||||
|
@ -135,12 +162,6 @@ evas_gl_context_create(Evas_GL *evas_gl, Evas_GL_Context *share_ctx)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!evas_gl->evas->engine.func->gl_context_create)
|
|
||||||
{
|
|
||||||
ERR("GL engine not available\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call engine->gl_create_context
|
// Call engine->gl_create_context
|
||||||
if (share_ctx)
|
if (share_ctx)
|
||||||
{
|
{
|
||||||
|
|
|
@ -584,8 +584,12 @@ _extensions_init(Render_Engine *re)
|
||||||
|
|
||||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||||
// EGL Extensions
|
// EGL Extensions
|
||||||
|
if (glsym_eglQueryString)
|
||||||
|
{
|
||||||
evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
|
evasglexts = glsym_eglQueryString(re->win->egl_disp, EGL_EXTENSIONS);
|
||||||
#else
|
#else
|
||||||
|
if (glsym_glXQueryExtensionsString)
|
||||||
|
{
|
||||||
evasglexts = glXQueryExtensionsString(re->info->info.display,
|
evasglexts = glXQueryExtensionsString(re->info->info.display,
|
||||||
re->info->info.screen);
|
re->info->info.screen);
|
||||||
#endif
|
#endif
|
||||||
|
@ -604,6 +608,7 @@ _extensions_init(Render_Engine *re)
|
||||||
}
|
}
|
||||||
DBG(" ");
|
DBG(" ");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int _evas_engine_GL_X11_log_dom = -1;
|
int _evas_engine_GL_X11_log_dom = -1;
|
||||||
/* function tables - filled in later (func and parent func) */
|
/* function tables - filled in later (func and parent func) */
|
||||||
|
|
Loading…
Reference in New Issue