rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self, RsvgFilterContext * ctx)
{
    RsvgBbox box, otherbox;
    double affine[6];

    _rsvg_affine_identity (affine);
    rsvg_bbox_init (&box, affine);
    rsvg_bbox_init (&otherbox, ctx->affine);
    otherbox.virgin = 0;
    if (ctx->filter->filterunits == objectBoundingBox)
        _rsvg_push_view_box (ctx->ctx, 1., 1.);
    otherbox.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, 'h');
    otherbox.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, 'v');
    otherbox.w = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, 'h');
    otherbox.h = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, 'v');
    if (ctx->filter->filterunits == objectBoundingBox)
        _rsvg_pop_view_box (ctx->ctx);

    rsvg_bbox_insert (&box, &otherbox);

    if (self != NULL)
        if (self->x.factor != 'n' || self->y.factor != 'n' ||
            self->width.factor != 'n' || self->height.factor != 'n') {

            rsvg_bbox_init (&otherbox, ctx->paffine);
            otherbox.virgin = 0;
            if (ctx->filter->primitiveunits == objectBoundingBox)
                _rsvg_push_view_box (ctx->ctx, 1., 1.);
            if (self->x.factor != 'n')
                otherbox.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, 'h');
            else
                otherbox.x = 0;
            if (self->y.factor != 'n')
                otherbox.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, 'v');
            else
                otherbox.y = 0;
            if (self->width.factor != 'n')
                otherbox.w = _rsvg_css_normalize_length (&self->width, ctx->ctx, 'h');
            else
                otherbox.w = ctx->ctx->vb.w;
            if (self->height.factor != 'n')
                otherbox.h = _rsvg_css_normalize_length (&self->height, ctx->ctx, 'v');
            else
                otherbox.h = ctx->ctx->vb.h;
            if (ctx->filter->primitiveunits == objectBoundingBox)
                _rsvg_pop_view_box (ctx->ctx);
            rsvg_bbox_clip (&box, &otherbox);
        }

    rsvg_bbox_init (&otherbox, affine);
    otherbox.virgin = 0;
    otherbox.x = 0;
    otherbox.y = 0;
    otherbox.w = ctx->width;
    otherbox.h = ctx->height;
    rsvg_bbox_clip (&box, &otherbox);
    {
        RsvgIRect output = { box.x, box.y,
            box.x + box.w,
            box.y + box.h
        };
        return output;
    }
}
rsvg_filter_primitive_get_bounds (RsvgFilterPrimitive * self, RsvgFilterContext * ctx)
{
    RsvgBbox box, otherbox;
    double affine[6];

    _rsvg_affine_identity (affine);
    rsvg_bbox_init (&box, affine);
    rsvg_bbox_init (&otherbox, ctx->affine);
    otherbox.virgin = 0;
    if (ctx->filter->filterunits == objectBoundingBox)
        _rsvg_push_view_box (ctx->ctx, 1., 1.);
    otherbox.x = _rsvg_css_normalize_length (&ctx->filter->x, ctx->ctx, 'h');
    otherbox.y = _rsvg_css_normalize_length (&ctx->filter->y, ctx->ctx, 'v');
    otherbox.w = _rsvg_css_normalize_length (&ctx->filter->width, ctx->ctx, 'h');
    otherbox.h = _rsvg_css_normalize_length (&ctx->filter->height, ctx->ctx, 'v');
    if (ctx->filter->filterunits == objectBoundingBox)
        _rsvg_pop_view_box (ctx->ctx);

    rsvg_bbox_insert (&box, &otherbox);

    if (self != NULL)
        if (self->x.factor != 'n' || self->y.factor != 'n' ||
            self->width.factor != 'n' || self->height.factor != 'n') {

            rsvg_bbox_init (&otherbox, ctx->paffine);
            otherbox.virgin = 0;
            if (ctx->filter->primitiveunits == objectBoundingBox)
                _rsvg_push_view_box (ctx->ctx, 1., 1.);
            if (self->x.factor != 'n')
                otherbox.x = _rsvg_css_normalize_length (&self->x, ctx->ctx, 'h');
            else
                otherbox.x = 0;
            if (self->y.factor != 'n')
                otherbox.y = _rsvg_css_normalize_length (&self->y, ctx->ctx, 'v');
            else
                otherbox.y = 0;
            if (self->width.factor != 'n')
                otherbox.w = _rsvg_css_normalize_length (&self->width, ctx->ctx, 'h');
            else
                otherbox.w = ctx->ctx->vb.w;
            if (self->height.factor != 'n')
                otherbox.h = _rsvg_css_normalize_length (&self->height, ctx->ctx, 'v');
            else
                otherbox.h = ctx->ctx->vb.h;
            if (ctx->filter->primitiveunits == objectBoundingBox)
                _rsvg_pop_view_box (ctx->ctx);
            rsvg_bbox_clip (&box, &otherbox);
        }

    rsvg_bbox_init (&otherbox, affine);
    otherbox.virgin = 0;
    otherbox.x = 0;
    otherbox.y = 0;
    otherbox.w = ctx->width;
    otherbox.h = ctx->height;
    rsvg_bbox_clip (&box, &otherbox);
    {
        RsvgIRect output = { box.x, box.y,
            box.x + box.w,
            box.y + box.h
        };
        return output;
    }
}