freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] FT_MulDiv optimization


From: Behdad Esfahbod
Subject: Re: [ft-devel] FT_MulDiv optimization
Date: Sat, 16 Aug 2014 14:06:21 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

On 14-08-15 11:12 PM, Alexei Podtelezhnikov wrote:
> Werner,
> 
> FT_MulFix optimized like this on line 543:
>     if ( ua <= 2048 && ub <= 1048576L )
>       ua = ( ua * ub + 0x8000UL ) >> 16;
> 
> Of course, when we anchor 2048 and use unsigned multiplication, it
> should safely have been
>      if ( ua <= 2048 && ub <= 2097135L )
> 
> but that's not my point. I do not know why 2048 is chosen, but we can
> relax the condition similarly to the recent FT_MulDiv change. We can
> use this to cover the old range *completely* and grab some more:
> 
>     if ( ua + ( ub >> 8 ) <= 8191UL )
> 
> So, what was so special about 2048?

I think main usage pattern for this function is to scale values from font
space to Fixed device space.  Font-space values are typically < 2048 because
of TrueType commonly uses upem=2048 and Type1 uses 1000, so 2048 matches most
use.  The 1048576 would have been quite enough for common cases 20 years ago
(that's 16px in 16.16), but not anymore, so the improvement should address
most common usage these days (eg on Android).

-- 
behdad
http://behdad.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]