summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-10-24 21:25:08 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-11-14 10:43:00 +0900
commit56a64756eb727393092aacb0ce48429fab4a5591 (patch)
tree352d1ad70649f2ccf8a4c9d61f50684d4be67e27
parentcb534366f347e324bed9f3206c32383dd18a3f65 (diff)
Evas GL: Introduce concept of safe extensions
This will mark some extension functions as "safe", which means we don't need to wrap them in order to expose them. All the known extensions from Evas_GL_API have been marked as safe for now. In the future, we may encounter extensions that are not safe out of the box, but can be wrapped. At that time, we will have to mark them as safe but return the pointer to the wrapper instead. Until then, only whitelisted extensions will be supported. @feature
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext.c13
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h26
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.c48
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core.h3
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_core_private.h2
-rw-r--r--src/modules/evas/engines/gl_generic/evas_engine.c11
6 files changed, 96 insertions, 7 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
index 56809151bb..69175a67a9 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext.c
@@ -315,8 +315,15 @@ re->info->info.screen);
315#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) \ 315#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) \
316 if ((*drvfunc) == NULL) *drvfunc = name; 316 if ((*drvfunc) == NULL) *drvfunc = name;
317 317
318// This adds all the function names to the "safe" list but only one pointer
319// will be stored in the hash table.
318#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name) \ 320#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name) \
319 if ((*drvfunc) == NULL) *drvfunc = GETPROCADDR(name); 321 if ((*drvfunc) == NULL) \
322 { \
323 *drvfunc = GETPROCADDR(name); \
324 evgl_safe_extension_add(name, (void *) (*drvfunc)); \
325 } \
326 else evgl_safe_extension_add(name, NULL);
320 327
321#include "evas_gl_api_ext_def.h" 328#include "evas_gl_api_ext_def.h"
322 329
@@ -403,8 +410,12 @@ evgl_api_ext_get(Evas_GL_API *gl_funcs)
403#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) 410#define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
404#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name) 411#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
405 412
413#undef _EVASGL_EXT_WHITELIST_ONLY
414#define _EVASGL_EXT_WHITELIST_ONLY 0
415
406#include "evas_gl_api_ext_def.h" 416#include "evas_gl_api_ext_def.h"
407 417
418#undef _EVASGL_EXT_WHITELIST_ONLY
408#undef _EVASGL_EXT_CHECK_SUPPORT 419#undef _EVASGL_EXT_CHECK_SUPPORT
409#undef _EVASGL_EXT_DISCARD_SUPPORT 420#undef _EVASGL_EXT_DISCARD_SUPPORT
410#undef _EVASGL_EXT_BEGIN 421#undef _EVASGL_EXT_BEGIN
diff --git a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
index 1612aaf4c3..637f2972af 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_api_ext_def.h
@@ -47,6 +47,10 @@
47#define _EVASGL_EXT_FUNCTION_PRIVATE_END_DEFINED 47#define _EVASGL_EXT_FUNCTION_PRIVATE_END_DEFINED
48#endif 48#endif
49 49
50#ifndef _EVASGL_EXT_WHITELIST_ONLY
51# define _EVASGL_EXT_WHITELIST_ONLY 1
52#endif
53
50/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 54///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
51// GL/GLES EXTENSIONS 55// GL/GLES EXTENSIONS
52/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 56///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1081,6 +1085,28 @@ _EVASGL_EXT_END()
1081/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1085///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1082 1086
1083 1087
1088
1089///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1090// Other "safe" extensions that are not in Evas_GL_API
1091///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1092#if _EVASGL_EXT_WHITELIST_ONLY
1093
1094// TODO: Remove this function. Not actually supported. Just for debugging.
1095_EVASGL_EXT_BEGIN(ARB_blend_func_extended)
1096 _EVASGL_EXT_DRVNAME(GL_ARB_blend_func_extended)
1097
1098 _EVASGL_EXT_FUNCTION_BEGIN(int, glGetFragDataIndex, (uint program, const char * name))
1099 _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glGetFragDataIndex")
1100 _EVASGL_EXT_FUNCTION_END()
1101_EVASGL_EXT_END()
1102
1103#endif // _EVASGL_EXT_WHITELIST_ONLY ("safe" extensions)
1104
1105///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1106
1107
1108
1109
1084/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1110///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1085// EGL EXTENSIONS 1111// EGL EXTENSIONS
1086/////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1112///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.c b/src/modules/evas/engines/gl_common/evas_gl_core.c
index fb56d00062..7768af7d39 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.c
@@ -1398,6 +1398,8 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
1398 // Link to evas_gl.c (this doesn't look great) 1398 // Link to evas_gl.c (this doesn't look great)
1399 glsym_evas_gl_native_context_get = dlsym(RTLD_DEFAULT, "_evas_gl_native_context_get"); 1399 glsym_evas_gl_native_context_get = dlsym(RTLD_DEFAULT, "_evas_gl_native_context_get");
1400 1400
1401 evgl_engine->safe_extensions = eina_hash_string_small_new(NULL);
1402
1401 // Initialize Extensions 1403 // Initialize Extensions
1402 if (efunc->proc_address_get && efunc->ext_string_get) 1404 if (efunc->proc_address_get && efunc->ext_string_get)
1403 { 1405 {
@@ -1457,6 +1459,7 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
1457error: 1459error:
1458 if (evgl_engine) 1460 if (evgl_engine)
1459 { 1461 {
1462 eina_hash_free(evgl_engine->safe_extensions);
1460 if (evgl_engine->resource_key) 1463 if (evgl_engine->resource_key)
1461 eina_tls_free(evgl_engine->resource_key); 1464 eina_tls_free(evgl_engine->resource_key);
1462 LKD(evgl_engine->resource_lock); 1465 LKD(evgl_engine->resource_lock);
@@ -2213,11 +2216,48 @@ evgl_string_query(int name)
2213 }; 2216 };
2214} 2217}
2215 2218
2216void * 2219void
2217evgl_proc_address_get(const char *name EINA_UNUSED) 2220evgl_safe_extension_add(const char *name, void *funcptr)
2218{ 2221{
2219 // Will eventually deprecate this function 2222 if (!name) return;
2220 return NULL; 2223
2224 if (funcptr)
2225 eina_hash_set(evgl_engine->safe_extensions, name, funcptr);
2226 else
2227 eina_hash_set(evgl_engine->safe_extensions, name, (void*) 0x1);
2228}
2229
2230Eina_Bool
2231evgl_safe_extension_get(const char *name, void **pfuncptr)
2232{
2233 static Eina_Bool _unsafe_checked = EINA_FALSE, _unsafe = EINA_FALSE;
2234 void *func;
2235
2236 if (!name || !*name)
2237 return EINA_FALSE;
2238
2239 // use this for debugging or if you want to break everything
2240 if (!_unsafe_checked)
2241 {
2242 if (getenv("EVAS_GL_UNSAFE_EXTENSIONS"))
2243 _unsafe = EINA_TRUE;
2244 }
2245
2246 if (_unsafe)
2247 return EINA_TRUE;
2248
2249 func = eina_hash_find(evgl_engine->safe_extensions, name);
2250 if (!func) return EINA_FALSE;
2251
2252 // this is for safe extensions of which we didn't resolve the address
2253 if (func == (void *) 0x1)
2254 {
2255 if (pfuncptr) *pfuncptr = NULL;
2256 return EINA_TRUE;
2257 }
2258
2259 if (pfuncptr) *pfuncptr = func;
2260 return EINA_TRUE;
2221} 2261}
2222 2262
2223int 2263int
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core.h b/src/modules/evas/engines/gl_common/evas_gl_core.h
index afe322dcc1..f74a9c1656 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core.h
@@ -31,9 +31,10 @@ int evgl_context_destroy(void *eng_data, EVGL_Context *ctx);
31int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx); 31int evgl_make_current(void *eng_data, EVGL_Surface *sfc, EVGL_Context *ctx);
32 32
33const char *evgl_string_query(int name); 33const char *evgl_string_query(int name);
34void *evgl_proc_address_get(const char *name);
35int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns); 34int evgl_native_surface_get(EVGL_Surface *sfc, Evas_Native_Surface *ns);
36Evas_GL_API *evgl_api_get(Evas_GL_Context_Version version); 35Evas_GL_API *evgl_api_get(Evas_GL_Context_Version version);
36void evgl_safe_extension_add(const char *name, void *funcptr);
37Eina_Bool evgl_safe_extension_get(const char *name, void **pfuncptr);
37 38
38int evgl_direct_rendered(); 39int evgl_direct_rendered();
39void evgl_direct_override_get(int *override, int *force_off); 40void evgl_direct_override_get(int *override, int *force_off);
diff --git a/src/modules/evas/engines/gl_common/evas_gl_core_private.h b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
index 61c8c6cb6d..329f726f66 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_core_private.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_core_private.h
@@ -311,7 +311,7 @@ struct _EVGL_Engine
311 Eina_List *direct_depth_stencil_surfaces; 311 Eina_List *direct_depth_stencil_surfaces;
312 312
313 //void *engine_data; 313 //void *engine_data;
314 314 Eina_Hash *safe_extensions;
315}; 315};
316 316
317 317
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c
index b94c469199..989f68d133 100644
--- a/src/modules/evas/engines/gl_generic/evas_engine.c
+++ b/src/modules/evas/engines/gl_generic/evas_engine.c
@@ -1207,6 +1207,17 @@ eng_gl_proc_address_get(void *data, const char *name)
1207{ 1207{
1208 Render_Engine_GL_Generic *re = data; 1208 Render_Engine_GL_Generic *re = data;
1209 EVGLINIT(re, NULL); 1209 EVGLINIT(re, NULL);
1210 void *func = NULL;
1211
1212 if (!evgl_safe_extension_get(name, &func))
1213 {
1214 DBG("The extension '%s' is not safe to use with Evas GL or is not "
1215 "supported on this platform.", name);
1216 return NULL;
1217 }
1218
1219 if (func)
1220 return func;
1210 1221
1211 if (re->evgl_funcs && re->evgl_funcs->proc_address_get) 1222 if (re->evgl_funcs && re->evgl_funcs->proc_address_get)
1212 return re->evgl_funcs->proc_address_get(name); 1223 return re->evgl_funcs->proc_address_get(name);