forked from AuroraMiddleware/gtk
colorscale: Draw gradient using render nodes
Don't use Cairo when it's not needed.
This commit is contained in:
parent
438b4b6b5c
commit
8c43f22e3e
@ -110,6 +110,7 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
|||||||
else if (scale->priv->type == GTK_COLOR_SCALE_ALPHA)
|
else if (scale->priv->type == GTK_COLOR_SCALE_ALPHA)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
graphene_point_t start, end;
|
||||||
|
|
||||||
cr = gtk_snapshot_append_cairo (snapshot,
|
cr = gtk_snapshot_append_cairo (snapshot,
|
||||||
&GRAPHENE_RECT_INIT(x, y, width, height),
|
&GRAPHENE_RECT_INIT(x, y, width, height),
|
||||||
@ -121,6 +122,13 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
|||||||
{
|
{
|
||||||
cairo_translate (cr, width, 0);
|
cairo_translate (cr, width, 0);
|
||||||
cairo_scale (cr, -1, 1);
|
cairo_scale (cr, -1, 1);
|
||||||
|
graphene_point_init (&start, x + width, y);
|
||||||
|
graphene_point_init (&end, x, y);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
graphene_point_init (&start, x, y);
|
||||||
|
graphene_point_init (&end, x + width, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_pattern_t *pattern;
|
cairo_pattern_t *pattern;
|
||||||
@ -137,16 +145,20 @@ gtk_color_scale_snapshot_trough (GtkColorScale *scale,
|
|||||||
cairo_mask (cr, pattern);
|
cairo_mask (cr, pattern);
|
||||||
cairo_pattern_destroy (pattern);
|
cairo_pattern_destroy (pattern);
|
||||||
|
|
||||||
|
cairo_destroy (cr);
|
||||||
|
|
||||||
color = &scale->priv->color;
|
color = &scale->priv->color;
|
||||||
|
|
||||||
pattern = cairo_pattern_create_linear (0, 0, width, 0);
|
gtk_snapshot_append_linear_gradient (snapshot,
|
||||||
cairo_pattern_add_color_stop_rgba (pattern, 0, color->red, color->green, color->blue, 0);
|
&GRAPHENE_RECT_INIT(x, y, width, height),
|
||||||
cairo_pattern_add_color_stop_rgba (pattern, width, color->red, color->green, color->blue, 1);
|
&start,
|
||||||
cairo_set_source (cr, pattern);
|
&end,
|
||||||
cairo_paint (cr);
|
(GskColorStop[2]) {
|
||||||
cairo_pattern_destroy (pattern);
|
{ 0, { color->red, color->green, color->blue, 0 } },
|
||||||
|
{ 1, { color->red, color->green, color->blue, 1 } },
|
||||||
cairo_destroy (cr);
|
},
|
||||||
|
2,
|
||||||
|
"ColorAlphaGradient");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user