From: Stanislav Vorobiov Date: Tue, 13 May 2014 06:44:38 +0000 (+0400) Subject: check_gl: cleanup allocated resources X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~375^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0cc41988811cb2a66c37290af2c0197bd0a0b0ba;p=sdk%2Femulator%2Fqemu.git 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 --- diff --git a/tizen/src/check_gl.h b/tizen/src/check_gl.h index 6750e3ca17..89594a7a5e 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 c776325807..379bab38a9 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 6e48d66c8c..3912a696a4 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 f8c13a8245..8034c5c7f0 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 f447c5a1df..702b555de3 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) {