Evas GL: Add support for OpenGL-ES 1.1 (part 2)

Add version param to context_create.
Add support for 1.1 contexts in the GL_X11 engine, and checks
for version in all other engines (return NULL).
Add API wrappers for all OpenGL-ES 1.1 APIs (normal and debug
modes).
This commit is contained in:
Jean-Philippe Andre 2014-09-22 19:15:37 +09:00
parent 3f9caaf16d
commit 4315537820
14 changed files with 4383 additions and 31 deletions

View File

@ -575,6 +575,7 @@ modules/evas/engines/gl_common/evas_gl_api_ext_def.h \
modules/evas/engines/gl_common/evas_gl_core.h \
modules/evas/engines/gl_common/evas_gl_core_private.h \
modules/evas/engines/gl_common/evas_gl_api.c \
modules/evas/engines/gl_common/evas_gl_api_gles1.c \
modules/evas/engines/gl_common/evas_gl_api_ext.c \
modules/evas/engines/gl_common/shader/font_frag.h \
modules/evas/engines/gl_common/shader/font_vert.h \

View File

@ -157,6 +157,7 @@ struct _Evas_3D_File_Eet
typedef Eina_Bool (*Evas_3D_Node_Func)(Evas_3D_Node *, void *data);
typedef enum _Evas_3D_Node_Traverse_Type
{
EVAS_3D_NODE_TRAVERSE_DOWNWARD,
@ -1233,13 +1234,13 @@ struct _Evas_Func
void *(*gl_surface_create) (void *data, void *config, int w, int h);
void *(*gl_pbuffer_surface_create) (void *data, void *config, int w, int h, int const *attrib_list);
int (*gl_surface_destroy) (void *data, void *surface);
void *(*gl_context_create) (void *data, void *share_context);
void *(*gl_context_create) (void *data, void *share_context, int version);
int (*gl_context_destroy) (void *data, void *context);
int (*gl_make_current) (void *data, void *surface, void *context);
void *(*gl_string_query) (void *data, int name);
void *(*gl_proc_address_get) (void *data, const char *name);
int (*gl_native_surface_get) (void *data, void *surface, void *native_surface);
void *(*gl_api_get) (void *data);
void *(*gl_api_get) (void *data, int version);
void (*gl_direct_override_get) (void *data, int *override, int *force_off);
void (*gl_get_pixels_set) (void *data, void *get_pixels, void *get_pixels_data, void *obj);
Eina_Bool (*gl_surface_lock) (void *data, void *surface);

View File

@ -1160,7 +1160,7 @@ evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const
#endif
static void *
eng_gl_api_get(void *data)
eng_gl_api_get(void *data, int version EINA_UNUSED)
{
Render_Engine *re;

View File

@ -19,9 +19,9 @@ void _make_current_check(const char* api)
ctx = evas_gl_common_current_context_get();
if (!ctx)
{
CRI("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api);
}
CRI("\e[1;33m%s\e[m: Current Context NOT SET: GL Call Should NOT Be Called without MakeCurrent!!!", api);
else if (ctx->version != EVAS_GL_GLES_2_X)
CRI("\e[1;33m%s\e[m: This API is being called with the wrong context (invalid version).", api);
}
static
@ -185,7 +185,7 @@ _evgl_glReleaseShaderCompiler(void)
// returns: imgc[4] (oc[4]) original image object dimension in gl coord
// returns: objc[4] (nc[4]) tranformed (x, y, width, heigth) in gl coord
// returns: cc[4] cliped coordinate in original coordinate
static void
void
compute_gl_coordinates(int win_w, int win_h, int rot, int clip_image,
int x, int y, int width, int height,
int img_x, int img_y, int img_w, int img_h,

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ typedef struct _GL_Format
// Globals
static Evas_GL_API gl_funcs;
static Evas_GL_API gles1_funcs;
EVGL_Engine *evgl_engine = NULL;
int _evas_gl_log_dom = -1;
int _evas_gl_log_level = -1;
@ -62,7 +63,7 @@ _internal_resources_create(void *eng_data)
}
// Create a resource context
rsc->context = evgl_engine->funcs->context_create(eng_data, NULL);
rsc->context = evgl_engine->funcs->context_create(eng_data, NULL, EVAS_GL_GLES_2_X);
if (!rsc->context)
{
ERR("Internal resource context creations failed.");
@ -1827,7 +1828,8 @@ evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc)
}
void *
evgl_context_create(void *eng_data, EVGL_Context *share_ctx)
evgl_context_create(void *eng_data, EVGL_Context *share_ctx,
Evas_GL_Context_Version version)
{
EVGL_Context *ctx = NULL;
@ -1839,6 +1841,13 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx)
return NULL;
}
if ((version < EVAS_GL_GLES_1_X) || (version > EVAS_GL_GLES_3_X))
{
ERR("Invalid context version number %d", version);
evas_gl_common_error_set(eng_data, EVAS_GL_BAD_PARAMETER);
return NULL;
}
// Allocate context object
ctx = calloc(1, sizeof(EVGL_Context));
if (!ctx)
@ -1849,9 +1858,9 @@ evgl_context_create(void *eng_data, EVGL_Context *share_ctx)
}
if (share_ctx)
ctx->context = evgl_engine->funcs->context_create(eng_data, share_ctx->context);
ctx->context = evgl_engine->funcs->context_create(eng_data, share_ctx->context, version);
else
ctx->context = evgl_engine->funcs->context_create(eng_data, NULL);
ctx->context = evgl_engine->funcs->context_create(eng_data, NULL, version);
// Call engine create context
if (!ctx->context)
@ -2229,11 +2238,19 @@ evgl_direct_info_clear()
}
Evas_GL_API *
evgl_api_get()
evgl_api_get(Evas_GL_Context_Version version)
{
_evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode);
return &gl_funcs;
if (version == EVAS_GL_GLES_2_X)
{
_evgl_api_get(&gl_funcs, evgl_engine->api_debug_mode);
return &gl_funcs;
}
else if (version == EVAS_GL_GLES_1_X)
{
_evgl_api_gles1_get(&gles1_funcs, evgl_engine->api_debug_mode);
return &gles1_funcs;
}
else return NULL;
}

View File

@ -26,14 +26,14 @@ EVGL_Engine *evgl_engine_init(void *eng_data, const EVGL_Interface *efunc);
void *evgl_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h);
void *evgl_pbuffer_surface_create(void *eng_data, Evas_GL_Config *cfg, int w, int h, const int *attrib_list);
int evgl_surface_destroy(void *eng_data, EVGL_Surface *sfc);
void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx);
void *evgl_context_create(void *eng_data, EVGL_Context *share_ctx, Evas_GL_Context_Version version);
int evgl_context_destroy(void *eng_data, EVGL_Context *ctx);
int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx);
const char *evgl_string_query(int name);
void *evgl_proc_address_get(const char *name);
int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
Evas_GL_API *evgl_api_get();
Evas_GL_API *evgl_api_get(Evas_GL_Context_Version version);
int evgl_direct_rendered();
void evgl_direct_override_get(int *override, int *force_off);

View File

@ -50,7 +50,7 @@ struct _EVGL_Interface
int (*surface_destroy)(void *data, void *surface);
// Creates/Destroys the native surface from evas engine.
void *(*context_create)(void *data, void *share_ctx);
void *(*context_create)(void *data, void *share_ctx, Evas_GL_Context_Version version);
int (*context_destroy)(void *data, void *context);
// Calls the make_current from evas_engine.
@ -134,6 +134,8 @@ struct _EVGL_Context
{
EVGLNative_Context context;
Evas_GL_Context_Version version;
// Context FBO
GLuint surface_fbo;
@ -301,9 +303,11 @@ extern EVGL_Engine *evgl_engine;
// Internally used functions
extern void _evgl_api_get(Evas_GL_API *api, int debug);
extern void _evgl_api_gles1_get(Evas_GL_API *api, Eina_Bool debug);
extern EVGL_Resource *_evgl_tls_resource_get(void);
extern EVGL_Resource *_evgl_tls_resource_create(void *data);
extern void _evgl_tls_resource_destroy(void *data);
extern EVGL_Context *_evgl_current_context_get(void);
extern int _evgl_not_in_pixel_get(void);
extern int _evgl_direct_enabled(void);
extern EVGLNative_Context _evgl_native_context_get(Evas_GL_Context *ctx);

View File

@ -84,7 +84,7 @@ static void *evgl_eng_native_window_create(void *data);
static int evgl_eng_native_window_destroy(void *data, void *native_window);
static void *evgl_eng_window_surface_create(void *data, void *native_window);
static int evgl_eng_window_surface_destroy(void *data, void *surface);
static void *evgl_eng_context_create(void *data, void *share_ctx);
static void *evgl_eng_context_create(void *data, void *share_ctx, int version);
static int evgl_eng_context_destroy(void *data, void *context);
static const char *evgl_eng_string_get(void *data);
static void *evgl_eng_proc_address_get(const char *name);
@ -405,7 +405,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
}
static void *
evgl_eng_context_create(void *data, void *share_ctx)
evgl_eng_context_create(void *data, void *share_ctx, int version)
{
Render_Engine *re = (Render_Engine *)data;
EGLContext context = EGL_NO_CONTEXT;
@ -417,6 +417,12 @@ evgl_eng_context_create(void *data, void *share_ctx)
return NULL;
}
if (version != EVAS_GL_GLES_2_X)
{
ERR("This engine only supports OpenGL-ES 2.0 contexts for now!");
return NULL;
}
context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
context_attrs[1] = 2;
context_attrs[2] = EGL_NONE;

View File

@ -1132,12 +1132,12 @@ eng_gl_surface_destroy(void *data, void *surface)
}
static void *
eng_gl_context_create(void *data, void *share_context)
eng_gl_context_create(void *data, void *share_context, int version)
{
EVGL_Context *sctx = (EVGL_Context *)share_context;
EVGLINIT(data, NULL);
return evgl_context_create(data, sctx);
return evgl_context_create(data, sctx, version);
}
static int
@ -1223,10 +1223,10 @@ eng_gl_native_surface_get(void *data EINA_UNUSED, void *surface, void *native_su
}
static void *
eng_gl_api_get(void *data)
eng_gl_api_get(void *data, int version)
{
EVGLINIT(data, NULL);
return evgl_api_get();
return evgl_api_get(version);
}

View File

@ -198,10 +198,16 @@ evgl_eng_window_surface_destroy(void *data EINA_UNUSED,
}
static void *
evgl_eng_context_create(void *data, void *share_ctx EINA_UNUSED)
evgl_eng_context_create(void *data, void *share_ctx EINA_UNUSED, int version)
{
Render_Engine *re = data;
if (version != EVAS_GL_GLES_2_X)
{
ERR("This engine only supports OpenGL-ES 2.0 contexts for now!");
return NULL;
}
SDL_GL_SetAttribute(SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 1);
return SDL_GL_CreateContext(re->generic.software.ob->window);
}

View File

@ -449,7 +449,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
}
static void *
evgl_eng_context_create(void *data, void *share_ctx)
evgl_eng_context_create(void *data, void *share_ctx, Evas_GL_Context_Version version)
{
Render_Engine *re = (Render_Engine *)data;
@ -461,12 +461,19 @@ evgl_eng_context_create(void *data, void *share_ctx)
return NULL;
}
if ((version < EVAS_GL_GLES_1_X) || (version > EVAS_GL_GLES_3_X))
{
ERR("Invalid context version number %d", version);
glsym_evas_gl_common_error_set(data, EVAS_GL_BAD_PARAMETER);
return NULL;
}
#ifdef GL_GLES
EGLContext context = EGL_NO_CONTEXT;
int context_attrs[3];
context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
context_attrs[1] = 2;
context_attrs[1] = version;
context_attrs[2] = EGL_NONE;
// Share context already assumes that it's sharing with evas' context
@ -477,6 +484,13 @@ evgl_eng_context_create(void *data, void *share_ctx)
(EGLContext)share_ctx,
context_attrs);
}
else if (version == EVAS_GL_GLES_1_X)
{
context = eglCreateContext(eng_get_ob(re)->egl_disp,
eng_get_ob(re)->egl_config,
NULL,
context_attrs);
}
else
{
context = eglCreateContext(eng_get_ob(re)->egl_disp,
@ -489,7 +503,7 @@ evgl_eng_context_create(void *data, void *share_ctx)
{
int err = eglGetError();
ERR("Engine Context Creations Failed. Error: %#x.", err);
glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
glsym_evas_gl_common_error_set(data, err - EGL_SUCCESS);
return NULL;
}
@ -505,6 +519,13 @@ evgl_eng_context_create(void *data, void *share_ctx)
(GLXContext)share_ctx,
1);
}
else if (version == EVAS_GL_GLES_1_X)
{
context = glXCreateContext(eng_get_ob(re)->info->info.display,
eng_get_ob(re)->visualinfo,
NULL,
1);
}
else
{
context = glXCreateContext(eng_get_ob(re)->info->info.display,

View File

@ -2410,12 +2410,19 @@ eng_gl_surface_destroy(void *data EINA_UNUSED, void *surface)
}
static void *
eng_gl_context_create(void *data EINA_UNUSED, void *share_context)
eng_gl_context_create(void *data EINA_UNUSED, void *share_context,
int version)
{
#ifdef EVAS_GL
Render_Engine_GL_Context *ctx;
Render_Engine_GL_Context *share_ctx;
if (version != EVAS_GL_GLES_2_X)
{
ERR("This engine only supports OpenGL-ES 2.0 contexts for now!");
return NULL;
}
ctx = calloc(1, sizeof(Render_Engine_GL_Context));
if (!ctx) return NULL;
@ -2596,8 +2603,11 @@ eng_gl_native_surface_get(void *data EINA_UNUSED, void *surface, void *native_su
static void *
eng_gl_api_get(void *data EINA_UNUSED)
eng_gl_api_get(void *data EINA_UNUSED, int version)
{
if (version != EVAS_GL_GLES_2_X)
return NULL;
#ifdef EVAS_GL
return &gl_funcs;
#else

View File

@ -323,7 +323,7 @@ evgl_eng_window_surface_destroy(void *data, void *surface)
}
static void *
evgl_eng_context_create(void *data, void *ctxt)
evgl_eng_context_create(void *data, void *ctxt, int version)
{
Render_Engine *re;
Outbuf *ob;
@ -333,6 +333,12 @@ evgl_eng_context_create(void *data, void *ctxt)
if (!(re = (Render_Engine *)data)) return NULL;
if (!(ob = eng_get_ob(re))) return NULL;
if (version != EVAS_GL_GLES_2_X)
{
ERR("This engine only supports OpenGL-ES 2.0 contexts for now!");
return NULL;
}
attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
attrs[1] = 2;
attrs[2] = EGL_NONE;