From: Sangjin Kim Date: Wed, 12 Sep 2012 03:56:06 +0000 (+0900) Subject: [Title] Context update bug fix. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1444^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ed907d3ead053135e0dd7e6ed8f08ec55e8f41dd;p=sdk%2Femulator%2Fqemu.git [Title] Context update bug fix. [Type] bug fix [Module] opengl [Priority] [Issue#] N_SE-9949, N_SE-9950 [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index ab51323663..788fe9e6c6 100644 --- a/package/pkginfo.manifest +++ b/package/pkginfo.manifest @@ -1,4 +1,4 @@ -Version: 1.3.50 +Version: 1.3.51 Maintainer: Yeong-Kyoon Lee Source: emulator diff --git a/tizen/src/hw/gloffscreen.h b/tizen/src/hw/gloffscreen.h index 88bb2b2fdf..05e377a583 100644 --- a/tizen/src/hw/gloffscreen.h +++ b/tizen/src/hw/gloffscreen.h @@ -81,7 +81,7 @@ extern GloContext *glo_context_create(int formatFlags, GloContext *shareLists); extern void glo_context_destroy(GloContext *context); /* Update the context in surface and free previous light-weight context */ -extern void glo_surface_update_context(GloSurface *surface, GloContext *context); +extern int glo_surface_update_context(GloSurface *surface, GloContext *context); /* Link the pixmap associated with surface as texture */ extern void glo_surface_as_texture(GloSurface *surface); diff --git a/tizen/src/hw/gloffscreen_glx.c b/tizen/src/hw/gloffscreen_glx.c index ae10dc0eef..e3d9887a17 100644 --- a/tizen/src/hw/gloffscreen_glx.c +++ b/tizen/src/hw/gloffscreen_glx.c @@ -220,13 +220,24 @@ static void glo_surface_try_alloc_xshm_image(GloSurface *surface) { /* ------------------------------------------------------------------------ */ -/* Update the context in surface and free previous light-weight context */ -void glo_surface_update_context(GloSurface *surface, GloContext *context) -{ - if ( surface->context && (surface->context->context == 0)) - qemu_free(surface->context); - surface->context = context; +/* Update the context in surface and handle previous context */ +int glo_surface_update_context(GloSurface *surface, GloContext *context) + { + /* If previous context is light-weight context, just free it. If previous + * context is valid one binded with surface via MakeCurrent, we need unbind + * from original glstate */ + int prev_context_valid = 0; + + if ( surface->context ) + { + prev_context_valid = (surface->context->context != 0); + if ( !prev_context_valid ) /* light-weight context */ + g_free(surface->context); + } + surface->context = context; + return prev_context_valid; } + /* Create a surface with given width and height, formatflags are from the * GLO_ constants */ diff --git a/tizen/src/hw/gloffscreen_wgl.c b/tizen/src/hw/gloffscreen_wgl.c index 31fb74c10f..af0a5f0e78 100644 --- a/tizen/src/hw/gloffscreen_wgl.c +++ b/tizen/src/hw/gloffscreen_wgl.c @@ -794,12 +794,22 @@ void glo_context_destroy(GloContext *context) { /* ------------------------------------------------------------------------ */ -/* Update the context in surface and free previous light-weight context */ -void glo_surface_update_context(GloSurface *surface, GloContext *context) +/* Update the context in surface and handle previous context */ +int glo_surface_update_context(GloSurface *surface, GloContext *context) { - if ( surface->context && !surface->context->hDC) - g_free(surface->context); + /* If previous context is light-weight context, just free it. If previous + * context is valid one binded with surface via MakeCurrent, we need unbind + * from original glstate */ + int prev_context_valid = 0; + + if ( surface->context ) + { + prev_context_valid = (surface->context->context != 0); + if ( !prev_context_valid ) /* light-weight context */ + g_free(surface->context); + } surface->context = context; + return prev_context_valid; } /* Create a surface with given width and height, formatflags are from the diff --git a/tizen/src/hw/gloffscreen_xcomposite.c b/tizen/src/hw/gloffscreen_xcomposite.c index 55f59339b0..18af1927b7 100644 --- a/tizen/src/hw/gloffscreen_xcomposite.c +++ b/tizen/src/hw/gloffscreen_xcomposite.c @@ -255,12 +255,22 @@ static void glo_surface_try_alloc_xshm_image(GloSurface *surface) { /* ------------------------------------------------------------------------ */ -/* Update the context in surface and free previous light-weight context */ -void glo_surface_update_context(GloSurface *surface, GloContext *context) -{ - if ( surface->context && (surface->context->context == 0)) - g_free(surface->context); - surface->context = context; +/* Update the context in surface and handle previous context */ +int glo_surface_update_context(GloSurface *surface, GloContext *context) + { + /* If previous context is light-weight context, just free it. If previous + * context is valid one binded with surface via MakeCurrent, we need unbind + * from original glstate */ + int prev_context_valid = 0; + + if ( surface->context ) + { + prev_context_valid = (surface->context->context != 0); + if ( !prev_context_valid ) /* light-weight context */ + g_free(surface->context); + } + surface->context = context; + return prev_context_valid; } /* Create a surface with given width and height, formatflags are from the diff --git a/tizen/src/hw/opengl_exec.c b/tizen/src/hw/opengl_exec.c index f0582d4adb..f0f6a9390e 100644 --- a/tizen/src/hw/opengl_exec.c +++ b/tizen/src/hw/opengl_exec.c @@ -608,6 +608,18 @@ static void bind_qsurface(GLState *state, state->current_qsurface = qsurface; } +/* Unbind a qsurface from a context (GLState) */ +static void unbind_qsurface(GLState *state, + QGloSurface *qsurface) +{ + qsurface->glstate = NULL; + + QTAILQ_REMOVE(&state->qsurfaces, qsurface, next); + + /*XXX: need this?*/ + state->current_qsurface = NULL; +} + /* Find the qsurface with required drawable in active & pending qsurfaces */ QGloSurface* find_qsurface_from_client_drawable(ProcessState *process, ClientGLXDrawable client_drawable) { @@ -711,7 +723,8 @@ static int link_qsurface(ProcessState *process, GLState *glstate, ClientGLXDrawa /* process->pending_qsurfaces[i] = NULL;*/ qsurface->ref = 1; /* qsurface->surface->context = glstate->context;*/ - glo_surface_update_context(qsurface->surface, glstate->context); + if ( glo_surface_update_context(qsurface->surface, glstate->context) ) + unbind_qsurface(qsurface->glstate, qsurface); bind_qsurface(glstate, qsurface); return 1; }