summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-02-25 19:09:29 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-02-25 19:09:29 +0200
commit431e0418e05125d103a811b106f777eef7fe2aa7 (patch)
treef4635edc2d32f0c25d00d018616ba2ab07e4ab32
parent89d84a2bb85f60f49944a7c4973c3dbef9d653ce (diff)
downloadmetacity-431e0418e05125d103a811b106f777eef7fe2aa7.tar.gz
libmetacity: fix gradients with one alpha value
Commit 71d5decc42f3367bcbe2c4656356edd0f94d9feb ported gradient code from GdkPixbuf to cairo. Ported coded wrongly assumed that alpha values always match color stops.
-rw-r--r--libmetacity/meta-gradient-spec.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/libmetacity/meta-gradient-spec.c b/libmetacity/meta-gradient-spec.c
index cfb0f82e..79f1bd52 100644
--- a/libmetacity/meta-gradient-spec.c
+++ b/libmetacity/meta-gradient-spec.c
@@ -52,7 +52,7 @@ create_cairo_pattern_from_gradient_spec (const MetaGradientSpec *spec,
if (n_colors == 0)
return NULL;
- if (alpha_spec != NULL)
+ if (alpha_spec != NULL && alpha_spec->n_alphas != 1)
g_assert (n_colors == alpha_spec->n_alphas);
if (spec->type == META_GRADIENT_HORIZONTAL)
@@ -73,9 +73,18 @@ 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 - 1),
- color.red, color.green, color.blue,
- alpha_spec->alphas[i] / 255.0);
+ {
+ gdouble alpha;
+
+ if (alpha_spec->n_alphas == 1)
+ alpha = alpha_spec->alphas[0] / 255.0;
+ else
+ alpha = alpha_spec->alphas[i] / 255.0;
+
+ cairo_pattern_add_color_stop_rgba (pattern, i / (gfloat) (n_colors - 1),
+ color.red, color.green, color.blue,
+ alpha);
+ }
else
cairo_pattern_add_color_stop_rgb (pattern, i / (gfloat) (n_colors - 1),
color.red, color.green, color.blue);