[clutter/clutter-1.18: 2/2] paint-nodes: Clarify color handling for TextureNode



commit bceca34ef9948ed1d0f3c1ee6793d8c97b291ac1
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Oct 10 13:37:11 2013 +0100

    paint-nodes: Clarify color handling for TextureNode
    
    The TextureNode premultiplies the blend color passed to the node
    constructor, so we need to document the fact properly to avoid
    causing premultiplication twice.
    
    We can also allow passing NULL for a color, and use a fully opaque
    white, to make the code slightly more friendly.

 clutter/clutter-paint-nodes.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)
---
diff --git a/clutter/clutter-paint-nodes.c b/clutter/clutter-paint-nodes.c
index 2b95d41..d1b574d 100644
--- a/clutter/clutter-paint-nodes.c
+++ b/clutter/clutter-paint-nodes.c
@@ -652,7 +652,7 @@ clutter_scaling_filter_to_cogl_pipeline_filter (ClutterScalingFilter filter)
 /**
  * clutter_texture_node_new:
  * @texture: a #CoglTexture
- * @color: a #ClutterColor
+ * @color: (allow-none): a #ClutterColor used for blending, or %NULL
  * @min_filter: the minification filter for the texture
  * @mag_filter: the magnification filter for the texture
  *
@@ -661,6 +661,10 @@ clutter_scaling_filter_to_cogl_pipeline_filter (ClutterScalingFilter filter)
  * This function will take a reference on @texture, so it is safe to
  * call cogl_object_unref() on @texture when it returns.
  *
+ * The @color must not be pre-multiplied with its #ClutterColor.alpha
+ * channel value; if @color is %NULL, a fully opaque white color will
+ * be used for blending.
+ *
  * Return value: (transfer full): the newly created #ClutterPaintNode.
  *   Use clutter_paint_node_unref() when done
  *
@@ -686,12 +690,18 @@ clutter_texture_node_new (CoglTexture          *texture,
   mag_f = clutter_scaling_filter_to_cogl_pipeline_filter (mag_filter);
   cogl_pipeline_set_layer_filters (tnode->pipeline, 0, min_f, mag_f);
 
-  cogl_color_init_from_4ub (&cogl_color,
-                            color->red,
-                            color->green,
-                            color->blue,
-                            color->alpha);
-  cogl_color_premultiply (&cogl_color);
+  if (color != NULL)
+    {
+      cogl_color_init_from_4ub (&cogl_color,
+                                color->red,
+                                color->green,
+                                color->blue,
+                                color->alpha);
+      cogl_color_premultiply (&cogl_color);
+    }
+  else
+    cogl_color_init_from_4ub (&cogl_color, 255, 255, 255, 255);
+
   cogl_pipeline_set_color (tnode->pipeline, &cogl_color);
 
   return (ClutterPaintNode *) tnode;


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