From c158a93a845e4f902272a42a150e373b3da1b802 Mon Sep 17 00:00:00 2001 From: Matthew Allum Date: Tue, 1 Apr 2008 14:04:46 +0000 Subject: [PATCH] 2008-04-01 Matthew Allum * 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). --- ChangeLog | 10 ++++++++++ clutter/clutter-backend.c | 18 ++++++++++++++---- clutter/glx/clutter-backend-glx.c | 28 +++++++++++++++++++++------- clutter/glx/clutter-stage-glx.c | 3 ++- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b78082..1447aa3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-04-01 Matthew Allum + + * 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 * clutter/glx/clutter-glx-texture-pixmap.c: diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index aedb393..2209060 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -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_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)) 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; - - CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); + + if (stage) + CLUTTER_SET_PRIVATE_FLAGS (stage, CLUTTER_ACTOR_SYNC_MATRICES); } } diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index 69f98d2..de6eaad 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -350,16 +350,30 @@ clutter_backend_glx_ensure_context (ClutterBackend *backend, ClutterBackendGLX *backend_glx; ClutterStageGLX *stage_glx; ClutterStageX11 *stage_x11; + ClutterBackendX11 *backend_x11; - stage_x11 = CLUTTER_STAGE_X11(stage); - stage_glx = CLUTTER_STAGE_GLX(stage); - backend_glx = CLUTTER_BACKEND_GLX(backend); + if (stage == NULL) + { + 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); + + g_return_if_fail (stage_x11->xwin != None); + g_return_if_fail (backend_glx->gl_context != None); - glXMakeCurrent (stage_x11->xdpy, - stage_x11->xwin, - 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 diff --git a/clutter/glx/clutter-stage-glx.c b/clutter/glx/clutter-stage-glx.c index 00dacbd..d7eb02b 100644 --- a/clutter/glx/clutter-stage-glx.c +++ b/clutter/glx/clutter-stage-glx.c @@ -99,7 +99,8 @@ clutter_stage_glx_unrealize (ClutterActor *actor) 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); -- 2.7.4