Commit b9499948 authored by Caleb Michael Moore's avatar Caleb Michael Moore

colour inheritance fix

parent fe8c0fa4
2005-08-10 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-styles.c: made a new function called rsvg_state_reconstruct that can make a style inherit from a node's ancestors rather than the drawing context.
* rsvg-paint-server.c: Made stop colour inheritance and currentColor usage work.
* rsvg-art-paint-server.c, rsvg-cairo-draw.c: removed redundant code in colour inheritance.
* rsvg-marker.c: use the new reconstruction function
2005-10-01 Dom Lachowicz <cinamod@hotmail.com>
* configure.in: bug 314593, support firefox-config
......
......@@ -41,8 +41,8 @@
#include <math.h>
static ArtGradientStop *
rsvg_paint_art_stops_from_rsvg (GPtrArray *rstops, guint32 * nstops,
guint32 current_color)
rsvg_paint_art_stops_from_rsvg (RsvgDrawingCtx * ctx, GPtrArray *rstops,
guint32 * nstops)
{
ArtGradientStop *stops;
unsigned int n_stop = rstops->len;
......@@ -69,10 +69,7 @@ rsvg_paint_art_stops_from_rsvg (GPtrArray *rstops, guint32 * nstops,
continue;
stop = (RsvgGradientStop *)temp;
stops[j].offset = stop->offset;
if (!stop->is_current_color)
rgba = stop->rgba;
else
rgba = current_color << 8;
rgba = stop->rgba;
/* convert from separated to premultiplied alpha */
a = stop->rgba & 0xff;
r = (rgba >> 24) * a + 0x80;
......@@ -121,7 +118,6 @@ rsvg_art_paint_server_lin_grad_render (RsvgLinearGradient *rlg, ArtRender *ar,
double x1, y1, x2, y2;
double dx, dy, scale;
double affine[6];
guint32 current_color;
double xchange, ychange, pointlen,unitlen;
double cx, cy, cxt, cyt;
double px, py, pxt, pyt;
......@@ -130,18 +126,15 @@ rsvg_art_paint_server_lin_grad_render (RsvgLinearGradient *rlg, ArtRender *ar,
rlg = &statgrad;
rsvg_linear_gradient_fix_fallback(rlg);
if (rlg->has_current_color)
current_color = rlg->current_color;
else
current_color = ctx->color;
if (rlg->super.children->len == 0)
{
return;
}
agl = g_new (ArtGradientLinear, 1);
agl->stops = rsvg_paint_art_stops_from_rsvg (rlg->super.children,
(guint32*)&agl->n_stops, current_color);
agl->stops = rsvg_paint_art_stops_from_rsvg (ctx->ctx,
rlg->super.children,
(guint32*)&agl->n_stops);
if (rlg->obj_bbox) {
......@@ -243,7 +236,6 @@ rsvg_art_paint_server_rad_grad_render (RsvgRadialGradient *rrg, ArtRender *ar,
RsvgRadialGradient statgrad = *rrg;
ArtGradientRadial *agr;
double aff1[6], aff2[6], affine[6];
guint32 current_color;
rrg = &statgrad;
rsvg_radial_gradient_fix_fallback(rrg);
......@@ -259,17 +251,13 @@ rsvg_art_paint_server_rad_grad_render (RsvgRadialGradient *rrg, ArtRender *ar,
} else
_rsvg_affine_multiply(affine, rrg->affine, ctx->affine);
if (rrg->has_current_color)
current_color = rrg->current_color;
else
current_color = ctx->color;
if (rrg->super.children->len == 0)
{
return;
}
agr = g_new (ArtGradientRadial, 1);
agr->stops = rsvg_paint_art_stops_from_rsvg (rrg->super.children,
(guint32*)&agr->n_stops, current_color);
agr->stops = rsvg_paint_art_stops_from_rsvg (ctx->ctx, rrg->super.children,
(guint32*)&agr->n_stops);
_rsvg_affine_scale (aff1, rrg->r, rrg->r);
_rsvg_affine_translate (aff2, rrg->cx, rrg->cy);
......
......@@ -54,10 +54,7 @@ _pattern_add_rsvg_color_stops (cairo_pattern_t *pattern,
if (node->type != RSVG_NODE_STOP)
continue;
stop = (RsvgGradientStop*) node;
if (stop->is_current_color)
rgba = current_color_rgb << 8;
else
rgba = stop->rgba;
rgba = stop->rgba;
cairo_pattern_add_color_stop_rgba (pattern, stop->offset,
((rgba >> 24) & 0xff) / 255.0,
((rgba >> 16) & 0xff) / 255.0,
......
......@@ -173,6 +173,8 @@ rsvg_marker_render (RsvgMarker *self, gdouble x, gdouble y, gdouble orient, gdou
rsvg_state_finalize(state);
rsvg_state_init(state);
rsvg_state_reconstruct(state, &self->super);
for (i = 0; i < 6; i++)
{
......
......@@ -203,11 +203,10 @@ rsvg_stop_set_atts (RsvgNode *self, RsvgHandle *ctx,
RsvgPropertyBag *atts)
{
double offset = 0;
RsvgState state;
gboolean is_current_color = FALSE;
const char *value;
RsvgGradientStop * stop;
rsvg_state_init(&state);
stop = (RsvgGradientStop *)self;
if (rsvg_property_bag_size (atts))
......@@ -224,14 +223,21 @@ rsvg_stop_set_atts (RsvgNode *self, RsvgHandle *ctx,
stop->offset = offset;
}
if ((value = rsvg_property_bag_lookup (atts, "style")))
rsvg_parse_style (ctx, &state, value);
rsvg_parse_style (ctx, self->state, value);
if ((value = rsvg_property_bag_lookup (atts, "stop-color")))
if (!strcmp(value, "currentColor"))
stop->is_current_color = TRUE;
rsvg_parse_style_pairs (ctx, &state, atts);
is_current_color = TRUE;
rsvg_parse_style_pairs (ctx, self->state, atts);
}
stop->rgba = (state.stop_color << 8) | state.stop_opacity;
self->parent = ctx->currentnode;
RsvgState state;
rsvg_state_init(&state);
rsvg_state_reconstruct(&state, self);
if (is_current_color)
state.stop_color = state.current_color;
stop->rgba = (state.stop_color << 8) | state.stop_opacity;
rsvg_state_finalize(&state);
}
......@@ -243,7 +249,6 @@ rsvg_new_stop (void)
stop->super.set_atts = rsvg_stop_set_atts;
stop->offset = 0;
stop->rgba = 0;
stop->is_current_color = 0;
stop->super.type = RSVG_NODE_STOP;
return &stop->super;
}
......@@ -303,6 +308,8 @@ rsvg_linear_gradient_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "linearGradient",
NULL, NULL, atts);
}
}
......@@ -388,6 +395,8 @@ rsvg_radial_gradient_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag
grad->obj_bbox = TRUE;
grad->hasbbox = TRUE;
}
rsvg_parse_style_attrs (ctx, self->state, "radialGradient",
NULL, NULL, atts);
}
}
......
......@@ -62,7 +62,6 @@ struct _RsvgPSCtx {
struct _RsvgGradientStop {
RsvgNode super;
double offset;
gboolean is_current_color;
guint32 rgba;
};
......
......@@ -216,11 +216,11 @@ rsvg_state_inherit_run (RsvgState *dst, const RsvgState *src,
dst->unicode_bidi = src->unicode_bidi;
if (function(dst->has_text_anchor, src->has_text_anchor))
dst->text_anchor = src->text_anchor;
if (function(dst->has_startMarker, !src->has_startMarker))
if (function(dst->has_startMarker, src->has_startMarker))
dst->startMarker = src->startMarker;
if (function(dst->has_middleMarker, !src->middleMarker))
if (function(dst->has_middleMarker, src->has_middleMarker))
dst->middleMarker = src->middleMarker;
if (function(dst->has_endMarker, !src->endMarker))
if (function(dst->has_endMarker, src->has_endMarker))
dst->endMarker = src->endMarker;
if (function(dst->has_font_family, src->has_font_family)) {
......@@ -1500,3 +1500,13 @@ rsvg_state_reinherit_top(RsvgDrawingCtx * ctx, RsvgState * state, int dominate)
}
}
}
void
rsvg_state_reconstruct(RsvgState * state,
RsvgNode * current)
{
if (current == NULL)
return;
rsvg_state_reconstruct(state, current->parent);
rsvg_state_inherit(state, current->state);
}
......@@ -205,6 +205,8 @@ void rsvg_state_push(RsvgDrawingCtx * ctx);
void rsvg_state_reinherit_top(RsvgDrawingCtx * ctx, RsvgState * state, int dominate);
void rsvg_state_reconstruct(RsvgState * state, RsvgNode * current);
G_END_DECLS
#endif /* RSVG_STYLES_H */
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