зеркало из https://github.com/stride3d/freetype.git
[truetype] Improve accuracy of normalization of short vectors.
Unit vector components are stored as 2.14 fixed-point numbers. In order to calculate all 14 bits accurately, a short vector to be normalized has to be upscaled to at least 14 bits before its length is calculated. This has been safe since accurate CORDIC algorithms were adopted. * src/truetype/ttinterp.c (Normalize): Scale short vectors by 0x4000.
This commit is contained in:
Родитель
081aba390a
Коммит
0e0fdc5dc8
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2013-01-12 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||
|
||||
[truetype] Improve accuracy of normalization of short vectors.
|
||||
|
||||
Unit vector components are stored as 2.14 fixed-point numbers. In
|
||||
order to calculate all 14 bits accurately, a short vector to be
|
||||
normalized has to be upscaled to at least 14 bits before its length
|
||||
is calculated. This has been safe since accurate CORDIC algorithms
|
||||
were adopted.
|
||||
|
||||
* src/truetype/ttinterp.c (Normalize): Scale short vectors by 0x4000.
|
||||
|
||||
2013-01-12 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||
|
||||
[truetype] Kill very old vector normalization hacks.
|
||||
|
|
|
@ -2635,8 +2635,6 @@
|
|||
/* In case Vx and Vy are both zero, Normalize() returns SUCCESS, and */
|
||||
/* R is undefined. */
|
||||
/* */
|
||||
|
||||
|
||||
static FT_Bool
|
||||
Normalize( EXEC_OP_ FT_F26Dot6 Vx,
|
||||
FT_F26Dot6 Vy,
|
||||
|
@ -2647,17 +2645,17 @@
|
|||
FT_UNUSED_EXEC;
|
||||
|
||||
|
||||
if ( FT_ABS( Vx ) < 0x10000L && FT_ABS( Vy ) < 0x10000L )
|
||||
if ( FT_ABS( Vx ) < 0x4000L && FT_ABS( Vy ) < 0x4000L )
|
||||
{
|
||||
Vx *= 0x100;
|
||||
Vy *= 0x100;
|
||||
|
||||
if ( Vx == 0 && Vy == 0 )
|
||||
{
|
||||
/* XXX: UNDOCUMENTED! It seems that it is possible to try */
|
||||
/* to normalize the vector (0,0). Return immediately. */
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Vx *= 0x4000;
|
||||
Vy *= 0x4000;
|
||||
}
|
||||
|
||||
W = TT_VecLen( Vx, Vy );
|
||||
|
|
Загрузка…
Ссылка в новой задаче