diff options
author | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2017-02-25 19:39:44 +0200 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2017-02-25 19:39:44 +0200 |
commit | 54e7061408cbb47385c686335c6b41b7fa089ae2 (patch) | |
tree | b19c5e09d42de7fad9783caa4b0893c378398594 | |
parent | 72488dc76ee24a3e377ee7f788a9361f8cf4928c (diff) | |
download | metacity-54e7061408cbb47385c686335c6b41b7fa089ae2.tar.gz |
theme: fix gradients with one alpha value
Commit 71d5decc42f3367bcbe2c4656356edd0f94d9feb ported gradient
code from GdkPixbuf to cairo. Ported code wrongly assumed that
alpha values always match color stops.
-rw-r--r-- | src/ui/theme.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/ui/theme.c b/src/ui/theme.c index 06882c40..f88af225 100644 --- a/src/ui/theme.c +++ b/src/ui/theme.c @@ -3904,7 +3904,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) @@ -3925,9 +3925,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); |