[cairo] Reduce number of floating point operations

Behdad Esfahbod behdad at behdad.org
Tue Nov 21 14:39:13 PST 2006


On Tue, 2006-11-21 at 15:41 -0500, Daniel Amelang wrote:
> 
> 4) Use a matrix state flag as a bit flag for is_identity,
> is_translation, etc. The code is now _very_ ugly, very tricky (did you
> cover all possible state transitions?), and isn't any faster on any
> benchmark that I have. Reason why is that is_translation isn't called
> that much at all (assuming my version of the transform glyphs patch)
> compared to is_identity, so this additional caching doesn't get you
> very far. 

Cannot tell without seeing your code, but I guess you didn't do it like
I had in mind.  In my plan, user (that is, rest of cairo) shouldn't care
about is_identity and is_translation at all.  The very matrix operations
will use them.  That is, your patch probably didn't speed up this:

void
_cairo_gstate_user_to_backend (cairo_gstate_t *gstate, double *x, double *y)
{
    cairo_matrix_transform_point (&gstate->ctm, x, y);
    cairo_matrix_transform_point (&gstate->target->device_transform, x, y);
}

In my plan, cairo_matrix_transform_point will first examine the
is_identity flag and return immediately if it's set.  Is that what you
did?  This way, it will not clutter the entire code base.

-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list