From: Stanislav Vorobiov Date: Fri, 29 Jun 2012 13:26:50 +0000 (+0400) Subject: Don't open new display on each query, just use the first one X-Git-Tag: TizenStudio_2.0_p2.3~1273^2~78 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fa22afaf96953f37884c9a4bc5d501eb2b61954;p=sdk%2Femulator%2Fqemu.git Don't open new display on each query, just use the first one --- diff --git a/gl/dgles2/src/EGL/degl.c b/gl/dgles2/src/EGL/degl.c index 66decd3..7034697 100644 --- a/gl/dgles2/src/EGL/degl.c +++ b/gl/dgles2/src/EGL/degl.c @@ -435,6 +435,8 @@ void deglFreeTLS(void) } } +void deglInitDisplayInternal(EGLNativeDisplayType display_id); + // Library initalizer. void deglInit(void) { @@ -775,6 +777,8 @@ void deglInit(void) degl_initialized = 1; Dprintf("Successfully initialized!\n"); + + deglInitDisplayInternal(EGL_DEFAULT_DISPLAY); } DGLES2_EXPORT degl_vbo* deglFindVBO(GLuint name) diff --git a/gl/dgles2/src/EGL/display.c b/gl/dgles2/src/EGL/display.c index 29f94a3..a16838f 100644 --- a/gl/dgles2/src/EGL/display.c +++ b/gl/dgles2/src/EGL/display.c @@ -19,6 +19,7 @@ */ #include +#include #include #include "common.h" #include "display.h" @@ -27,96 +28,107 @@ #include "context.h" pthread_once_t degl_init_control = PTHREAD_ONCE_INIT; +DEGLDisplay* degl_display = NULL; +void deglInitDisplayInternal(EGLNativeDisplayType display_id) +{ + degl_display = malloc(sizeof(DEGLDisplay)); + degl_display->initialized = 0; + degl_display->config_count = 0; + +# if(CONFIG_GLX == 1) + if(degl_backend == DEGLBackend_glx) + { + int display_opened = 0; + if(display_id == EGL_DEFAULT_DISPLAY) + { + if(!(display_id = XOpenDisplay(NULL))) + { + Dprintf("Can't open default display!\n"); + free(degl_display); + degl_display = NULL; + return; + } + display_opened = 1; + } + + Dprintf("Opened X11 display %p!\n", display_id); + + int error_base = 0, event_base = 0, glx_major = 0, glx_minor = 0; + Bool glx_ok = hglX.QueryExtension(display_id, &error_base, &event_base); + if(glx_ok == False) + { + Dprintf("glXQueryExtension failed!\n"); + } + else + { + glx_ok = hglX.QueryVersion(display_id, &glx_major, &glx_minor); + if(glx_ok == False) + { + Dprintf("glXQueryVersion failed!\n"); + } + else + { + if(glx_major < 1 || (glx_major == 1 && glx_minor < 1)) + { + Dprintf("Insufficient GLX version (%d.%d)!\n", + glx_major, glx_minor); + glx_ok = False; + } + else + { + Dprintf("GLX version %d.%d\n", glx_major, glx_minor); + } + } + } + if(glx_ok == False) + { + if(display_opened) + { + XCloseDisplay(display_id); + } + free(degl_display); + degl_display = NULL; + return; + } + + degl_display->dpy = display_id; + degl_display->scr = (Screen*)-1; + } + if(degl_frontend == DEGLFrontend_x11) + { + degl_display->x11_config = NULL; + } +# endif // (CONFIG_GLX == 1) + +# if(CONFIG_COCOA == 1) + if(degl_frontend == DEGLFrontend_cocoa) + { + degl_display->cocoa_config = NULL; + if(degl_display_id == EGL_DEFAULT_DISPLAY) + { + degl_display->id = CGMainDisplayID(); + } + else + { + degl_display->id = (CGDirectDisplayID)(uintptr_t)display_id; + } + } +# endif // (CONFIG_COCOA == 1) +} EGLAPI_BUILD EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { - extern void deglInit(void); - pthread_once(°l_init_control, deglInit); - - DEGLDisplay* display = malloc(sizeof(DEGLDisplay)); - display->initialized = 0; - display->config_count = 0; - -# if(CONFIG_GLX == 1) - if(degl_backend == DEGLBackend_glx) - { - int display_opened = 0; - if(display_id == EGL_DEFAULT_DISPLAY) - { - if(!(display_id = XOpenDisplay(NULL))) - { - Dprintf("Can't open default display!\n"); - free(display); - return EGL_NO_DISPLAY; - } - display_opened = 1; - } - - Dprintf("Opened X11 display %p!\n", display_id); - - int error_base = 0, event_base = 0, glx_major = 0, glx_minor = 0; - Bool glx_ok = hglX.QueryExtension(display_id, &error_base, &event_base); - if(glx_ok == False) - { - Dprintf("glXQueryExtension failed!\n"); - } - else - { - glx_ok = hglX.QueryVersion(display_id, &glx_major, &glx_minor); - if(glx_ok == False) - { - Dprintf("glXQueryVersion failed!\n"); - } - else - { - if(glx_major < 1 || (glx_major == 1 && glx_minor < 1)) - { - Dprintf("Insufficient GLX version (%d.%d)!\n", - glx_major, glx_minor); - glx_ok = False; - } - else - { - Dprintf("GLX version %d.%d\n", glx_major, glx_minor); - } - } - } - if(glx_ok == False) - { - if(display_opened) - { - XCloseDisplay(display_id); - } - free(display); - return EGL_NO_DISPLAY; - } + /* + * We always get default display + */ - display->dpy = display_id; - display->scr = (Screen*)-1; - } - if(degl_frontend == DEGLFrontend_x11) - { - display->x11_config = NULL; - } -# endif // (CONFIG_GLX == 1) + assert(display_id == EGL_DEFAULT_DISPLAY); -# if(CONFIG_COCOA == 1) - if(degl_frontend == DEGLFrontend_cocoa) - { - display->cocoa_config = NULL; - if(display_id == EGL_DEFAULT_DISPLAY) - { - display->id = CGMainDisplayID(); - } - else - { - display->id = (CGDirectDisplayID)(uintptr_t)display_id; - } - } -# endif // (CONFIG_COCOA == 1) + extern void deglInit(void); + pthread_once(°l_init_control, deglInit); - return display; + return degl_display; } #if(CONFIG_COCOA == 1)