summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-04-07 22:49:00 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-04-08 00:43:42 -0400
commit97fc6fbffe65d9ca4e92fc8979808faebed0ee35 (patch)
treeea92030296fb77bc4913f3ce0c3dd2d4c5046fdb /pango
parentbab5cf24b746527020f51548e020c410dee63f71 (diff)
downloadpango-97fc6fbffe65d9ca4e92fc8979808faebed0ee35.tar.gz
attributes: Make alpha work without color
Improve the behavior of the cairo renderer to take alpha into account even if no color specified. https://bugzilla.gnome.org/show_bug.cgi?id=773767
Diffstat (limited to 'pango')
-rw-r--r--pango/pangocairo-render.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/pango/pangocairo-render.c b/pango/pangocairo-render.c
index b1efb37f..73b1ae36 100644
--- a/pango/pangocairo-render.c
+++ b/pango/pangocairo-render.c
@@ -191,17 +191,38 @@ set_color (PangoCairoRenderer *crenderer,
PangoRenderPart part)
{
PangoColor *color = pango_renderer_get_color ((PangoRenderer *) (crenderer), part);
- guint16 alpha = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
+ guint16 a = pango_renderer_get_alpha ((PangoRenderer *) (crenderer), part);
+ gdouble red, green, blue, alpha;
- if (!alpha)
- alpha = 0xffff;
+ if (!a && !color)
+ return;
if (color)
- cairo_set_source_rgba (crenderer->cr,
- color->red / 65535.,
- color->green / 65535.,
- color->blue / 65535.,
- alpha / 65535.);
+ {
+ red = color->red / 65535.;
+ green = color->green / 65535.;
+ blue = color->blue / 65535.;
+ alpha = 1.;
+ }
+ else
+ {
+ cairo_pattern_t *pattern = cairo_get_source (crenderer->cr);
+
+ if (pattern && cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SOLID)
+ cairo_pattern_get_rgba (pattern, &red, &green, &blue, &alpha);
+ else
+ {
+ red = 0.;
+ green = 0.;
+ blue = 0.;
+ alpha = 1.;
+ }
+ }
+
+ if (a)
+ alpha = a / 65535.;
+
+ cairo_set_source_rgba (crenderer->cr, red, green, blue, alpha);
}
/* note: modifies crenderer->cr without doing cairo_save/restore() */