[metacity/gnome-3-18] theme: fix gradients



commit e269d38465b0bff339145089031df337e18bd9ee
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Thu Jul 7 19:00:15 2016 +0300

    theme: fix gradients

 src/ui/theme.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/theme.c b/src/ui/theme.c
index b837774..06882c4 100644
--- a/src/ui/theme.c
+++ b/src/ui/theme.c
@@ -3925,17 +3925,23 @@ create_cairo_pattern_from_gradient_spec (const MetaGradientSpec      *spec,
       meta_color_spec_render (tmp->data, context, &color);
 
       if (alpha_spec != NULL)
-        cairo_pattern_add_color_stop_rgba (pattern, i / (gfloat) n_colors,
+        cairo_pattern_add_color_stop_rgba (pattern, i / (gfloat) (n_colors - 1),
                                            color.red, color.green, color.blue,
-                                           alpha_spec->alphas[i]);
+                                           alpha_spec->alphas[i] / 255.0);
       else
-        cairo_pattern_add_color_stop_rgb (pattern, i / (gfloat) n_colors,
+        cairo_pattern_add_color_stop_rgb (pattern, i / (gfloat) (n_colors - 1),
                                           color.red, color.green, color.blue);
 
       tmp = tmp->next;
       ++i;
     }
 
+  if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS)
+    {
+      cairo_pattern_destroy (pattern);
+      return NULL;
+    }
+
   return pattern;
 }
 


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