forked from minhngoc25a/freetype2
[base] Split out MSB function.
* src/base/fttrigon.c (ft_trig_prenorm): Borrow from here. * include/freetype/internal/ftcalc.h (FT_MSB): Declare here. * src/base/ftcalc.c (FT_MSB): Define here.
This commit is contained in:
parent
e0469372be
commit
869fb8c49d
|
@ -1,3 +1,11 @@
|
|||
2013-01-23 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||
|
||||
[base] Split out MSB function.
|
||||
|
||||
* src/base/fttrigon.c (ft_trig_prenorm): Borrow from here.
|
||||
* include/freetype/internal/ftcalc.h (FT_MSB): Declare here.
|
||||
* src/base/ftcalc.c (FT_MSB): Define here.
|
||||
|
||||
2013-01-22 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[truetype] Fix font height.
|
||||
|
|
|
@ -125,7 +125,6 @@ FT_BEGIN_HEADER
|
|||
* A variant of FT_Vector_Transform. See comments for
|
||||
* FT_Matrix_Multiply_Scaled.
|
||||
*/
|
||||
|
||||
FT_BASE( void )
|
||||
FT_Vector_Transform_Scaled( FT_Vector* vector,
|
||||
const FT_Matrix* matrix,
|
||||
|
@ -156,6 +155,13 @@ FT_BEGIN_HEADER
|
|||
FT_Pos out_y );
|
||||
|
||||
|
||||
/*
|
||||
* Return the most significant bit index.
|
||||
*/
|
||||
FT_BASE( FT_Int )
|
||||
FT_MSB( FT_UInt32 z );
|
||||
|
||||
|
||||
#define INT_TO_F26DOT6( x ) ( (FT_Long)(x) << 6 )
|
||||
#define INT_TO_F2DOT14( x ) ( (FT_Long)(x) << 14 )
|
||||
#define INT_TO_FIXED( x ) ( (FT_Long)(x) << 16 )
|
||||
|
|
|
@ -103,6 +103,42 @@
|
|||
}
|
||||
|
||||
|
||||
FT_BASE_DEF ( FT_Int )
|
||||
FT_MSB( FT_UInt32 z )
|
||||
{
|
||||
FT_Int shift = 0;
|
||||
|
||||
/* determine msb bit index in `shift' */
|
||||
if ( z >= ( 1L << 16 ) )
|
||||
{
|
||||
z >>= 16;
|
||||
shift += 16;
|
||||
}
|
||||
if ( z >= ( 1L << 8 ) )
|
||||
{
|
||||
z >>= 8;
|
||||
shift += 8;
|
||||
}
|
||||
if ( z >= ( 1L << 4 ) )
|
||||
{
|
||||
z >>= 4;
|
||||
shift += 4;
|
||||
}
|
||||
if ( z >= ( 1L << 2 ) )
|
||||
{
|
||||
z >>= 2;
|
||||
shift += 2;
|
||||
}
|
||||
if ( z >= ( 1L << 1 ) )
|
||||
{
|
||||
z >>= 1;
|
||||
shift += 1;
|
||||
}
|
||||
|
||||
return shift;
|
||||
}
|
||||
|
||||
|
||||
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
|
||||
|
||||
/* documentation is in ftcalc.h */
|
||||
|
|
|
@ -118,42 +118,14 @@
|
|||
static FT_Int
|
||||
ft_trig_prenorm( FT_Vector* vec )
|
||||
{
|
||||
FT_Fixed x, y, z;
|
||||
FT_Fixed x, y;
|
||||
FT_Int shift;
|
||||
|
||||
|
||||
x = vec->x;
|
||||
y = vec->y;
|
||||
|
||||
z = FT_ABS( x ) | FT_ABS( y );
|
||||
shift = 0;
|
||||
|
||||
/* determine msb bit index in `shift' */
|
||||
if ( z >= ( 1L << 16 ) )
|
||||
{
|
||||
z >>= 16;
|
||||
shift += 16;
|
||||
}
|
||||
if ( z >= ( 1L << 8 ) )
|
||||
{
|
||||
z >>= 8;
|
||||
shift += 8;
|
||||
}
|
||||
if ( z >= ( 1L << 4 ) )
|
||||
{
|
||||
z >>= 4;
|
||||
shift += 4;
|
||||
}
|
||||
if ( z >= ( 1L << 2 ) )
|
||||
{
|
||||
z >>= 2;
|
||||
shift += 2;
|
||||
}
|
||||
if ( z >= ( 1L << 1 ) )
|
||||
{
|
||||
z >>= 1;
|
||||
shift += 1;
|
||||
}
|
||||
shift = FT_MSB( FT_ABS( x ) | FT_ABS( y ) );
|
||||
|
||||
if ( shift <= FT_TRIG_SAFE_MSB )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue