[pango/parse-color-with-alpha: 1/3] pango-color: Tweak semantics of _pango_parse_color_with_alpha




commit 08d372d657368711038f6c9c328cde18a6582123
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jul 31 13:43:02 2020 -0400

    pango-color: Tweak semantics of _pango_parse_color_with_alpha
    
    Make it return 0xffff if alpha is not present (this will
    be more convenient when we use this function in GdkRGBA).
    
    Update all users.

 pango/pango-color.c  | 5 +++--
 pango/pango-markup.c | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/pango/pango-color.c b/pango/pango-color.c
index 3c37c3d04..f06756fee 100644
--- a/pango/pango-color.c
+++ b/pango/pango-color.c
@@ -210,7 +210,7 @@ hex (const char *spec,
 /* Like pango_color_parse, but allow strings of the form
  * '&num;rgba', '&num;rrggbbaa', '&num;rrrrggggbbbbaaaa',
  * if alpha is not NULL. If no alpha component is found
- * in the string, *alpha is set to 0.
+ * in the string, *alpha is set to 0xffff.
  */
 gboolean
 _pango_color_parse_with_alpha (PangoColor *color,
@@ -220,7 +220,7 @@ _pango_color_parse_with_alpha (PangoColor *color,
   g_return_val_if_fail (spec != NULL, FALSE);
 
   if (alpha)
-    *alpha = 0;
+    *alpha = 0xffff;
 
   if (spec[0] == '#')
     {
@@ -294,6 +294,7 @@ _pango_color_parse_with_alpha (PangoColor *color,
     }
   return TRUE;
 }
+
 /**
  * pango_color_parse:
  * @color: (nullable): a #PangoColor structure in which to store the
diff --git a/pango/pango-markup.c b/pango/pango-markup.c
index a67e10fd9..5375a8e05 100644
--- a/pango/pango-markup.c
+++ b/pango/pango-markup.c
@@ -1622,7 +1622,7 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
        goto error;
 
       add_attribute (tag, pango_attr_foreground_new (color.red, color.green, color.blue));
-      if (alpha != 0)
+      if (alpha != 0xffff)
         add_attribute (tag, pango_attr_foreground_alpha_new (alpha));
     }
 
@@ -1635,7 +1635,7 @@ span_parse_func     (MarkupData            *md G_GNUC_UNUSED,
        goto error;
 
       add_attribute (tag, pango_attr_background_new (color.red, color.green, color.blue));
-      if (alpha != 0)
+      if (alpha != 0xffff)
         add_attribute (tag, pango_attr_background_alpha_new (alpha));
     }
 


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