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)
downloadefl-56a64756eb727393092aacb0ce48429fab4a5591.tar.gz
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);
#define _EVASGL_EXT_FUNCTION_DRVFUNC(name) \
if ((*drvfunc) == NULL) *drvfunc = name;
+// This adds all the function names to the "safe" list but only one pointer
+// will be stored in the hash table.
#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name) \
- if ((*drvfunc) == NULL) *drvfunc = GETPROCADDR(name);
+ if ((*drvfunc) == NULL) \
+ { \
+ *drvfunc = GETPROCADDR(name); \
+ evgl_safe_extension_add(name, (void *) (*drvfunc)); \
+ } \
+ else evgl_safe_extension_add(name, NULL);
#include "evas_gl_api_ext_def.h"
@@ -403,8 +410,12 @@ evgl_api_ext_get(Evas_GL_API *gl_funcs)
#define _EVASGL_EXT_FUNCTION_DRVFUNC(name)
#define _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR(name)
+#undef _EVASGL_EXT_WHITELIST_ONLY
+#define _EVASGL_EXT_WHITELIST_ONLY 0
+
#include "evas_gl_api_ext_def.h"
+#undef _EVASGL_EXT_WHITELIST_ONLY
#undef _EVASGL_EXT_CHECK_SUPPORT
#undef _EVASGL_EXT_DISCARD_SUPPORT
#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 @@
#define _EVASGL_EXT_FUNCTION_PRIVATE_END_DEFINED
#endif
+#ifndef _EVASGL_EXT_WHITELIST_ONLY
+# define _EVASGL_EXT_WHITELIST_ONLY 1
+#endif
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// GL/GLES EXTENSIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -1081,6 +1085,28 @@ _EVASGL_EXT_END()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Other "safe" extensions that are not in Evas_GL_API
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+#if _EVASGL_EXT_WHITELIST_ONLY
+
+// TODO: Remove this function. Not actually supported. Just for debugging.
+_EVASGL_EXT_BEGIN(ARB_blend_func_extended)
+ _EVASGL_EXT_DRVNAME(GL_ARB_blend_func_extended)
+
+ _EVASGL_EXT_FUNCTION_BEGIN(int, glGetFragDataIndex, (uint program, const char * name))
+ _EVASGL_EXT_FUNCTION_DRVFUNC_PROCADDR("glGetFragDataIndex")
+ _EVASGL_EXT_FUNCTION_END()
+_EVASGL_EXT_END()
+
+#endif // _EVASGL_EXT_WHITELIST_ONLY ("safe" extensions)
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EGL EXTENSIONS
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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)
// Link to evas_gl.c (this doesn't look great)
glsym_evas_gl_native_context_get = dlsym(RTLD_DEFAULT, "_evas_gl_native_context_get");
+ evgl_engine->safe_extensions = eina_hash_string_small_new(NULL);
+
// Initialize Extensions
if (efunc->proc_address_get && efunc->ext_string_get)
{
@@ -1457,6 +1459,7 @@ evgl_engine_init(void *eng_data, const EVGL_Interface *efunc)
error:
if (evgl_engine)
{
+ eina_hash_free(evgl_engine->safe_extensions);
if (evgl_engine->resource_key)
eina_tls_free(evgl_engine->resource_key);
LKD(evgl_engine->resource_lock);
@@ -2213,11 +2216,48 @@ evgl_string_query(int name)
};
}
-void *
-evgl_proc_address_get(const char *name EINA_UNUSED)
+void
+evgl_safe_extension_add(const char *name, void *funcptr)
{
- // Will eventually deprecate this function
- return NULL;
+ if (!name) return;
+
+ if (funcptr)
+ eina_hash_set(evgl_engine->safe_extensions, name, funcptr);
+ else
+ eina_hash_set(evgl_engine->safe_extensions, name, (void*) 0x1);
+}
+
+Eina_Bool
+evgl_safe_extension_get(const char *name, void **pfuncptr)
+{
+ static Eina_Bool _unsafe_checked = EINA_FALSE, _unsafe = EINA_FALSE;
+ void *func;
+
+ if (!name || !*name)
+ return EINA_FALSE;
+
+ // use this for debugging or if you want to break everything
+ if (!_unsafe_checked)
+ {
+ if (getenv("EVAS_GL_UNSAFE_EXTENSIONS"))
+ _unsafe = EINA_TRUE;
+ }
+
+ if (_unsafe)
+ return EINA_TRUE;
+
+ func = eina_hash_find(evgl_engine->safe_extensions, name);
+ if (!func) return EINA_FALSE;
+
+ // this is for safe extensions of which we didn't resolve the address
+ if (func == (void *) 0x1)
+ {
+ if (pfuncptr) *pfuncptr = NULL;
+ return EINA_TRUE;
+ }
+
+ if (pfuncptr) *pfuncptr = func;
+ return EINA_TRUE;
}
int
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);
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_Context_Version version);
+void evgl_safe_extension_add(const char *name, void *funcptr);
+Eina_Bool evgl_safe_extension_get(const char *name, void **pfuncptr);
int evgl_direct_rendered();
void 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
Eina_List *direct_depth_stencil_surfaces;
//void *engine_data;
-
+ Eina_Hash *safe_extensions;
};
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)
{
Render_Engine_GL_Generic *re = data;
EVGLINIT(re, NULL);
+ void *func = NULL;
+
+ if (!evgl_safe_extension_get(name, &func))
+ {
+ DBG("The extension '%s' is not safe to use with Evas GL or is not "
+ "supported on this platform.", name);
+ return NULL;
+ }
+
+ if (func)
+ return func;
if (re->evgl_funcs && re->evgl_funcs->proc_address_get)
return re->evgl_funcs->proc_address_get(name);