offscreen: only restore the cogl state if it had been modified

Make sure that the cogl_pop_matrix and cogl_pop_framebuffer functions are
only called in the post-paint handler if pre-paint was completed
successfully.
This commit is contained in:
Thomas Wood 2011-11-08 09:56:56 +00:00
parent 1ffda25ad3
commit 526426bc3f
1 changed files with 13 additions and 2 deletions

View File

@ -60,6 +60,8 @@ struct _MxOffscreenPrivate
guint in_dispose : 1;
guint pre_paint_done : 1;
ClutterActor *child;
CoglHandle fbo;
@ -780,9 +782,16 @@ mx_offscreen_pre_paint_cb (ClutterActor *actor,
MxOffscreen *offscreen)
{
CoglColor zero_colour;
gfloat width, height;
MxOffscreenPrivate *priv = offscreen->priv;
priv->pre_paint_done = FALSE;
clutter_actor_get_size (actor, &width, &height);
if (width * height < 1)
return FALSE;
if (!mx_offscreen_ensure_buffers (offscreen))
{
g_warning (G_STRLOC ": Unable to create necessary buffers");
@ -807,6 +816,8 @@ mx_offscreen_pre_paint_cb (ClutterActor *actor,
COGL_BUFFER_BIT_DEPTH);
}
priv->pre_paint_done = TRUE;
return TRUE;
}
@ -816,7 +827,7 @@ mx_offscreen_post_paint_cb (ClutterActor *actor,
{
MxOffscreenPrivate *priv = offscreen->priv;
if (!priv->fbo)
if (!priv->fbo || !priv->pre_paint_done)
return;
/* Restore state */