[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Devel] Optimizatins to ttinterp.c
From: |
David Turner |
Subject: |
Re: [Devel] Optimizatins to ttinterp.c |
Date: |
Mon, 11 Dec 2000 10:41:40 +0100 |
Hi David,
David Williss a écrit :
>
> I happened to be running a program through Rational Quantify (a really
> good profiler for Windows NT/2000) and found a few things in Freetype 1.3
> that I was able to speed up. They're compiler specific (Visual C 6.0), but
> significant.
>
> [....]
>
> Anyway, the result was that with all the changes I made, loading
> this font, the time to do the hinting went from 13.5 sec to 3.5 sec.
> Now the child of RunIns() that takes the most time is Ins_IUP
> which is down to 908ms and is now 25.43% of the time.
> followed by Ins_SHP at 431ms for 12.07% of the time.
>
Some drastic improvements have already been introduced in the FreeType 2
source tree. Two of them are important relative to the performance
bottleneck you're describing:
- first of all, 1.x uses two values to scale any distance from font units
to sub-pixels, i.e. scaling the outline is done with something like:
distance_pix = FT_MulDiv( distance_org, scale_1, scale_2 );
where the scale is really scale_1/scale_2.
in 2.0, a single 16.16 scale is used, which converts into:
distance_pix = FT_MulFix( distance_org, scale );
- second, FT_MulFix has been optimised to deal with the very frequent
case where the first parameter is a distance in font units (and generally
below 2048), while the second one if a 16.16 scale. This allows us to
avoid using 64-bits in many cases, resulting in a significant speed up.
see the code "src/base/ftcalc.c" for FT_MulFix, there is a rather long
comment that explains it. FT_MulDiv is used for "unusal cases".
this explains why FT2 is significantly faster than 1.x at TrueTyê bytecode
decoding.There are of course other tricks we would try, but we focused for
now on portability issues.
Note that it's possible to use 64-bit longs in the current code. See the
macro FTCALC_USE_LONG_LONG in "include/freetype/config/ftoption.h"
and of course, using inlines, that we never considered until them..
Regards,
- David