2008-04-01 Matthew Allum <mallum@openedhand.com>

* clutter/clutter-backend.c:
        * clutter/glx/clutter-backend-glx.c:
        * clutter/glx/clutter-stage-glx.c:
        Allow NULL to be passed to _clutter_backend_ensure_context
        which essentially clears GL context. This is hooked into stage
        unrealisation.  Isn't yet quite bulletproof.
        Fixes issues with gtk-embed crasher (thanks to Neil).
This commit is contained in:
Matthew Allum 2008-04-01 14:04:46 +00:00
parent d04fd6d620
commit c158a93a84
4 changed files with 47 additions and 12 deletions

View File

@ -1,3 +1,13 @@
2008-04-01 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-backend.c:
* clutter/glx/clutter-backend-glx.c:
* clutter/glx/clutter-stage-glx.c:
Allow NULL to be passed to _clutter_backend_ensure_context
which essentially clears GL context. This is hooked into stage
unrealisation. Isn't yet quite bulletproof.
Fixes issues with gtk-embed crasher (thanks to Neil).
2008-04-1 Robert Bragg <bob@o-hand.com> 2008-04-1 Robert Bragg <bob@o-hand.com>
* clutter/glx/clutter-glx-texture-pixmap.c: * clutter/glx/clutter-glx-texture-pixmap.c:

View File

@ -184,15 +184,25 @@ _clutter_backend_ensure_context (ClutterBackend *backend, ClutterStage *stage)
g_return_if_fail (CLUTTER_IS_BACKEND (backend)); g_return_if_fail (CLUTTER_IS_BACKEND (backend));
g_return_if_fail (CLUTTER_IS_STAGE (stage)); g_return_if_fail (CLUTTER_IS_STAGE (stage));
if (stage != current_context_stage) if (stage != current_context_stage || !CLUTTER_ACTOR_IS_REALIZED(stage))
{ {
klass = CLUTTER_BACKEND_GET_CLASS (backend); if (!CLUTTER_ACTOR_IS_REALIZED(stage))
stage = NULL;
klass = CLUTTER_BACKEND_GET_CLASS (backend);
if (G_LIKELY(klass->ensure_context)) if (G_LIKELY(klass->ensure_context))
klass->ensure_context (backend, stage); klass->ensure_context (backend, stage);
/* FIXME: With a NULL stage and thus no active context it may make more
* sense to clean the context but then re call with the default stage
* so at least there is some kind of context in place (as to avoid
* potential issue of GL calls with no context)
*/
current_context_stage = stage; current_context_stage = stage;
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); if (stage)
CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES);
} }
} }

View File

@ -350,16 +350,30 @@ clutter_backend_glx_ensure_context (ClutterBackend *backend,
ClutterBackendGLX *backend_glx; ClutterBackendGLX *backend_glx;
ClutterStageGLX *stage_glx; ClutterStageGLX *stage_glx;
ClutterStageX11 *stage_x11; ClutterStageX11 *stage_x11;
ClutterBackendX11 *backend_x11;
stage_x11 = CLUTTER_STAGE_X11(stage); if (stage == NULL)
stage_glx = CLUTTER_STAGE_GLX(stage); {
backend_glx = CLUTTER_BACKEND_GLX(backend); backend_x11 = CLUTTER_BACKEND_X11(backend);
CLUTTER_NOTE (MULTISTAGE, "Clearing all context");
CLUTTER_NOTE (MULTISTAGE, "setting context for stage:%p", stage ); glXMakeCurrent (backend_x11->xdpy, None, NULL);
}
else
{
stage_glx = CLUTTER_STAGE_GLX(stage);
stage_x11 = CLUTTER_STAGE_X11(stage);
backend_glx = CLUTTER_BACKEND_GLX(backend);
glXMakeCurrent (stage_x11->xdpy, g_return_if_fail (stage_x11->xwin != None);
stage_x11->xwin, g_return_if_fail (backend_glx->gl_context != None);
backend_glx->gl_context);
CLUTTER_NOTE (MULTISTAGE, "setting context for stage:%p", stage );
glXMakeCurrent (stage_x11->xdpy,
stage_x11->xwin,
backend_glx->gl_context);
}
} }
static void static void

View File

@ -99,7 +99,8 @@ clutter_stage_glx_unrealize (ClutterActor *actor)
stage_x11->xwin = None; stage_x11->xwin = None;
} }
glXMakeCurrent (stage_x11->xdpy, None, NULL); /* As unrealised the context will now get cleared */
clutter_stage_ensure_current (CLUTTER_STAGE(stage_glx));
XSync (stage_x11->xdpy, False); XSync (stage_x11->xdpy, False);