summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-03-08 13:33:32 -0600
committerDerek Foreman <derekf@osg.samsung.com>2018-03-08 14:27:04 -0600
commit464d0ca9bb1146b48d42d8145245e93760bec9e8 (patch)
tree717f73b1bfa061bd539cfc812a0be91214b22dcc /src/modules/evas/engines
parentc7b44dfa2c199009ee735610a6d8d6f10c5d5b16 (diff)
gl_common: Replace strstr() for extension checks with a helper function
The helper incorporates NULL checks, and we love those, so it's better.
Diffstat (limited to 'src/modules/evas/engines')
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_common.h2
-rw-r--r--src/modules/evas/engines/gl_common/evas_gl_context.c56
2 files changed, 33 insertions, 25 deletions
diff --git a/src/modules/evas/engines/gl_common/evas_gl_common.h b/src/modules/evas/engines/gl_common/evas_gl_common.h
index a56dddb719..7ae78a799d 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_common.h
+++ b/src/modules/evas/engines/gl_common/evas_gl_common.h
@@ -563,6 +563,7 @@ EAPI void evas_gl_preload_render_lock(evas_gl_make_current_cb make_curre
563EAPI void evas_gl_preload_render_unlock(evas_gl_make_current_cb make_current, void *engine_data); 563EAPI void evas_gl_preload_render_unlock(evas_gl_make_current_cb make_current, void *engine_data);
564EAPI void evas_gl_preload_render_relax(evas_gl_make_current_cb make_current, void *engine_data); 564EAPI void evas_gl_preload_render_relax(evas_gl_make_current_cb make_current, void *engine_data);
565EAPI void evas_gl_symbols(void *(*GetProcAddress)(const char *name), const char *extsn); 565EAPI void evas_gl_symbols(void *(*GetProcAddress)(const char *name), const char *extsn);
566EAPI Eina_Bool evas_gl_extension_string_check(const char *ext, const char *exts);
566 567
567EAPI void evas_gl_common_error_set(int error_enum); 568EAPI void evas_gl_common_error_set(int error_enum);
568EAPI int evas_gl_common_error_get(void); 569EAPI int evas_gl_common_error_get(void);
@@ -577,6 +578,7 @@ typedef Evas_Engine_GL_Context *(*Evas_GL_Common_Context_New)(void);
577typedef void (*Evas_GL_Common_Context_Resize_Call)(Evas_Engine_GL_Context *gc, int w, int h, int rot); 578typedef void (*Evas_GL_Common_Context_Resize_Call)(Evas_Engine_GL_Context *gc, int w, int h, int rot);
578typedef int (*Evas_GL_Common_Buffer_Dump_Call)(Evas_Engine_GL_Context *gc,const char* dname, const char* fname, int frame, const char* suffix); 579typedef int (*Evas_GL_Common_Buffer_Dump_Call)(Evas_Engine_GL_Context *gc,const char* dname, const char* fname, int frame, const char* suffix);
579typedef void (*Evas_Gl_Symbols)(void *(*GetProcAddress)(const char *sym), const char *extsn); 580typedef void (*Evas_Gl_Symbols)(void *(*GetProcAddress)(const char *sym), const char *extsn);
581typedef Eina_Bool (*Evas_Gl_Extension_String_Check)(const char *exts, const char *ext);
580 582
581EAPI void __evas_gl_err(int err, const char *file, const char *func, int line, const char *op); 583EAPI void __evas_gl_err(int err, const char *file, const char *func, int line, const char *op);
582 584
diff --git a/src/modules/evas/engines/gl_common/evas_gl_context.c b/src/modules/evas/engines/gl_common/evas_gl_context.c
index cb1e3ad649..8294963dd1 100644
--- a/src/modules/evas/engines/gl_common/evas_gl_context.c
+++ b/src/modules/evas/engines/gl_common/evas_gl_context.c
@@ -84,6 +84,18 @@ sym_missing(void)
84 ERR("GL symbols missing!"); 84 ERR("GL symbols missing!");
85} 85}
86 86
87EAPI Eina_Bool
88evas_gl_extension_string_check(const char *exts, const char *ext)
89{
90 if (!exts || !ext) return EINA_FALSE;
91 return strstr(exts, ext) != NULL;
92}
93
94/* Totally gross, but I didn't want to reindent all the
95 * strstr() callers :(
96 */
97static Evas_Gl_Extension_String_Check _ckext = evas_gl_extension_string_check;
98
87static int 99static int
88_has_ext(const char *ext, const char **pexts, int *pnum) 100_has_ext(const char *ext, const char **pexts, int *pnum)
89{ 101{
@@ -114,17 +126,11 @@ _has_ext(const char *ext, const char **pexts, int *pnum)
114 if (!exts) return EINA_FALSE; 126 if (!exts) return EINA_FALSE;
115 *pexts = exts; 127 *pexts = exts;
116 } 128 }
117 return strstr(exts, ext) != NULL; 129 return _ckext(exts, ext);
118 } 130 }
119} 131}
120 132
121#ifdef GL_GLES 133#ifdef GL_GLES
122static int
123_has_extn(const char *ext, const char *exts)
124{
125 if (!exts || !ext) return EINA_FALSE;
126 return strstr(exts, ext) != NULL;
127}
128 134
129EAPI void * 135EAPI void *
130evas_gl_common_eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list) 136evas_gl_common_eglCreateImage(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list)
@@ -312,7 +318,7 @@ evas_gl_symbols(void *(*GetProcAddress)(const char *name), const char *extsn)
312#ifdef GL_GLES 318#ifdef GL_GLES
313#define FINDSYMN(dst, sym, ext, typ) do { \ 319#define FINDSYMN(dst, sym, ext, typ) do { \
314 if (!dst) { \ 320 if (!dst) { \
315 if (_has_extn(ext, extsn) && GetProcAddress) \ 321 if (_ckext(extsn, ext) && GetProcAddress) \
316 dst = (typ) GetProcAddress(sym); \ 322 dst = (typ) GetProcAddress(sym); \
317 if (!dst) \ 323 if (!dst) \
318 dst = (typ) dlsym(RTLD_DEFAULT, sym); \ 324 dst = (typ) dlsym(RTLD_DEFAULT, sym); \
@@ -887,41 +893,41 @@ evas_gl_common_context_new(void)
887 { 893 {
888 if (getenv("EVAS_GL_INFO")) 894 if (getenv("EVAS_GL_INFO"))
889 fprintf(stderr, "EXT:\n%s\n", ext); 895 fprintf(stderr, "EXT:\n%s\n", ext);
890 if ((strstr(ext, "GL_ARB_texture_non_power_of_two")) || 896 if ((_ckext(ext, "GL_ARB_texture_non_power_of_two")) ||
891 (strstr(ext, "OES_texture_npot")) || 897 (_ckext(ext, "OES_texture_npot")) ||
892 (strstr(ext, "GL_IMG_texture_npot"))) 898 (_ckext(ext, "GL_IMG_texture_npot")))
893 shared->info.tex_npo2 = 1; 899 shared->info.tex_npo2 = 1;
894 if ((strstr(ext, "GL_NV_texture_rectangle")) || 900 if ((_ckext(ext, "GL_NV_texture_rectangle")) ||
895 (strstr(ext, "GL_EXT_texture_rectangle")) || 901 (_ckext(ext, "GL_EXT_texture_rectangle")) ||
896 (strstr(ext, "GL_ARB_texture_rectangle"))) 902 (_ckext(ext, "GL_ARB_texture_rectangle")))
897 shared->info.tex_rect = 1; 903 shared->info.tex_rect = 1;
898 if ((strstr(ext, "GL_ARB_get_program_binary")) || 904 if ((_ckext(ext, "GL_ARB_get_program_binary")) ||
899 (strstr(ext, "GL_OES_get_program_binary"))) 905 (_ckext(ext, "GL_OES_get_program_binary")))
900 shared->info.bin_program = 1; 906 shared->info.bin_program = 1;
901 else 907 else
902 glsym_glGetProgramBinary = NULL; 908 glsym_glGetProgramBinary = NULL;
903#ifdef GL_UNPACK_ROW_LENGTH 909#ifdef GL_UNPACK_ROW_LENGTH
904 shared->info.unpack_row_length = 1; 910 shared->info.unpack_row_length = 1;
905# ifdef GL_GLES 911# ifdef GL_GLES
906 if (!strstr(ext, "_unpack_subimage")) 912 if (!_ckext(ext, "_unpack_subimage"))
907 shared->info.unpack_row_length = 0; 913 shared->info.unpack_row_length = 0;
908# endif 914# endif
909#endif 915#endif
910 916
911#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT 917#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
912 if ((strstr(ext, "GL_EXT_texture_filter_anisotropic"))) 918 if ((_ckext(ext, "GL_EXT_texture_filter_anisotropic")))
913 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, 919 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
914 &(shared->info.anisotropic)); 920 &(shared->info.anisotropic));
915#endif 921#endif
916#ifdef GL_BGRA 922#ifdef GL_BGRA
917 if ((strstr(ext, "GL_EXT_bgra")) || 923 if ((_ckext(ext, "GL_EXT_bgra")) ||
918 (strstr(ext, "GL_EXT_texture_format_BGRA8888"))) 924 (_ckext(ext, "GL_EXT_texture_format_BGRA8888")))
919 shared->info.bgra = 1; 925 shared->info.bgra = 1;
920#endif 926#endif
921 if (strstr(ext, "OES_compressed_ETC1_RGB8_texture")) 927 if (_ckext(ext, "OES_compressed_ETC1_RGB8_texture"))
922 shared->info.etc1 = 1; 928 shared->info.etc1 = 1;
923 if (strstr(ext, "GL_EXT_texture_compression_s3tc") || 929 if (_ckext(ext, "GL_EXT_texture_compression_s3tc") ||
924 strstr(ext, "GL_S3_s3tc")) 930 _ckext(ext, "GL_S3_s3tc"))
925 shared->info.s3tc = 1; 931 shared->info.s3tc = 1;
926#ifdef GL_GLES 932#ifdef GL_GLES
927 // FIXME: there should be an extension name/string to check for 933 // FIXME: there should be an extension name/string to check for
@@ -949,7 +955,7 @@ evas_gl_common_context_new(void)
949 (secsym_tbm_surface_get_info)) 955 (secsym_tbm_surface_get_info))
950 shared->info.sec_tbm_surface = 1; 956 shared->info.sec_tbm_surface = 1;
951#endif 957#endif
952 if (!strstr(ext, "GL_QCOM_tiled_rendering")) 958 if (!_ckext(ext, "GL_QCOM_tiled_rendering"))
953 { 959 {
954 glsym_glStartTiling = NULL; 960 glsym_glStartTiling = NULL;
955 glsym_glEndTiling = NULL; 961 glsym_glEndTiling = NULL;
@@ -1046,7 +1052,7 @@ evas_gl_common_context_new(void)
1046 // Note: If we support ETC2 we'll try to always use ETC2 even when the 1052 // Note: If we support ETC2 we'll try to always use ETC2 even when the
1047 // image has colorspace ETC1 (backwards compatibility). 1053 // image has colorspace ETC1 (backwards compatibility).
1048 1054
1049 if (ext && strstr(ext, "GL_EXT_compressed_ETC1_RGB8_sub_texture")) 1055 if (_ckext(ext, "GL_EXT_compressed_ETC1_RGB8_sub_texture"))
1050 shared->info.etc1_subimage = 1; 1056 shared->info.etc1_subimage = 1;
1051 else 1057 else
1052 shared->info.etc1_subimage = shared->info.etc2; 1058 shared->info.etc1_subimage = shared->info.etc2;