[mutter] clutter/effect: Don't call effect paint_node() if pre_paint() failed



commit 791761499ae6f270c567584767b8f33bfb95bca4
Author: Sebastian Keller <skeller gnome org>
Date:   Tue Dec 29 18:43:22 2020 +0100

    clutter/effect: Don't call effect paint_node() if pre_paint() failed
    
    Some effects such as the BrightnessContrastEffect try to skip rendering
    by returning early with a FALSE return value in pre_paint() in cases
    where the effect would not change the rendering. This stopped working
    when effects were ported to paint nodes.
    
    In the case of OffscreenEffects, like BrightnessContrastEffect,
    pre_paint() is responsible for setting up the offscreen buffer which is
    then used in paint_node(). However if pre_paint() fails, this buffer is
    not created and attempting to use it will result in several error
    messages and broken rendering.
    
    Instead of trying to call paint_node() of the effect if pre_paint()
    failed, just draw the actor.
    
    Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1576
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1658>

 clutter/clutter/clutter-effect.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter/clutter-effect.c b/clutter/clutter/clutter-effect.c
index 3c9d8efd5d..012037f614 100644
--- a/clutter/clutter/clutter-effect.c
+++ b/clutter/clutter/clutter-effect.c
@@ -201,10 +201,8 @@ clutter_effect_real_modify_paint_volume (ClutterEffect      *effect,
 }
 
 static void
-clutter_effect_real_paint_node (ClutterEffect           *effect,
-                                ClutterPaintNode        *node,
-                                ClutterPaintContext     *paint_context,
-                                ClutterEffectPaintFlags  flags)
+add_actor_node (ClutterEffect    *effect,
+                ClutterPaintNode *node)
 {
   ClutterPaintNode *actor_node;
   ClutterActor *actor;
@@ -216,6 +214,15 @@ clutter_effect_real_paint_node (ClutterEffect           *effect,
   clutter_paint_node_unref (actor_node);
 }
 
+static void
+clutter_effect_real_paint_node (ClutterEffect           *effect,
+                                ClutterPaintNode        *node,
+                                ClutterPaintContext     *paint_context,
+                                ClutterEffectPaintFlags  flags)
+{
+  add_actor_node (effect, node);
+}
+
 static void
 clutter_effect_real_paint (ClutterEffect           *effect,
                            ClutterPaintNode        *node,
@@ -231,10 +238,16 @@ clutter_effect_real_paint (ClutterEffect           *effect,
 
   pre_paint_succeeded = effect_class->pre_paint (effect, node,paint_context);
 
-  effect_class->paint_node (effect, node, paint_context, flags);
-
   if (pre_paint_succeeded)
-    effect_class->post_paint (effect, node, paint_context);
+    {
+      effect_class->paint_node (effect, node, paint_context, flags);
+      effect_class->post_paint (effect, node, paint_context);
+    }
+  else
+    {
+      /* Just paint the actor as fallback */
+      add_actor_node (effect, node);
+    }
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]