[metacity/gnome-3-20] libmetacity: fix gradients with one alpha value
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [metacity/gnome-3-20] libmetacity: fix gradients with one alpha value
- Date: Sat, 25 Feb 2017 17:34:13 +0000 (UTC)
commit b30c1ce7becf908d3370c156a1227b030e861b8a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Feb 25 19:09:29 2017 +0200
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.
libmetacity/meta-gradient-spec.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/libmetacity/meta-gradient-spec.c b/libmetacity/meta-gradient-spec.c
index 5da0b1d..40fbafc 100644
--- a/libmetacity/meta-gradient-spec.c
+++ b/libmetacity/meta-gradient-spec.c
@@ -53,7 +53,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)
@@ -74,9 +74,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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]