Commit 31c5c2db authored by Caleb Michael Moore's avatar Caleb Michael Moore

pserver domification

parent c29dd1c3
2005-05-20 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg_paint_server.c, rsvg_art_paint_server.c, rsvg.c: converted to use the new create->manipulate->use system.
2005-05-17 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg_structure.c: Fixed a problem with <use> not working.
......
......@@ -41,26 +41,28 @@
#include <math.h>
static ArtGradientStop *
rsvg_paint_art_stops_from_rsvg (RsvgGradientStops *rstops,
rsvg_paint_art_stops_from_rsvg (GPtrArray *rstops,
guint32 current_color)
{
ArtGradientStop *stops;
int n_stop = rstops->n_stop;
int n_stop = rstops->len;
int i;
stops = g_new (ArtGradientStop, n_stop);
for (i = 0; i < n_stop; i++)
{
RsvgGradientStop * stop;
guint32 rgba;
guint32 r, g, b, a;
stops[i].offset = rstops->stop[i].offset;
if (!rstops->stop[i].is_current_color)
rgba = rstops->stop[i].rgba;
stop = (RsvgGradientStop *)g_ptr_array_index(rstops, i);
stops[i].offset = stop->offset;
if (!stop->is_current_color)
rgba = stop->rgba;
else
rgba = current_color << 8;
/* convert from separated to premultiplied alpha */
a = rstops->stop[i].rgba & 0xff;
a = stop->rgba & 0xff;
r = (rgba >> 24) * a + 0x80;
r = (r + (r >> 8)) >> 8;
g = ((rgba >> 16) & 0xff) * a + 0x80;
......@@ -97,6 +99,7 @@ rsvg_art_paint_server_lin_grad_render (RsvgLinearGradient *rlg, ArtRender *ar,
const RsvgPSCtx *ctx)
{
ArtGradientLinear *agl;
RsvgLinearGradient statgrad = *rlg;
double x1, y1, x2, y2;
double dx, dy, scale;
double affine[6];
......@@ -107,18 +110,21 @@ rsvg_art_paint_server_lin_grad_render (RsvgLinearGradient *rlg, ArtRender *ar,
double px, py, pxt, pyt;
double x2t, y2t;
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->stops->n_stop == 0)
if (rlg->super.children->len == 0)
{
return;
}
agl = g_new (ArtGradientLinear, 1);
agl->n_stops = rlg->stops->n_stop;
agl->stops = rsvg_paint_art_stops_from_rsvg (rlg->stops, current_color);
agl->n_stops = rlg->super.children->len;
agl->stops = rsvg_paint_art_stops_from_rsvg (rlg->super.children, current_color);
if (rlg->obj_bbox) {
affine[0] = ctx->x1 - ctx->x0;
......@@ -217,10 +223,13 @@ static void
rsvg_art_paint_server_rad_grad_render (RsvgRadialGradient *rrg, ArtRender *ar,
const RsvgPSCtx *ctx)
{
RsvgRadialGradient statgrad = *rrg;
ArtGradientRadial *agr;
double aff1[6], aff2[6], affine[6];
guint32 current_color;
int i;
rrg = &statgrad;
rsvg_radial_gradient_fix_fallback(rrg);
if (rrg->obj_bbox) {
affine[0] = ctx->x1 - ctx->x0;
......@@ -241,13 +250,13 @@ rsvg_art_paint_server_rad_grad_render (RsvgRadialGradient *rrg, ArtRender *ar,
current_color = rrg->current_color;
else
current_color = ctx->color;
if (rrg->stops->n_stop == 0)
if (rrg->super.children->len == 0)
{
return;
}
agr = g_new (ArtGradientRadial, 1);
agr->n_stops = rrg->stops->n_stop;
agr->stops = rsvg_paint_art_stops_from_rsvg (rrg->stops, current_color);
agr->n_stops = rrg->super.children->len;
agr->stops = rsvg_paint_art_stops_from_rsvg (rrg->super.children, current_color);
_rsvg_affine_scale (aff1, rrg->r, rrg->r);
_rsvg_affine_translate (aff2, rrg->cx, rrg->cy);
......@@ -385,7 +394,8 @@ static void
rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
const RsvgPSCtx *ctx)
{
RsvgNode *drawable = (RsvgNode *)pattern;
RsvgPattern statpat = *pattern;
RsvgNode *drawable = (RsvgNode *)&statpat;
RsvgDrawingCtx *hctx = ctx->ctx;
GdkPixbuf *pixbuf = ((RsvgArtRender *)hctx->render)->pixbuf;
double affine[6];
......@@ -394,6 +404,9 @@ rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
gdouble minx, miny, maxx, maxy, xcoord, ycoord, xoffset, yoffset;
GdkPixbuf *save, *render;
pattern = &statpat;
rsvg_pattern_fix_fallback(pattern);
if (ctx->ctx == NULL)
return;
......@@ -471,7 +484,7 @@ rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
render = _rsvg_pixbuf_new_cleared(GDK_COLORSPACE_RGB, 1, 8,
maxx - minx, maxy - miny);
save = pixbuf;
((RsvgArtRender *)hctx->render)->pixbuf = render;
......@@ -487,11 +500,7 @@ rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
rsvg_state_current(hctx)->affine[i] = caffine[i];
}
if (drawable->children->len ||
pattern->fallback == NULL)
_rsvg_node_draw_children (drawable, hctx, 2);
else
_rsvg_node_draw_children (pattern->fallback, hctx, 2);
_rsvg_node_draw_children (drawable, hctx, 2);
rsvg_state_pop(ctx->ctx);
......
......@@ -610,7 +610,6 @@ rsvg_new_filter (void)
filter->super.type = RSVG_NODE_FILTER;
filter->super.free = rsvg_filter_free;
filter->super.draw = _rsvg_node_draw_nothing;
filter->super.add_child = rsvg_node_add_child;
filter->super.set_atts = rsvg_filter_set_args;
return &filter->super;
}
......@@ -1905,7 +1904,6 @@ rsvg_new_filter_primitive_merge (void)
filter->super.super.type = RSVG_NODE_FILTER_PRIMITIVE;
filter->super.super.set_atts = rsvg_filter_primitive_merge_set_atts;
filter->super.super.children = g_ptr_array_new();
filter->super.super.add_child = rsvg_node_add_child;
return (RsvgNode *)filter;
}
......@@ -4681,7 +4679,6 @@ rsvg_new_filter_primitive_diffuse_lighting (void)
filter->super.super.type = RSVG_NODE_FILTER_PRIMITIVE;
filter->super.super.set_atts = rsvg_filter_primitive_diffuse_lighting_set_atts;
filter->super.super.children = g_ptr_array_new();
filter->super.super.add_child = rsvg_node_add_child;
return (RsvgNode *)filter;
}
......@@ -4904,7 +4901,6 @@ rsvg_new_filter_primitive_specular_lighting (void)
filter->super.super.type = RSVG_NODE_FILTER_PRIMITIVE;
filter->super.super.set_atts = rsvg_filter_primitive_specular_lighting_set_atts;
filter->super.super.children = g_ptr_array_new();
filter->super.super.add_child = rsvg_node_add_child;
return (RsvgNode *)filter;
}
......
......@@ -112,7 +112,6 @@ rsvg_new_marker (void)
marker->super.children = g_ptr_array_new();
marker->super.free = rsvg_node_free;
marker->super.draw = _rsvg_node_draw_nothing;
marker->super.add_child = rsvg_node_add_child;
marker->super.set_atts = rsvg_node_marker_set_atts;
return &marker->super;
}
......
......@@ -108,7 +108,6 @@ rsvg_new_mask (void)
mask->super.type = RSVG_NODE_MASK;
mask->super.free = rsvg_node_free;
mask->super.draw = _rsvg_node_draw_nothing;
mask->super.add_child = rsvg_node_add_child;
mask->super.set_atts = rsvg_mask_set_atts;
return &mask->super;
}
......@@ -187,7 +186,6 @@ rsvg_new_clip_path (void)
clip_path->super.state = g_new(RsvgState, 1);
clip_path->super.type = RSVG_NODE_CLIP_PATH;
clip_path->super.free = rsvg_node_free;
clip_path->super.add_child = rsvg_node_add_child;
clip_path->super.draw = _rsvg_node_draw_nothing;
clip_path->super.set_atts = rsvg_clip_path_set_atts;
return &clip_path->super;
......
This diff is collapsed.
......@@ -60,39 +60,50 @@ struct _RsvgPSCtx {
};
struct _RsvgGradientStop {
RsvgNode super;
double offset;
gboolean is_current_color;
guint32 rgba;
};
struct _RsvgGradientStops {
int n_stop;
RsvgGradientStop *stop;
};
struct _RsvgLinearGradient {
RsvgNode super;
gboolean obj_bbox;
double affine[6]; /* user space to actual at time of gradient def */
RsvgGradientStops *stops;
RsvgGradientSpread spread;
double x1, y1;
double x2, y2;
guint32 current_color;
gboolean has_current_color;
int hasx1 : 1;
int hasy1 : 1;
int hasx2 : 1;
int hasy2 : 1;
int hastransform : 1;
int hasbbox : 1;
int hasspread : 1;
RsvgNode * fallback;
};
struct _RsvgRadialGradient {
RsvgNode super;
gboolean obj_bbox;
double affine[6]; /* user space to actual at time of gradient def */
RsvgGradientStops *stops;
RsvgGradientSpread spread;
double cx, cy;
double r;
double fx, fy;
guint32 current_color;
gboolean has_current_color;
int hascx : 1;
int hascy : 1;
int hasfx : 1;
int hasfy : 1;
int hasr : 1;
int hasspread : 1;
int hastransform : 1;
int hasbbox : 1;
RsvgNode * fallback;
};
struct _RsvgPattern {
......@@ -103,8 +114,17 @@ struct _RsvgPattern {
double affine[6]; /* user space to actual at time of gradient def */
double x, y, width, height;
double vbx, vby, vbh, vbw;
RsvgNode * fallback;
unsigned int preserve_aspect_ratio;
int hasx : 1;
int hasy : 1;
int haswidth : 1;
int hasheight : 1;
int hasvbox : 1;
int hasaspect : 1;
int hastransform : 1;
int hascbox : 1;
int hasbbox : 1;
RsvgPattern * fallback;
};
struct _RsvgSolidColour {
......@@ -153,17 +173,26 @@ rsvg_clone_radial_gradient (const RsvgRadialGradient *grad, gboolean * shallow_c
RsvgLinearGradient *
rsvg_clone_linear_gradient (const RsvgLinearGradient *grad, gboolean * shallow_cloned);
RsvgPattern *
rsvg_clone_pattern (const RsvgPattern *pattern);
RsvgNode *
rsvg_new_linear_gradient (void);
RsvgNode *
rsvg_new_radial_gradient (void);
RsvgNode *
rsvg_new_stop(void);
RsvgNode *
rsvg_new_pattern (void);
void
rsvg_start_linear_gradient (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_pattern_fix_fallback(RsvgPattern * pattern);
void
rsvg_start_radial_gradient (RsvgHandle *ctx, RsvgPropertyBag *atts, const char * tag);
rsvg_linear_gradient_fix_fallback(RsvgLinearGradient * grad);
void
rsvg_start_pattern (RsvgHandle *ctx, RsvgPropertyBag *atts);
rsvg_radial_gradient_fix_fallback(RsvgRadialGradient * grad);
G_END_DECLS
......
......@@ -201,7 +201,6 @@ struct _RsvgNode {
RsvgState * state;
RsvgNode * parent;
GPtrArray *children;
void (*add_child) (RsvgNode *self, RsvgNode *child);
void (*free) (RsvgNode *self);
void (*draw) (RsvgNode * self, RsvgDrawingCtx *ctx, int dominate);
void (*set_atts) (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag*);
......
......@@ -76,12 +76,6 @@ _rsvg_node_draw_nothing (RsvgNode * self, RsvgDrawingCtx *ctx,
{
}
void
rsvg_node_add_child (RsvgNode *self, RsvgNode *child)
{
g_ptr_array_add(self->children, child);
}
void
rsvg_node_free (RsvgNode *self)
{
......@@ -120,37 +114,11 @@ rsvg_new_group (void)
rsvg_state_init(group->super.state);
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_free;
group->super.add_child = rsvg_node_add_child;
group->super.draw = _rsvg_node_draw_children;
group->super.set_atts = rsvg_node_group_set_atts;
return &group->super;
}
RsvgNode *
rsvg_push_part_def_group (RsvgHandle *ctx, const char * id,
RsvgState *state)
{
RsvgNodeGroup *group;
group = g_new (RsvgNodeGroup, 1);
group->super.children = g_ptr_array_new();
group->super.state = g_new(RsvgState, 1);
*group->super.state = *state;
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_free;
group->super.draw = _rsvg_node_draw_children;
group->super.add_child = rsvg_node_add_child;
rsvg_defs_set (ctx->defs, id, &group->super);
group->super.parent = (RsvgNode *)ctx->currentnode;
ctx->currentnode = &group->super;
return &group->super;
}
void
rsvg_pop_def_group (RsvgHandle *ctx)
{
......@@ -161,7 +129,7 @@ rsvg_pop_def_group (RsvgHandle *ctx)
void
rsvg_node_group_pack (RsvgNode *self, RsvgNode *child)
{
self->add_child(self, child);
g_ptr_array_add(self->children, child);
child->parent = self;
}
......@@ -373,7 +341,6 @@ rsvg_new_svg (void)
svg->super.type = RSVG_NODE_PATH;
svg->super.free = rsvg_node_free;
svg->super.draw = rsvg_node_svg_draw;
svg->super.add_child = rsvg_node_add_child;
svg->super.set_atts = rsvg_node_svg_set_atts;
svg->overflow = FALSE;
return &svg->super;
......@@ -384,7 +351,6 @@ rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char *value = NULL, *klazz = NULL, *id = NULL;
double font_size;
gboolean got_width = FALSE, got_height = FALSE;
font_size = rsvg_state_current_font_size(ctx);
RsvgNodeUse * use;
......@@ -395,14 +361,10 @@ rsvg_node_use_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
use->x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
if ((value = rsvg_property_bag_lookup (atts, "y")))
use->y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
if ((value = rsvg_property_bag_lookup (atts, "width"))) {
if ((value = rsvg_property_bag_lookup (atts, "width")))
use->w = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->height, font_size);
got_width = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "height"))) {
if ((value = rsvg_property_bag_lookup (atts, "height")))
use->h = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
got_height = TRUE;
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
......@@ -519,7 +481,6 @@ rsvg_new_symbol(void)
symbol->super.type = RSVG_NODE_SYMBOL;
symbol->super.free = rsvg_node_free;
symbol->super.draw = rsvg_node_symbol_draw;
symbol->super.add_child = rsvg_node_add_child;
symbol->super.set_atts = rsvg_node_symbol_set_atts;
return &symbol->super;
}
......@@ -534,7 +495,6 @@ rsvg_new_defs ()
rsvg_state_init(group->super.state);
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_free;
group->super.add_child = rsvg_node_add_child;
group->super.draw = _rsvg_node_draw_nothing;
group->super.set_atts = rsvg_node_group_set_atts;
return &group->super;
......@@ -577,7 +537,6 @@ rsvg_new_switch (void)
rsvg_state_init(group->super.state);
group->super.type = RSVG_NODE_PATH;
group->super.free = rsvg_node_free;
group->super.add_child = rsvg_node_add_child;
group->super.draw = _rsvg_node_switch_draw;
group->super.set_atts = rsvg_node_group_set_atts;
return &group->super;
......
......@@ -73,11 +73,8 @@ struct _RsvgNodeSvg {
GdkPixbuf *img;
};
RsvgNode *
rsvg_push_part_def_group (RsvgHandle *ctx, const char * id, RsvgState *state);
void rsvg_pop_def_group (RsvgHandle *ctx);
void rsvg_node_group_pack (RsvgNode *self, RsvgNode *child);
void rsvg_node_add_child (RsvgNode *overself, RsvgNode *child);
void rsvg_node_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
int dominate);
......
......@@ -229,6 +229,16 @@ rsvg_filter_handler_start (RsvgHandle *ctx, const xmlChar *name,
newnode = rsvg_new_filter_primitive_light_source('s');
else if (!strcmp ((char *)name, "fePointLight"))
newnode = rsvg_new_filter_primitive_light_source('p');
else if (!strcmp ((char *)name, "stop"))
newnode = rsvg_new_stop ();
else if (!strcmp ((char *)name, "pattern"))
newnode = rsvg_new_pattern ();
else if (!strcmp ((char *)name, "linearGradient"))
newnode = rsvg_new_linear_gradient ();
else if (!strcmp ((char *)name, "radialGradient"))
newnode = rsvg_new_radial_gradient ();
else if (!strcmp ((char *)name, "conicalGradient"))
newnode = rsvg_new_radial_gradient ();
if (newnode)
{
rsvg_node_set_atts(newnode, ctx, atts);
......@@ -529,15 +539,6 @@ rsvg_start_element (void *data, const xmlChar *name,
rsvg_start_desc (ctx, bag);
else if (!strcmp ((char *)name, "metadata"))
rsvg_start_metadata (ctx, bag);
/* see conicalGradient discussion above */
else if (!strcmp ((char *)name, "linearGradient"))
rsvg_start_linear_gradient (ctx, bag);
else if (!strcmp ((char *)name, "radialGradient"))
rsvg_start_radial_gradient (ctx, bag, "radialGradient");
else if (!strcmp ((char *)name, "conicalGradient"))
rsvg_start_radial_gradient (ctx, bag, "conicalGradient");
else if (!strcmp ((char *)name, "pattern"))
rsvg_start_pattern (ctx, bag);
else if (!strcmp ((char *)name, "feFuncR"))
rsvg_start_filter_primitive_component_transfer_function(ctx, bag, 'r');
else if (!strcmp ((char *)name, "feFuncG"))
......@@ -590,7 +591,11 @@ rsvg_end_element (void *data, const xmlChar *name)
!strcmp ((char *)name, "svg") ||
!strcmp ((char *)name, "a") ||
!strcmp ((char *)name, "g") ||
!strcmp ((char *)name, "pattern"))
!strcmp ((char *)name, "pattern") ||
!strcmp ((char *)name, "linearGradient") ||
!strcmp ((char *)name, "radialGradient") ||
!strcmp ((char *)name, "conicalGradient") ||
!strcmp ((char *)name, "stop"))
{
printf ("ended %s\n", (char *)name);
rsvg_pop_def_group(ctx);
......
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