[cairo] Patches for speeding up _cairo_fixed_from_double

Daniel Amelang daniel.amelang at gmail.com
Thu Nov 16 15:54:37 PST 2006

On 11/16/06, Behdad Esfahbod <behdad at behdad.org> wrote:
> On Thu, 2006-11-16 at 15:31 -0800, Daniel Amelang wrote:
> >
> > The required change is to replace PANGO_UNITS in pangocairo-fc-font.c
> > with an inline function almost identical to the new
> > _cairo_fixed_from_double function. This significantly speeds up
> > compute_glyph_extents, which accounts for all the __muldf3 found here
> > (third function down):
> Cool.
> Makes me wonder, should we export this function in a header file or
> something?  In glib maybe?  As an inline or static, donno.  Anyway.

Yea, I thought the same thing. I didn't see much of a difference when
I made it inline, but it didn't hurt. I think putting it in glib would
be a good idea, but this trick requires IEEE-754 compliance in how the
double is represented in binary. I think glib might have tighter
portability restrictions. Then again, we do have the ac macro to check
for that. Owen?

> I hope that doesn't corrupt the rounding behavior.  There used to be a
> bug around there that I fixed.

It really shouldn't. The only difference in behavior is that it uses
banker's rounding, which some people think is better. You'll only see
the difference in edge cases (I saw it show up 1/5000 times in some
ad-hoc tests I did with cairo).



More information about the cairo mailing list