From 0cc41988811cb2a66c37290af2c0197bd0a0b0ba Mon Sep 17 00:00:00 2001 From: Stanislav Vorobiov Date: Tue, 13 May 2014 10:44:38 +0400 Subject: [PATCH] check_gl: cleanup allocated resources since check_gl is now being used inside qemu process we need to cleanup resources allocated by it Change-Id: Icb5ccf8e7ccc67e57c1ec856a1348c767599a95a Signed-off-by: Stanislav Vorobiov --- tizen/src/check_gl.h | 4 +++- tizen/src/check_gl_cgl.c | 4 ++++ tizen/src/check_gl_core.c | 30 ++++++++++++++++++++++++------ tizen/src/check_gl_glx.c | 16 +++++++++++++--- tizen/src/check_gl_wgl.c | 11 +++++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/tizen/src/check_gl.h b/tizen/src/check_gl.h index 6750e3c..89594a7 100644 --- a/tizen/src/check_gl.h +++ b/tizen/src/check_gl.h @@ -45,11 +45,13 @@ typedef enum gl_3_2 = 2 } gl_version; +int check_gl(void); + void check_gl_log(gl_log_level level, const char *format, ...); int check_gl_init(void); -int check_gl(void); +void check_gl_cleanup(void); struct gl_context *check_gl_context_create(struct gl_context *share_ctx, gl_version version); diff --git a/tizen/src/check_gl_cgl.c b/tizen/src/check_gl_cgl.c index c776325..379bab3 100644 --- a/tizen/src/check_gl_cgl.c +++ b/tizen/src/check_gl_cgl.c @@ -60,6 +60,10 @@ int check_gl_init(void) return 1; } +void check_gl_cleanup(void) +{ +} + struct gl_context *check_gl_context_create(struct gl_context *share_ctx, gl_version version) { diff --git a/tizen/src/check_gl_core.c b/tizen/src/check_gl_core.c index 6e48d66..3912a69 100644 --- a/tizen/src/check_gl_core.c +++ b/tizen/src/check_gl_core.c @@ -138,9 +138,10 @@ fail: int check_gl(void) { - struct gl_context *ctx_2; - struct gl_context *ctx_3_1; - struct gl_context *ctx_3_2; + int res = 1; + struct gl_context *ctx_2 = NULL; + struct gl_context *ctx_3_1 = NULL; + struct gl_context *ctx_3_2 = NULL; int have_es3 = 0; int have_es3_compatibility = 0; int have_es1 = 0; @@ -152,7 +153,7 @@ int check_gl(void) if (!check_gl_procaddr((void**)&get_string, "glGetString", 0) || !check_gl_procaddr((void**)&get_stringi, "glGetStringi", 1) || !check_gl_procaddr((void**)&get_integerv, "glGetIntegerv", 0)) { - return 1; + goto out; } ctx_2 = check_gl_version(gl_2); @@ -161,7 +162,7 @@ int check_gl(void) if (!ctx_2 && !ctx_3_1 && !ctx_3_2) { check_gl_log(gl_info, "Host does not have hardware GL acceleration!"); - return 1; + goto out; } have_es1 = (ctx_2 != NULL); @@ -247,5 +248,22 @@ int check_gl(void) check_gl_log(gl_info, "Host has hardware GL acceleration!"); - return 0; + res = 0; + +out: + if (ctx_2) { + check_gl_context_destroy(ctx_2); + } + + if (ctx_3_1) { + check_gl_context_destroy(ctx_3_1); + } + + if (ctx_3_2) { + check_gl_context_destroy(ctx_3_2); + } + + check_gl_cleanup(); + + return res; } diff --git a/tizen/src/check_gl_glx.c b/tizen/src/check_gl_glx.c index f8c13a8..8034c5c 100644 --- a/tizen/src/check_gl_glx.c +++ b/tizen/src/check_gl_glx.c @@ -104,7 +104,7 @@ int check_gl_init(void) if (!handle) { check_gl_log(gl_error, "%s", dlerror()); - return 0; + goto fail; } get_proc_address = dlsym(handle, "glXGetProcAddress"); @@ -115,7 +115,7 @@ int check_gl_init(void) if (!get_proc_address) { check_gl_log(gl_error, "%s", dlerror()); - return 0; + goto fail; } GLX_GET_PROC(choose_fb_config, glXChooseFBConfig); @@ -133,7 +133,7 @@ int check_gl_init(void) if (!configs || (n <= 0)) { check_gl_log(gl_error, "Unable to find suitable FB config"); - return 0; + goto fail; } x_config = configs[0]; @@ -141,6 +141,16 @@ int check_gl_init(void) XFree(configs); return 1; + +fail: + XCloseDisplay(x_dpy); + + return 0; +} + +void check_gl_cleanup(void) +{ + XCloseDisplay(x_dpy); } struct gl_context *check_gl_context_create(struct gl_context *share_ctx, diff --git a/tizen/src/check_gl_wgl.c b/tizen/src/check_gl_wgl.c index f447c5a..702b555 100644 --- a/tizen/src/check_gl_wgl.c +++ b/tizen/src/check_gl_wgl.c @@ -298,6 +298,17 @@ fail: return 0; } +void check_gl_cleanup(void) +{ + ReleaseDC(win, dc); + DestroyWindow(win); + delete_context(init_ctx); + ReleaseDC(init_win, init_dc); + DestroyWindow(init_win); + + UnregisterClassA((LPCTSTR)"CheckGLWinClass", NULL); +} + struct gl_context *check_gl_context_create(struct gl_context *share_ctx, gl_version version) { -- 2.7.4