clutter/offscreen-effect: Unref framebuffer on pre_paint

Move unreffing the framebuffer to ClutterOffscreenEffect.pre_paint().
This will allow us to properly chain up ClutterOffscreenEffect.paint()
and not reimplement exactly what ClutterEffect does by default.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1474
This commit is contained in:
Georges Basile Stavracas Neto 2020-06-27 22:18:45 -03:00
parent 67129c7757
commit f5c77df86c

View File

@ -272,10 +272,10 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
local_offset = GRAPHENE_POINT3D_INIT (0.0f, 0.0f, 0.0f); local_offset = GRAPHENE_POINT3D_INIT (0.0f, 0.0f, 0.0f);
if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect))) if (!clutter_actor_meta_get_enabled (CLUTTER_ACTOR_META (effect)))
return FALSE; goto disable_effect;
if (priv->actor == NULL) if (priv->actor == NULL)
return FALSE; goto disable_effect;
stage = _clutter_actor_get_stage_internal (priv->actor); stage = _clutter_actor_get_stage_internal (priv->actor);
clutter_actor_get_size (stage, &stage_width, &stage_height); clutter_actor_get_size (stage, &stage_width, &stage_height);
@ -320,7 +320,7 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
/* First assert that the framebuffer is the right size... */ /* First assert that the framebuffer is the right size... */
if (!update_fbo (effect, target_width, target_height, resource_scale)) if (!update_fbo (effect, target_width, target_height, resource_scale))
return FALSE; goto disable_effect;
framebuffer = clutter_paint_context_get_framebuffer (paint_context); framebuffer = clutter_paint_context_get_framebuffer (paint_context);
cogl_framebuffer_get_modelview_matrix (framebuffer, &old_modelview); cogl_framebuffer_get_modelview_matrix (framebuffer, &old_modelview);
@ -387,6 +387,10 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect,
clutter_actor_set_opacity_override (priv->actor, 0xff); clutter_actor_set_opacity_override (priv->actor, 0xff);
return TRUE; return TRUE;
disable_effect:
cogl_clear_object (&priv->offscreen);
return FALSE;
} }
static void static void
@ -510,8 +514,6 @@ clutter_offscreen_effect_paint (ClutterEffect *effect,
if (pre_paint_succeeded) if (pre_paint_succeeded)
effect_class->post_paint (effect, paint_context); effect_class->post_paint (effect, paint_context);
else
g_clear_pointer (&priv->offscreen, cogl_object_unref);
} }
else else
clutter_offscreen_effect_paint_texture (self, paint_context); clutter_offscreen_effect_paint_texture (self, paint_context);