-Version: 1.3.50
+Version: 1.3.51
Maintainer: Yeong-Kyoon Lee<yeongkyoon.lee@samsung.com>
Source: emulator
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);
/* ------------------------------------------------------------------------ */
-/* 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 */
/* ------------------------------------------------------------------------ */
-/* 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
/* ------------------------------------------------------------------------ */
-/* 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
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)
{
/* 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;
}