rsvg_marker_render (RsvgMarker * self, gdouble x, gdouble y, gdouble orient, gdouble linewidth,
		    RsvgDrawingCtx * ctx)
{
    gdouble affine[6];
    gdouble taffine[6];
    unsigned int i;
    gdouble rotation;
    RsvgState *state = rsvg_current_state (ctx);

    _rsvg_affine_translate (taffine, x, y);
    _rsvg_affine_multiply (affine, taffine, state->affine);

    if (self->orientAuto)
        rotation = orient * 180. / M_PI;
    else
        rotation = self->orient;
    _rsvg_affine_rotate (taffine, rotation);
    _rsvg_affine_multiply (affine, taffine, affine);

    if (self->bbox) {
        _rsvg_affine_scale (taffine, linewidth, linewidth);
        _rsvg_affine_multiply (affine, taffine, affine);
    }

    if (self->vbox.active) {

        double w, h, x, y;
        w = _rsvg_css_normalize_length (&self->width, ctx, 'h');
        h = _rsvg_css_normalize_length (&self->height, ctx, 'v');
        x = 0;
        y = 0;

        rsvg_preserve_aspect_ratio (self->preserve_aspect_ratio,
                                    self->vbox.w, self->vbox.h, &w, &h, &x, &y);

        x = -self->vbox.x * w / self->vbox.w;
        y = -self->vbox.y * h / self->vbox.h;

        taffine[0] = w / self->vbox.w;
        taffine[1] = 0.;
        taffine[2] = 0.;
        taffine[3] = h / self->vbox.h;
        taffine[4] = x;
        taffine[5] = y;
        _rsvg_affine_multiply (affine, taffine, affine);
        _rsvg_push_view_box (ctx, self->vbox.w, self->vbox.h);
    }
    _rsvg_affine_translate (taffine,
                            -_rsvg_css_normalize_length (&self->refX, ctx, 'h'),
                            -_rsvg_css_normalize_length (&self->refY, ctx, 'v'));
    _rsvg_affine_multiply (affine, taffine, affine);


    rsvg_state_push (ctx);
    state = rsvg_current_state (ctx);

    rsvg_state_reinit (state);

    rsvg_state_reconstruct (state, &self->super);

    for (i = 0; i < 6; i++)
        state->affine[i] = affine[i];

    rsvg_push_discrete_layer (ctx);

    state = rsvg_current_state (ctx);

    if (!state->overflow) {
        if (self->vbox.active)
            rsvg_add_clipping_rect (ctx, self->vbox.x, self->vbox.y, self->vbox.w, self->vbox.h);
        else
            rsvg_add_clipping_rect (ctx, 0, 0,
                                    _rsvg_css_normalize_length (&self->width, ctx, 'h'),
                                    _rsvg_css_normalize_length (&self->height, ctx, 'v'));
    }

    for (i = 0; i < self->super.children->len; i++) {
        rsvg_state_push (ctx);

        rsvg_node_draw (g_ptr_array_index (self->super.children, i), ctx, 0);

        rsvg_state_pop (ctx);
    }
    rsvg_pop_discrete_layer (ctx);

    rsvg_state_pop (ctx);
    if (self->vbox.active)
        _rsvg_pop_view_box (ctx);
}
rsvg_marker_render (RsvgMarker * self, gdouble x, gdouble y, gdouble orient, gdouble linewidth,
		    RsvgDrawingCtx * ctx)
{
    gdouble affine[6];
    gdouble taffine[6];
    unsigned int i;
    gdouble rotation;
    RsvgState *state = rsvg_current_state (ctx);

    _rsvg_affine_translate (taffine, x, y);
    _rsvg_affine_multiply (affine, taffine, state->affine);

    if (self->orientAuto)
        rotation = orient * 180. / M_PI;
    else
        rotation = self->orient;
    _rsvg_affine_rotate (taffine, rotation);
    _rsvg_affine_multiply (affine, taffine, affine);

    if (self->bbox) {
        _rsvg_affine_scale (taffine, linewidth, linewidth);
        _rsvg_affine_multiply (affine, taffine, affine);
    }

    if (self->vbox.active) {

        double w, h, x, y;
        w = _rsvg_css_normalize_length (&self->width, ctx, 'h');
        h = _rsvg_css_normalize_length (&self->height, ctx, 'v');
        x = 0;
        y = 0;

        rsvg_preserve_aspect_ratio (self->preserve_aspect_ratio,
                                    self->vbox.w, self->vbox.h, &w, &h, &x, &y);

        x = -self->vbox.x * w / self->vbox.w;
        y = -self->vbox.y * h / self->vbox.h;

        taffine[0] = w / self->vbox.w;
        taffine[1] = 0.;
        taffine[2] = 0.;
        taffine[3] = h / self->vbox.h;
        taffine[4] = x;
        taffine[5] = y;
        _rsvg_affine_multiply (affine, taffine, affine);
        _rsvg_push_view_box (ctx, self->vbox.w, self->vbox.h);
    }
    _rsvg_affine_translate (taffine,
                            -_rsvg_css_normalize_length (&self->refX, ctx, 'h'),
                            -_rsvg_css_normalize_length (&self->refY, ctx, 'v'));
    _rsvg_affine_multiply (affine, taffine, affine);


    rsvg_state_push (ctx);
    state = rsvg_current_state (ctx);

    rsvg_state_reinit (state);

    rsvg_state_reconstruct (state, &self->super);

    for (i = 0; i < 6; i++)
        state->affine[i] = affine[i];

    rsvg_push_discrete_layer (ctx);

    state = rsvg_current_state (ctx);

    if (!state->overflow) {
        if (self->vbox.active)
            rsvg_add_clipping_rect (ctx, self->vbox.x, self->vbox.y, self->vbox.w, self->vbox.h);
        else
            rsvg_add_clipping_rect (ctx, 0, 0,
                                    _rsvg_css_normalize_length (&self->width, ctx, 'h'),
                                    _rsvg_css_normalize_length (&self->height, ctx, 'v'));
    }

    for (i = 0; i < self->super.children->len; i++) {
        rsvg_state_push (ctx);

        rsvg_node_draw (g_ptr_array_index (self->super.children, i), ctx, 0);

        rsvg_state_pop (ctx);
    }
    rsvg_pop_discrete_layer (ctx);

    rsvg_state_pop (ctx);
    if (self->vbox.active)
        _rsvg_pop_view_box (ctx);
}