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

further DOM restructuring

parent cf2e610b
2005-05-17 Caleb Moore <c.moore@student.unsw.edu.au>
* A_whole_bunch_o'_files: Did a bit of fiddling. Now Children are stored in the RsvgNode structure, since DOM seems to mandate that everything be able to have children. I shall get rid of virtual functions for adding children soon.
* rsvg-filters.c: Made merge nodes and light sources proper objects.
* rsvg-marker.c: Converted markers to use the new system and broke them BADLY.
* rsvg-structures.c: made structual element relating functions a bit more generic. Saves some code duplication.
2005-05-16 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-filter.c, rsvg-structure.c, rsvg-mask.c, rsvg.c: more DOM stuff. Now orthodox nodes are created, then attributes are assigned then are packed onto the top of the tree. I have moved all conforming node creation bits to rsvg-filter-handler-start so I remember what's left to convert. Probably opened a few bugs, you know how it is. Theoretically, it is now possible to implement external DOM interfaces to create new nodes and add nodes to other nodes. Attributes can be edited as much as the user wants for many elements now.
......
......@@ -131,9 +131,9 @@ rsvg_art_clip_path_render (RsvgClipPath * self, RsvgDrawingCtx *ctx)
save = ctx->render;
ctx->render = (RsvgRender *)asvpr;
for (i = 0; i < group->children->len; i++)
for (i = 0; i < group->super.children->len; i++)
{
rsvg_node_draw (g_ptr_array_index(group->children, i),
rsvg_node_draw (g_ptr_array_index(group->super.children, i),
ctx, 0);
}
......@@ -163,7 +163,7 @@ rsvg_art_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, RsvgDrawin
((RsvgArtRender *)ctx->render)->pixbuf = mask;
rsvg_state_push(ctx);
rsvg_node_mask_draw (self, ctx, 0);
_rsvg_node_draw_children ((RsvgNode *)self, ctx, 0);
rsvg_state_pop(ctx);
((RsvgArtRender *)ctx->render)->pixbuf = save;
......
......@@ -385,7 +385,7 @@ static void
rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
const RsvgPSCtx *ctx)
{
RsvgNode *drawable = (RsvgNode *)pattern->g;
RsvgNode *drawable = (RsvgNode *)pattern;
RsvgDrawingCtx *hctx = ctx->ctx;
GdkPixbuf *pixbuf = ((RsvgArtRender *)hctx->render)->pixbuf;
double affine[6];
......@@ -487,11 +487,11 @@ rsvg_art_paint_server_pattern_render (RsvgPattern *pattern, ArtRender *ar,
rsvg_state_current(hctx)->affine[i] = caffine[i];
}
if (((RsvgNodeGroup *)drawable)->children->len ||
pattern->gfallback == NULL)
rsvg_node_draw (drawable, hctx, 2);
if (drawable->children->len ||
pattern->fallback == NULL)
_rsvg_node_draw_children (drawable, hctx, 2);
else
rsvg_node_draw ((RsvgNode *)pattern->gfallback, hctx, 2);
_rsvg_node_draw_children (pattern->fallback, hctx, 2);
rsvg_state_pop(ctx->ctx);
......
......@@ -321,9 +321,9 @@ rsvg_filter_render (RsvgFilter * self, GdkPixbuf * source, GdkPixbuf * output,
ctx->lastresult.Aused = 1;
ctx->lastresult.bounds = rsvg_filter_primitive_get_bounds (NULL, ctx);
for (i = 0; i < self->primitives->len; i++)
for (i = 0; i < self->super.children->len; i++)
{
current = g_ptr_array_index (self->primitives, i);
current = g_ptr_array_index (self->super.children, i);
rsvg_filter_primitive_render (current, ctx);
}
......@@ -527,29 +527,6 @@ rsvg_filter_parse (const RsvgDefs * defs, const char *str)
return NULL;
}
static void
rsvg_filter_add_child (RsvgNode *overself, RsvgNode *child)
{
RsvgFilter *self = (RsvgFilter *)overself;
g_ptr_array_add (self->primitives, child);
}
/**
* rsvg_filter_free: Free a filter.
* @dself: The defval to be freed
*
* Frees a filter and all primatives associated with this filter, this is
* to be set as its free function to be used with rsvg defs
**/
static void
rsvg_filter_free (RsvgNode * dself)
{
RsvgFilter *self;
self = (RsvgFilter *) dself;
g_ptr_array_free(self->primitives, FALSE);
}
static void
rsvg_filter_set_args (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
{
......@@ -605,6 +582,13 @@ rsvg_filter_set_args (RsvgNode * self, RsvgHandle * ctx, RsvgPropertyBag * atts)
}
}
static void
rsvg_filter_free (RsvgNode *self)
{
g_ptr_array_free(self->children, TRUE);
g_free (self);
}
/**
* rsvg_new_filter: Creates a black filter
*
......@@ -622,10 +606,11 @@ rsvg_new_filter (void)
filter->y = -0.1;
filter->width = 1.2;
filter->height = 1.2;
filter->primitives = g_ptr_array_new ();
filter->super.children = g_ptr_array_new ();
filter->super.type = RSVG_NODE_FILTER;
filter->super.free = rsvg_filter_free;
filter->super.add_child = rsvg_filter_add_child;
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;
}
......@@ -1819,7 +1804,6 @@ typedef struct _RsvgFilterPrimitiveMerge RsvgFilterPrimitiveMerge;
struct _RsvgFilterPrimitiveMerge
{
RsvgFilterPrimitive super;
GPtrArray *nodes;
};
static void
......@@ -1839,9 +1823,9 @@ rsvg_filter_primitive_merge_render (RsvgFilterPrimitive * self,
output = _rsvg_pixbuf_new_cleared (GDK_COLORSPACE_RGB, 1, 8, ctx->width, ctx->height);
for (i = 0; i < mself->nodes->len; i++)
for (i = 0; i < mself->super.super.children->len; i++)
{
in = rsvg_filter_get_in (g_ptr_array_index (mself->nodes, i), ctx);
in = rsvg_filter_get_in (g_ptr_array_index (mself->super.super.children, i), ctx);
rsvg_art_alpha_blt (in, boundarys.x1, boundarys.y1, boundarys.x2 - boundarys.x1,
boundarys.y2 - boundarys.y1, output, boundarys.x1,
boundarys.y1);
......@@ -1857,14 +1841,11 @@ static void
rsvg_filter_primitive_merge_free (RsvgNode * self)
{
RsvgFilterPrimitiveMerge *mself;
guint i;
mself = (RsvgFilterPrimitiveMerge *) self;
g_string_free (mself->super.result, TRUE);
for (i = 0; i < mself->nodes->len; i++)
g_string_free (g_ptr_array_index (mself->nodes, i), TRUE);
g_ptr_array_free (mself->nodes, TRUE);
g_ptr_array_free (mself->super.super.children, TRUE);
g_free (mself);
}
......@@ -1931,39 +1912,48 @@ rsvg_new_filter_primitive_merge (void)
filter = g_new (RsvgFilterPrimitiveMerge, 1);
filter->super.result = g_string_new ("none");
filter->super.sizedefaults = 1;
filter->nodes = g_ptr_array_new ();
filter->super.render = &rsvg_filter_primitive_merge_render;
filter->super.super.free = &rsvg_filter_primitive_merge_free;
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;
}
void
rsvg_start_filter_primitive_merge_node (RsvgHandle * ctx,
RsvgPropertyBag * atts)
static void
rsvg_filter_primitive_merge_node_set_atts (RsvgNode * self,
RsvgHandle * ctx,
RsvgPropertyBag * atts)
{
const char *value;
int needdefault = 1;
if (!(ctx && ctx->currentnode))
return;
const char * value;
if (rsvg_property_bag_size (atts))
{
/* see bug 145149 - sodipodi generates bad SVG... */
if ((value = rsvg_property_bag_lookup (atts, "in")))
{
needdefault = 0;
g_ptr_array_add (((RsvgFilterPrimitiveMerge *)
(ctx->currentnode))->
nodes, g_string_new (value));
}
g_string_assign (((RsvgFilterPrimitive *)self)->in, value);
}
if (needdefault)
g_ptr_array_add (((RsvgFilterPrimitiveMerge *)
(ctx->currentnode))->
nodes, g_string_new ("none"));
}
static void
rsvg_filter_primitive_merge_node_free (RsvgNode * self)
{
RsvgFilterPrimitive *mself;
mself = (RsvgFilterPrimitive *) self;
g_string_free (mself->in, TRUE);
g_free (mself);
}
RsvgNode *
rsvg_new_filter_primitive_merge_node (void)
{
RsvgFilterPrimitive *filter;
filter = g_new (RsvgFilterPrimitive, 1);
filter->in = g_string_new ("none");
filter->super.free = rsvg_filter_primitive_merge_node_free;
filter->super.set_atts = rsvg_filter_primitive_merge_node_set_atts;
filter->super.type = RSVG_NODE_FILTER_PRIMITIVE_MERGE_NODE;
return &filter->super;
}
/*************************************************************/
......@@ -4317,10 +4307,11 @@ typedef enum {
DISTANTLIGHT, POINTLIGHT, SPOTLIGHT
} lightType;
typedef struct _lightSource lightSource;
typedef struct _RsvgNodeLightSource RsvgNodeLightSource;
struct _lightSource
struct _RsvgNodeLightSource
{
RsvgNode super;
lightType type;
gdouble x; /*doubles as azimuth*/
gdouble y; /*dounles as elevation*/
......@@ -4333,7 +4324,7 @@ struct _lightSource
};
static vector3
get_light_direction (lightSource source, gdouble x1, gdouble y1, gdouble z, gdouble * affine)
get_light_direction (RsvgNodeLightSource * source, gdouble x1, gdouble y1, gdouble z, gdouble * affine)
{
vector3 output;
......@@ -4342,18 +4333,18 @@ get_light_direction (lightSource source, gdouble x1, gdouble y1, gdouble z, gdou
x = affine[0] * x1 + affine[2] * y1 + affine[4];
y = affine[1] * x1 + affine[3] * y1 + affine[5];
switch (source.type)
switch (source->type)
{
case DISTANTLIGHT:
output.x = cos(source.x)*cos(source.y);
output.y = sin(source.x)*cos(source.y);
output.z = sin(source.y);
output.x = cos(source->x)*cos(source->y);
output.y = sin(source->x)*cos(source->y);
output.z = sin(source->y);
break;
case POINTLIGHT:
case SPOTLIGHT:
output.x = source.x - x;
output.y = source.y - y;
output.z = source.z - z;
output.x = source->x - x;
output.y = source->y - y;
output.z = source->z - z;
output = normalise(output);
break;
}
......@@ -4361,7 +4352,7 @@ get_light_direction (lightSource source, gdouble x1, gdouble y1, gdouble z, gdou
}
static vector3
get_light_colour(lightSource source, vector3 colour,
get_light_colour(RsvgNodeLightSource * source, vector3 colour,
gdouble x1, gdouble y1, gdouble z, gdouble * affine)
{
double base, angle, x, y;
......@@ -4369,27 +4360,27 @@ get_light_colour(lightSource source, vector3 colour,
vector3 L;
vector3 output;
if (source.type != SPOTLIGHT)
if (source->type != SPOTLIGHT)
return colour;
x = affine[0] * x1 + affine[2] * y1 + affine[4];
y = affine[1] * x1 + affine[3] * y1 + affine[5];
L.x = source.x - x;
L.y = source.y - y;
L.z = source.z - z;
L.x = source->x - x;
L.y = source->y - y;
L.z = source->z - z;
L = normalise(L);
s.x = source.pointsAtX - source.x;
s.y = source.pointsAtY - source.y;
s.z = source.pointsAtZ - source.z;
s.x = source->pointsAtX - source->x;
s.y = source->pointsAtY - source->y;
s.z = source->pointsAtZ - source->z;
s = normalise(s);
base = -dotproduct(L, s);
angle = acos(base) * 180.0 / M_PI;
if (base < 0 || angle > source.limitingconeAngle)
if (base < 0 || angle > source->limitingconeAngle)
{
output.x = 0;
output.y = 0;
......@@ -4397,34 +4388,25 @@ get_light_colour(lightSource source, vector3 colour,
return output;
}
output.x = colour.x*pow(base, source.specularExponent);
output.y = colour.y*pow(base, source.specularExponent);
output.z = colour.z*pow(base, source.specularExponent);
output.x = colour.x*pow(base, source->specularExponent);
output.y = colour.y*pow(base, source->specularExponent);
output.z = colour.z*pow(base, source->specularExponent);
return output;
}
void
rsvg_start_filter_primitive_light_source (RsvgHandle * ctx,
RsvgPropertyBag * atts, char type)
static void
rsvg_filter_primitive_light_source_set_atts (RsvgNode * self,
RsvgHandle * ctx,
RsvgPropertyBag * atts)
{
lightSource * data;
RsvgNodeLightSource * data;
const char *value;
double font_size;
font_size = rsvg_state_current_font_size (ctx);
data = (lightSource *)ctx->currentnode;
data->specularExponent = 1;
if (type == 's')
data->type = SPOTLIGHT;
else if (type == 'd')
data->type = DISTANTLIGHT;
else
data->type = POINTLIGHT;
data->limitingconeAngle = 180;
data = (RsvgNodeLightSource *)self;
if (rsvg_property_bag_size (atts))
{
......@@ -4475,6 +4457,29 @@ rsvg_start_filter_primitive_light_source (RsvgHandle * ctx,
}
}
static void
rsvg_filter_primitive_light_source_free(RsvgNode * tofree)
{
g_free(tofree);
}
RsvgNode *
rsvg_new_filter_primitive_light_source(char type)
{
RsvgNodeLightSource * data;
data = g_new(RsvgNodeLightSource, 1);
data->super.free = rsvg_filter_primitive_light_source_free;
data->super.set_atts = rsvg_filter_primitive_light_source_set_atts;
data->specularExponent = 1;
if (type == 's')
data->type = SPOTLIGHT;
else if (type == 'd')
data->type = DISTANTLIGHT;
else
data->type = POINTLIGHT;
data->limitingconeAngle = 180;
return &data->super;
}
/*************************************************************/
/*************************************************************/
......@@ -4487,7 +4492,6 @@ struct _RsvgFilterPrimitiveDiffuseLighting
gdouble dx, dy;
double diffuseConstant;
double surfaceScale;
lightSource source;
guint32 lightingcolour;
};
......@@ -4503,7 +4507,7 @@ rsvg_filter_primitive_diffuse_lighting_render (RsvgFilterPrimitive * self,
vector3 lightcolour, L, N;
vector3 colour;
gdouble iaffine[6];
RsvgNodeLightSource * source = NULL;
FPBox boundarys;
guchar *in_pixels;
......@@ -4513,7 +4517,18 @@ rsvg_filter_primitive_diffuse_lighting_render (RsvgFilterPrimitive * self,
GdkPixbuf *output;
GdkPixbuf *in;
unsigned int i;
for (i = 0; i < self->super.children->len; i++)
{
RsvgNode * temp;
temp = g_ptr_array_index(self->super.children, i);
if (temp->type == RSVG_NODE_FILTER_PRIMITIVE_MERGE_NODE)
source = (RsvgNodeLightSource *)temp;
}
if (source == NULL)
return;
oself = (RsvgFilterPrimitiveDiffuseLighting *) self;
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
......@@ -4556,11 +4571,11 @@ rsvg_filter_primitive_diffuse_lighting_render (RsvgFilterPrimitive * self,
for (x = boundarys.x1; x < boundarys.x2; x++)
{
z = surfaceScale * (double)in_pixels[y * rowstride + x * 4 + 3];
L = get_light_direction(oself->source, x, y, z, iaffine);
L = get_light_direction(source, x, y, z, iaffine);
N = get_surface_normal(in_pixels, boundarys, x, y,
dx, dy, rawdx, rawdy, oself->surfaceScale,
rowstride);
lightcolour = get_light_colour(oself->source, colour, x, y, z,
lightcolour = get_light_colour(source, colour, x, y, z,
iaffine);
factor = dotproduct(N, L);
......@@ -4677,6 +4692,8 @@ rsvg_new_filter_primitive_diffuse_lighting (void)
filter->super.super.free = &rsvg_filter_primitive_diffuse_lighting_free;
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;
}
......@@ -4691,7 +4708,6 @@ struct _RsvgFilterPrimitiveSpecularLighting
double specularConstant;
double specularExponent;
double surfaceScale;
lightSource source;
guint32 lightingcolour;
};
......@@ -4708,7 +4724,8 @@ rsvg_filter_primitive_specular_lighting_render (RsvgFilterPrimitive * self,
vector3 L;
gdouble iaffine[6];
FPBox boundarys;
RsvgNodeLightSource *source = NULL;
guchar *in_pixels;
guchar *output_pixels;
......@@ -4716,6 +4733,18 @@ rsvg_filter_primitive_specular_lighting_render (RsvgFilterPrimitive * self,
GdkPixbuf *output;
GdkPixbuf *in;
unsigned int i;
for (i = 0; i < self->super.children->len; i++)
{
RsvgNode * temp;
temp = g_ptr_array_index(self->super.children, i);
if (temp->type == RSVG_NODE_FILTER_PRIMITIVE_MERGE_NODE)
source = (RsvgNodeLightSource *)temp;
}
if (source == NULL)
return;
oself = (RsvgFilterPrimitiveSpecularLighting *) self;
boundarys = rsvg_filter_primitive_get_bounds (self, ctx);
......@@ -4744,11 +4773,11 @@ rsvg_filter_primitive_specular_lighting_render (RsvgFilterPrimitive * self,
for (x = boundarys.x1; x < boundarys.x2; x++)
{
z = in_pixels[y * rowstride + x * 4 + 3] * surfaceScale;
L = get_light_direction(oself->source, x, y, z, iaffine);
L = get_light_direction(source, x, y, z, iaffine);
L.z += 1;
L = normalise(L);
lightcolour = get_light_colour(oself->source, colour, x, y, z,
lightcolour = get_light_colour(source, colour, x, y, z,
iaffine);
base = dotproduct(get_surface_normal(in_pixels, boundarys, x, y,
1, 1, 1.0 / ctx->paffine[0], 1.0 / ctx->paffine[3],
......@@ -4886,6 +4915,8 @@ rsvg_new_filter_primitive_specular_lighting (void)
filter->super.super.free = &rsvg_filter_primitive_specular_lighting_free;
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;
}
......
......@@ -36,7 +36,6 @@ typedef RsvgCoordUnits RsvgFilterUnits;
struct _RsvgFilter {
RsvgNode super;
int refcnt;
GPtrArray * primitives;
double x, y, width, height;
RsvgFilterUnits filterunits;
RsvgFilterUnits primitiveunits;
......@@ -69,8 +68,8 @@ rsvg_new_filter_primitive_offset (void);
RsvgNode *
rsvg_new_filter_primitive_merge (void);
void
rsvg_start_filter_primitive_merge_node (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgNode *
rsvg_new_filter_primitive_merge_node (void);
RsvgNode *
rsvg_new_filter_primitive_colour_matrix (void);
......@@ -103,9 +102,8 @@ rsvg_new_filter_primitive_image (void);
RsvgNode *
rsvg_new_filter_primitive_diffuse_lighting (void);
void
rsvg_start_filter_primitive_light_source (RsvgHandle * ctx,
RsvgPropertyBag * atts, char type);
RsvgNode *
rsvg_new_filter_primitive_light_source (char type);
RsvgNode *
rsvg_new_filter_primitive_specular_lighting (void);
......
......@@ -525,79 +525,78 @@ rsvg_node_image_draw (RsvgNode * self, RsvgDrawingCtx *ctx,
rsvg_pop_discrete_layer(ctx);
}
void
rsvg_start_image (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_node_image_set_atts (RsvgNode *self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
double x = 0., y = 0., w = -1., h = -1., font_size;
const char * href = NULL;
double font_size;
const char * klazz = NULL, * id = NULL, *value;
int aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID;
GdkPixbuf *img;
GError *err = NULL;
RsvgState * state;
RsvgNodeImage *image;
gboolean overflow = FALSE;
state = g_new(RsvgState, 1);
rsvg_state_init(state);
RsvgNodeImage *image = (RsvgNodeImage *)self;
font_size = rsvg_state_current_font_size(ctx);
if (rsvg_property_bag_size (atts))
{
if ((value = rsvg_property_bag_lookup (atts, "x")))
x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
image->x = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
if ((value = rsvg_property_bag_lookup (atts, "y")))
y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
image->y = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
if ((value = rsvg_property_bag_lookup (atts, "width")))
w = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
image->w = rsvg_css_parse_normalized_length (value, ctx->dpi_x, (gdouble)ctx->width, font_size);
if ((value = rsvg_property_bag_lookup (atts, "height")))
h = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
image->h = rsvg_css_parse_normalized_length (value, ctx->dpi_y, (gdouble)ctx->height, font_size);
/* path is used by some older adobe illustrator versions */
if ((value = rsvg_property_bag_lookup (atts, "path")) || (value = rsvg_property_bag_lookup (atts, "xlink:href")))
href = value;
{
img = rsvg_pixbuf_new_from_href (value,
rsvg_handle_get_base_uri (ctx),
NULL);
if (!img)
{
if (err)
{
g_warning (_("Couldn't load image: %s\n"), err->message);
g_error_free (err);
}
return;
}
image->img = img;
}
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name (ctx->defs, id, &image->super);
}
if ((value = rsvg_property_bag_lookup (atts, "preserveAspectRatio")))
aspect_ratio = rsvg_css_parse_aspect_ratio (value);
image->preserve_aspect_ratio = rsvg_css_parse_aspect_ratio (value);
if ((value = rsvg_property_bag_lookup (atts, "overflow")))
overflow = rsvg_css_parse_overflow(value);
rsvg_parse_style_attrs (ctx, state, "image", klazz, id, atts);
}
if (!href || w <= 0. || h <= 0.)
return;
image->overflow = rsvg_css_parse_overflow(value);
/*hmm, passing the error thingie into the next thing makes it screw up when using vfs*/
img = rsvg_pixbuf_new_from_href (href, rsvg_handle_get_base_uri (ctx), NULL);
rsvg_parse_style_attrs (ctx, image->super.state, "image", klazz, id, atts);
}
}
if (!img)
{
if (err)
{
g_warning (_("Couldn't load image: %s\n"), err->message);
g_error_free (err);
}
return;
}
RsvgNode *
rsvg_new_image (void)
{
RsvgNodeImage *image;
image = g_new (RsvgNodeImage, 1);
image->img = img;
image->preserve_aspect_ratio = aspect_ratio;
image->x = x;
image->y = y;
image->w = w;
image->h = h;
image->overflow = overflow;
image->super.state = state;
image->img = NULL;
image->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID;
image->x = 0;
image->y = 0;
image->w = -1;
image->h = -1;
image->overflow = FALSE;
image->super.state = g_new(RsvgState, 1);
rsvg_state_init(image->super.state);
image->super.type = RSVG_NODE_PATH;
image->super.free = rsvg_node_image_free;
image->super.draw = rsvg_node_image_draw;
rsvg_defs_set (ctx->defs, id, &image->super);
image->super.parent = (RsvgNode *)ctx->currentnode;
if (image->super.parent != NULL)
rsvg_node_group_pack(image->super.parent, &image->super);
image->super.set_atts = rsvg_node_image_set_atts;
return &image->super;
}
......@@ -33,7 +33,8 @@
G_BEGIN_DECLS
void rsvg_start_image (RsvgHandle *ctx, RsvgPropertyBag *atts);
RsvgNode *
rsvg_new_image (void);
typedef struct _RsvgNodeImage RsvgNodeImage;
......
......@@ -36,64 +36,42 @@
#include <math.h>
#include <errno.h>
static void
rsvg_marker_free(RsvgNode* self)
{
RsvgMarker *marker;
marker = (RsvgMarker *)self;
g_free(self);
}
void
rsvg_start_marker (RsvgHandle *ctx, RsvgPropertyBag *atts)
static void
rsvg_node_marker_set_atts (RsvgNode * self, RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char *klazz = NULL, *id = NULL, *value;
RsvgMarker *marker;
double font_size;
double x = 0., y = 0., w = 0., h = 0.;
double vbx = 0., vby = 0., vbw = 1., vbh = 1.;
gboolean obj_bbox = TRUE;
RsvgState state;
gboolean got_x, got_y, got_bbox, got_vbox, got_width, got_height;
got_x = got_y = got_bbox = got_vbox = got_width = got_height = FALSE;
font_size = rsvg_state_current_font_size (ctx);
marker = g_new (RsvgMarker, 1);
rsvg_state_init(&state);
marker->orient = 0;
marker->orientAuto = FALSE;
marker->overflow = FALSE;
marker->preserve_aspect_ratio = RSVG_ASPECT_RATIO_XMID_YMID;
marker = (RsvgMarker *)self;
if (rsvg_property_bag_size (atts))
{
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
{
id = value;
rsvg_defs_register_name (ctx->defs, id, &marker->super);
}