Hi

I found out that for certain SVG files, rendering can likely be sped up a lot by directly rendering SVG elliptical arcs with Cairo instead of converting them to cubic Beziers and rendering those.

I expanded our current code in experimental to do that, and it... almost works. I'm not quite sure what I'm doing wrong at the moment, hopefully someone can help me with that!
The code works well for perfect circles. It does not work well for ellipses, but doesn't seem to have any issues with rotation of ellipses.

Any optimization tips would be appreciated, as this code is called extremely often.

    #line 558 "src/display/cairo-utils.cpp"
    else if (Geom::EllipticalArc const *a = dynamic_cast<Geom::EllipticalArc const*>(&c)) {
        Geom::EllipticalArc* tx = static_cast<Geom::EllipticalArc *>(a->transformed(trans));
        Geom::Affine xform = tx->unitCircleTransform();

        // Normalize the ellipse into a circle
        Geom::EllipticalArc * ax = static_cast<Geom::EllipticalArc *>(tx->transformed(xform));

        bool sweep = /*ax->sweep(), large_arc = */ax->largeArc();
        Geom::Point ce = ax->center();
        Geom::Point ang(ax->initialAngle().radians(), ax->finalAngle().radians());

        // Apply the transformation to the current context
        cairo_save(cr);
        cairo_matrix_t cr_trans;
        xform = xform.inverse() * trans;
        cairo_matrix_init(&cr_trans, xform[0], xform[1], xform[2], xform[3], xform[4], xform[5]);
        cairo_transform(cr, &cr_trans);
       
        if (!optimize_stroke || tx->boundsFast().intersects(view)) {
            // Draw the circle
            if (sweep) {
                cairo_arc(cr, ce[X], ce[Y], ax->ray(X), ang[0], ang[1]);
            } else {
                cairo_arc_negative(cr, ce[X], ce[Y], ax->ray(X), ang[0], ang[1]);
            }
        } else {
            cairo_move_to(cr, ax->finalPoint()[X], ax->finalPoint()[Y]);
        }
        cairo_restore(cr);
        delete tx; delete ax;
        return;
    }


http://cairographics.org/manual/cairo-Paths.html#cairo-arc