clutter-offscreen-effect: Preserve the old opacity override
authorNeil Roberts <neil@linux.intel.com>
Thu, 3 Mar 2011 16:46:26 +0000 (16:46 +0000)
committerNeil Roberts <neil@linux.intel.com>
Thu, 3 Mar 2011 16:54:52 +0000 (16:54 +0000)
When removing the opacity override in the post_paint implementation,
ClutterOffscreenEffect would always set the override back to -1. This
ends up cancelling out the effect of any overrides from outer effects
which means that if any actor has multiple effects attached then it
would apply the opacity multiple times.

To fix this, the effect now preserves the old value of the opacity
override and restores that instead of setting -1.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2541

clutter/clutter-offscreen-effect.c

index 804a362..be2c2d1 100644 (file)
@@ -87,6 +87,8 @@ struct _ClutterOffscreenEffectPrivate
 
   gfloat target_width;
   gfloat target_height;
+
+  gint old_opacity_override;
 };
 
 G_DEFINE_ABSTRACT_TYPE (ClutterOffscreenEffect,
@@ -296,6 +298,8 @@ clutter_offscreen_effect_pre_paint (ClutterEffect *effect)
    * texture with the actor's paint opacity, so we need to do this to avoid
    * multiplying the opacity twice.
    */
+  priv->old_opacity_override =
+    _clutter_actor_get_opacity_override (priv->actor);
   _clutter_actor_set_opacity_override (priv->actor, 0xff);
 
   return TRUE;
@@ -354,8 +358,8 @@ clutter_offscreen_effect_post_paint (ClutterEffect *effect)
   cogl_matrix_translate (&modelview, priv->x_offset, priv->y_offset, 0.0f);
   cogl_set_modelview_matrix (&modelview);
 
-  /* Remove the opacity override */
-  _clutter_actor_set_opacity_override (priv->actor, -1);
+  /* Restore the previous opacity override */
+  _clutter_actor_set_opacity_override (priv->actor, priv->old_opacity_override);
 
   /* paint the target material; this is virtualized for
    * sub-classes that require special hand-holding