[Title] Context update bug fix.
authorSangjin Kim <sangjin3.kim@samsung.com>
Wed, 12 Sep 2012 03:56:06 +0000 (12:56 +0900)
committerSangjin Kim <sangjin3.kim@samsung.com>
Wed, 12 Sep 2012 03:56:06 +0000 (12:56 +0900)
[Type] bug fix
[Module] opengl
[Priority]
[Issue#] N_SE-9949, N_SE-9950
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

package/pkginfo.manifest
tizen/src/hw/gloffscreen.h
tizen/src/hw/gloffscreen_glx.c
tizen/src/hw/gloffscreen_wgl.c
tizen/src/hw/gloffscreen_xcomposite.c
tizen/src/hw/opengl_exec.c

index ab51323..788fe9e 100644 (file)
@@ -1,4 +1,4 @@
-Version: 1.3.50
+Version: 1.3.51
 Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
 Source: emulator
 
index 88bb2b2..05e377a 100644 (file)
@@ -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);
index ae10dc0..e3d9887 100644 (file)
@@ -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 */
index 31fb74c..af0a5f0 100644 (file)
@@ -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
index 55f5933..18af192 100644 (file)
@@ -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
index f0582d4..f0f6a93 100644 (file)
@@ -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;
         }