From ed907d3ead053135e0dd7e6ed8f08ec55e8f41dd Mon Sep 17 00:00:00 2001 From: Sangjin Kim Date: Wed, 12 Sep 2012 12:56:06 +0900 Subject: [PATCH] [Title] Context update bug fix. [Type] bug fix [Module] opengl [Priority] [Issue#] N_SE-9949, N_SE-9950 [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- package/pkginfo.manifest | 2 +- tizen/src/hw/gloffscreen.h | 2 +- tizen/src/hw/gloffscreen_glx.c | 23 +++++++++++++++++------ tizen/src/hw/gloffscreen_wgl.c | 18 ++++++++++++++---- tizen/src/hw/gloffscreen_xcomposite.c | 22 ++++++++++++++++------ tizen/src/hw/opengl_exec.c | 15 ++++++++++++++- 6 files changed, 63 insertions(+), 19 deletions(-) diff --git a/package/pkginfo.manifest b/package/pkginfo.manifest index ab51323..788fe9e 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 88bb2b2..05e377a 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 ae10dc0..e3d9887 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 31fb74c..af0a5f0 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 55f5933..18af192 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 f0582d4..f0f6a93 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; } -- 2.7.4