Gradients: Don't store "current color" for gradient nodes

Gradient nodes don't need to store a has_current_color flag nor the
current color:  nodes for gradient stops already contain this
information, and they already resolve the current color themselves.
parent 03d7716b
......@@ -43,7 +43,7 @@
static void
_pattern_add_rsvg_color_stops (cairo_pattern_t * pattern,
GPtrArray * stops, guint32 current_color_rgb, guint8 opacity)
GPtrArray * stops, guint8 opacity)
{
gsize i;
RsvgGradientStop *stop;
......@@ -54,6 +54,7 @@ _pattern_add_rsvg_color_stops (cairo_pattern_t * pattern,
node = (RsvgNode *) g_ptr_array_index (stops, i);
if (RSVG_NODE_TYPE (node) != RSVG_NODE_TYPE_STOP)
continue;
stop = (RsvgGradientStop *) node;
rgba = stop->rgba;
cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
......@@ -67,7 +68,7 @@ _pattern_add_rsvg_color_stops (cairo_pattern_t * pattern,
static void
_set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
RsvgLinearGradient * linear,
guint32 current_color_rgb, guint8 opacity, RsvgBbox bbox)
guint8 opacity, RsvgBbox bbox)
{
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
cairo_t *cr = render->cr;
......@@ -78,9 +79,6 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
linear = &statlinear;
rsvg_linear_gradient_fix_fallback (ctx, linear);
if (linear->has_current_color)
current_color_rgb = linear->current_color;
if (linear->obj_bbox)
_rsvg_push_view_box (ctx, 1., 1.);
pattern = cairo_pattern_create_linear (_rsvg_css_normalize_length (&linear->x1, ctx),
......@@ -102,7 +100,7 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
cairo_pattern_set_matrix (pattern, &matrix);
cairo_pattern_set_extend (pattern, linear->spread);
_pattern_add_rsvg_color_stops (pattern, linear->super.children, current_color_rgb, opacity);
_pattern_add_rsvg_color_stops (pattern, linear->super.children, opacity);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
......@@ -111,7 +109,7 @@ _set_source_rsvg_linear_gradient (RsvgDrawingCtx * ctx,
static void
_set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
RsvgRadialGradient * radial,
guint32 current_color_rgb, guint8 opacity, RsvgBbox bbox)
guint8 opacity, RsvgBbox bbox)
{
RsvgCairoRender *render = RSVG_CAIRO_RENDER (ctx->render);
cairo_t *cr = render->cr;
......@@ -122,9 +120,6 @@ _set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
radial = &statradial;
rsvg_radial_gradient_fix_fallback (ctx, radial);
if (radial->has_current_color)
current_color_rgb = radial->current_color;
if (radial->obj_bbox)
_rsvg_push_view_box (ctx, 1., 1.);
......@@ -148,7 +143,7 @@ _set_source_rsvg_radial_gradient (RsvgDrawingCtx * ctx,
cairo_pattern_set_matrix (pattern, &matrix);
cairo_pattern_set_extend (pattern, radial->spread);
_pattern_add_rsvg_color_stops (pattern, radial->super.children, current_color_rgb, opacity);
_pattern_add_rsvg_color_stops (pattern, radial->super.children, opacity);
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
......@@ -336,9 +331,9 @@ _set_source_rsvg_paint_server (RsvgDrawingCtx * ctx,
if (node == NULL)
break;
else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_LINEAR_GRADIENT)
_set_source_rsvg_linear_gradient (ctx, (RsvgLinearGradient *) node, current_color_rgb, opacity, bbox);
_set_source_rsvg_linear_gradient (ctx, (RsvgLinearGradient *) node, opacity, bbox);
else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_RADIAL_GRADIENT)
_set_source_rsvg_radial_gradient (ctx, (RsvgRadialGradient *) node, current_color_rgb, opacity, bbox);
_set_source_rsvg_radial_gradient (ctx, (RsvgRadialGradient *) node, opacity, bbox);
else if (RSVG_NODE_TYPE (node) == RSVG_NODE_TYPE_PATTERN)
_set_source_rsvg_pattern (ctx, (RsvgPattern *) node, opacity, bbox);
......
......@@ -240,8 +240,6 @@ rsvg_linear_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "color")))
grad->current_color = rsvg_css_parse_color (value, 0);
if ((value = rsvg_property_bag_lookup (atts, "gradientUnits"))) {
if (!strcmp (value, "userSpaceOnUse"))
grad->obj_bbox = FALSE;
......@@ -268,7 +266,6 @@ rsvg_new_linear_gradient (void)
grad = g_new (RsvgLinearGradient, 1);
_rsvg_node_init (&grad->super, RSVG_NODE_TYPE_LINEAR_GRADIENT);
cairo_matrix_init_identity (&grad->affine);
grad->has_current_color = FALSE;
grad->x1 = rsvg_length_parse ("0", LENGTH_DIR_HORIZONTAL);
grad->y1 = grad->y2 = rsvg_length_parse ("0", LENGTH_DIR_VERTICAL);
grad->x2 = rsvg_length_parse ("1", LENGTH_DIR_HORIZONTAL);
......@@ -319,9 +316,6 @@ rsvg_radial_gradient_set_atts (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBa
rsvg_parse_transform (&grad->affine, value);
grad->hastransform = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "color"))) {
grad->current_color = rsvg_css_parse_color (value, 0);
}
if ((value = rsvg_property_bag_lookup (atts, "spreadMethod"))) {
if (!strcmp (value, "pad"))
grad->spread = CAIRO_EXTEND_PAD;
......@@ -357,7 +351,6 @@ rsvg_new_radial_gradient (void)
RsvgRadialGradient *grad = g_new (RsvgRadialGradient, 1);
_rsvg_node_init (&grad->super, RSVG_NODE_TYPE_RADIAL_GRADIENT);
cairo_matrix_init_identity (&grad->affine);
grad->has_current_color = FALSE;
grad->obj_bbox = TRUE;
grad->spread = CAIRO_EXTEND_PAD;
grad->fallback = NULL;
......
......@@ -56,8 +56,6 @@ struct _RsvgLinearGradient {
cairo_matrix_t affine; /* user space to actual at time of gradient def */
cairo_extend_t spread;
RsvgLength x1, y1, x2, y2;
guint32 current_color;
gboolean has_current_color;
int hasx1:1;
int hasy1:1;
int hasx2:1;
......@@ -74,8 +72,6 @@ struct _RsvgRadialGradient {
cairo_matrix_t affine; /* user space to actual at time of gradient def */
cairo_extend_t spread;
RsvgLength cx, cy, r, fx, fy;
guint32 current_color;
gboolean has_current_color;
int hascx:1;
int hascy:1;
int hasfx:1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment