Commit 3fe5c8e0 authored by Caleb Michael Moore's avatar Caleb Michael Moore

marker fixes

parent 7ebf2c8a
2004-11-29 Caleb Moore <c.moore@student.unsw.edu.au>
* rsvg-shapes.c: made markers work again and inherit from the context that they were specified in, not where they were invoked.
2004-11-18 Dom Lachowicz <cinamod@hotmail.com>
* test-display.c: rsvg-view now can optionally use the new GtkFileChooser instead of GtkFileSelection, depending on whether you have GTK 2.4 installed or not.
......
......@@ -1495,7 +1495,7 @@ static void
box_blur (GdkPixbuf *in, GdkPixbuf *output, GdkPixbuf *intermediate, gint kw,
gint kh, FPBox boundarys, RsvgFilterPrimitiveOutput op)
{
guchar ch;
gint ch;
gint x, y;
gint rowstride, height, width;
......
......@@ -93,7 +93,7 @@ rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, DrawingCtx *ct
{
guchar r, g, b, rm, gm, bm, am;
guint a;
gdouble luminance;
guint luminance;
a = tos_pixels[4 * x + 3];
if (a)
{
......@@ -106,12 +106,9 @@ rsvg_mask_render (RsvgMask *self, GdkPixbuf *tos, GdkPixbuf *nos, DrawingCtx *ct
bm = mask_pixels[4 * x + 2];
am = mask_pixels[4 * x + 3];
luminance = ((gdouble)rm * 0.2125 +
(gdouble)gm * 0.7154 +
(gdouble)bm * 0.0721) / 255.;
luminance = (rm * 2125 + gm * 7154 + bm * 0721) / 10000;
a = (guint)((gdouble)a * luminance
* (gdouble)am / 255.);
a = a * luminance / 255 * am / 255;
art_rgba_run_alpha (nos_pixels + 4 * x, r, g, b, a, 1);
}
......
......@@ -2299,7 +2299,7 @@ rsvg_marker_free(RsvgDefVal* self)
void
rsvg_start_marker (RsvgHandle *ctx, RsvgPropertyBag *atts)
{
const char *id = NULL, *value;
const char *klazz = NULL, *id = NULL, *value;
RsvgMarker *marker;
double font_size;
double x = 0., y = 0., w = 0., h = 0.;
......@@ -2323,6 +2323,8 @@ rsvg_start_marker (RsvgHandle *ctx, RsvgPropertyBag *atts)
{
if ((value = rsvg_property_bag_lookup (atts, "id")))
id = value;
if ((value = rsvg_property_bag_lookup (atts, "class")))
klazz = value;
if ((value = rsvg_property_bag_lookup (atts, "viewBox")))
{
got_vbox = rsvg_css_parse_vbox (value, &vbx, &vby,
......@@ -2406,6 +2408,7 @@ rsvg_start_marker (RsvgHandle *ctx, RsvgPropertyBag *atts)
marker->contents = (RsvgDefsDrawable *)rsvg_push_part_def_group(ctx, NULL, state);
rsvg_state_init (&marker->contents->state);
marker->super.free = rsvg_marker_free;
rsvg_defs_set (ctx->defs, id, &marker->super);
......@@ -2469,9 +2472,12 @@ rsvg_marker_render (RsvgMarker *self, gdouble x, gdouble y, gdouble orient, gdou
art_affine_multiply(affine, affine, taffine);
/*don't inherit anything from the current context*/
rsvg_state_finalize(state);
rsvg_state_init(state);
rsvg_state_reassemble((RsvgDefsDrawable *)self->contents, state);
rsvg_state_push(ctx);
state = rsvg_state_current(ctx);
for (i = 0; i < 6; i++)
......@@ -2479,7 +2485,7 @@ rsvg_marker_render (RsvgMarker *self, gdouble x, gdouble y, gdouble orient, gdou
state->affine[i] = affine[i];
}
rsvg_defs_drawable_draw (self->contents, ctx, 2);
rsvg_defs_drawable_draw (self->contents, ctx, 3);
rsvg_state_pop(ctx);
}
......@@ -2497,22 +2503,18 @@ rsvg_marker_parse (const RsvgDefs * defs, const char *str)
while (g_ascii_isspace (*p))
p++;
if (*p == '#')
for (ix = 0; p[ix]; ix++)
if (p[ix] == ')')
break;
if (p[ix] == ')')
{
p++;
for (ix = 0; p[ix]; ix++)
if (p[ix] == ')')
break;
if (p[ix] == ')')
{
name = g_strndup (p, ix);
val = rsvg_defs_lookup (defs, name);
g_free (name);
if (val && val->type == RSVG_DEF_MARKER)
return (RsvgDefVal *) val;
}
name = g_strndup (p, ix);
val = rsvg_defs_lookup (defs, name);
g_free (name);
if (val && val->type == RSVG_DEF_MARKER)
return (RsvgDefVal *) val;
}
}
return NULL;
......@@ -2662,3 +2664,19 @@ rsvg_start_sub_svg (RsvgHandle *ctx, RsvgPropertyBag *atts)
ctx->nest_level++;
}
void
rsvg_state_reassemble(RsvgDefsDrawable * self, RsvgState * state)
{
RsvgState store;
if (self == NULL)
{
return;
}
rsvg_state_reassemble(self->parent, state);
rsvg_state_clone (&store, &self->state);
rsvg_state_reinherit(&store, state);
rsvg_state_finalize(state);
*state = store;
}
......@@ -149,6 +149,9 @@ void rsvg_defs_drawable_group_pack (RsvgDefsDrawableGroup *self, RsvgDefsDrawabl
gchar *
rsvg_get_file_path (const gchar * filename, const gchar *basedir);
void
rsvg_state_reassemble(RsvgDefsDrawable * self, RsvgState * state);
G_END_DECLS
#endif /* RSVG_SHAPES_H */
......@@ -1781,6 +1781,9 @@ rsvg_state_reinherit_top(DrawingCtx * ctx, RsvgState * state, int dominate)
gint i;
RsvgState * baseon;
if (dominate == 3)
return;
baseon = rsvg_state_parent(ctx);
for (i = 0; i < 6; i++)
......@@ -1794,8 +1797,7 @@ rsvg_state_reinherit_top(DrawingCtx * ctx, RsvgState * state, int dominate)
if (baseon)
{
/*This is a special domination mode for patterns, the style
is simply left as is, wheras the transform is totally overridden*/
if (dominate == 2)
is simply left as is, wheras the transform is totally overridden*/ if (dominate == 2)
{
for (i = 0; i < 6; i++)
{
......
......@@ -159,32 +159,6 @@ rsvg_tspan_new()
return self;
}
static gdouble
rsvg_tspan_dx(RsvgTspan * self)
{
RsvgTspan * i;
gdouble total;
total = 0;
for (i = self; i->hasx == FALSE; i = i->parent)
total += i->dx;
total += i->dx;
return total;
}
static gdouble
rsvg_tspan_dy(RsvgTspan * self)
{
RsvgTspan * i;
gdouble total;
total = 0;
for (i = self; i->hasy == FALSE; i = i->parent)
total += i->dy;
total += i->dy;
return total;
}
static void
rsvg_tchunk_remove_leading(RsvgTChunk * self);
......@@ -457,6 +431,7 @@ rsvg_text_tspan_width (DrawingCtx *ctx,
currentindex = -1;
if (currentspan->hasx || currentspan->hasy)
return currentwidth;
currentwidth += currentspan->dx;
}
}
currentindex++;
......@@ -501,6 +476,17 @@ rsvg_tspan_draw(RsvgTspan * self, DrawingCtx *ctx, gdouble *x, gdouble *y, int d
*y = self->y;
}
if (rsvg_state_current(ctx)->text_dir == PANGO_DIRECTION_TTB_LTR ||
rsvg_state_current(ctx)->text_dir == PANGO_DIRECTION_TTB_RTL)
{
*y += self->dx;
*x += self->dy;
}
else
{
*x += self->dx;
*y += self->dy;
}
for (i = 0; i < self->contents->len; i++) {
rsvg_tchunk_draw (g_ptr_array_index(self->contents, i), ctx, self, x, y);
}
......@@ -668,6 +654,7 @@ struct _RsvgTextLayout
TextAnchor anchor;
RsvgTspan *span;
gdouble x, y;
gboolean orientation;
};
typedef struct _RenderCtx RenderCtx;
......@@ -965,7 +952,7 @@ cubicto (FT_Vector *ftcontrol1,
return 0;
}
static void
static gint
rsvg_text_layout_render_glyphs (RsvgTextLayout *layout,
PangoFont *font,
PangoGlyphString *glyphs,
......@@ -993,9 +980,10 @@ rsvg_text_layout_render_glyphs (RsvgTextLayout *layout,
pos.x, pos.y,
render_data);
}
x_position += glyphs->glyphs[i].geometry.width;
}
return x_position;
}
static void
......@@ -1058,13 +1046,12 @@ rsvg_text_layout_render_line (RsvgTextLayout *layout,
pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
NULL, &rect);
rsvg_text_layout_render_glyphs (layout,
run->item->analysis.font, run->glyphs,
render_func,
x + x_off, y,
render_data);
x_off += rsvg_text_layout_render_glyphs (layout,
run->item->analysis.font, run->glyphs,
render_func,
x + x_off, y,
render_data);
x_off += rect.width;
}
}
......@@ -1079,10 +1066,6 @@ rsvg_text_layout_render (RsvgTextLayout *layout,
rsvg_text_layout_get_offsets (layout, &offx, &offy);
offx += rsvg_tspan_dx(layout->span);
offy += rsvg_tspan_dy(layout->span);
x = offx + layout->x;
y = offy + layout->y;
......@@ -1136,6 +1119,8 @@ rsvg_text_render_text_as_string (DrawingCtx *ctx,
layout->span = tspan;
layout->x = *x;
layout->y = *y;
layout->orientation = rsvg_state_current(ctx)->text_dir == PANGO_DIRECTION_TTB_LTR ||
rsvg_state_current(ctx)->text_dir == PANGO_DIRECTION_TTB_RTL;
render = rsvg_render_ctx_new ();
rsvg_text_layout_render (layout, rsvg_text_render_vectors,
......@@ -1191,8 +1176,6 @@ rsvg_text_layout_width (RsvgTextLayout *layout)
gint offx, offy;
rsvg_text_layout_get_offsets (layout, &offx, &offy);
offx += rsvg_tspan_dx(layout->span);
iter = pango_layout_get_iter (layout->layout);
......
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