diff options
author | marha <marha@users.sourceforge.net> | 2013-06-21 11:18:17 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2013-06-21 11:18:17 +0200 |
commit | 039fb6c83783fff3b92f1e7934ce4702cedb1722 (patch) | |
tree | bb971ed2e247f7d311b696e62c7ed4d66b199b6d /freetype/src/base/ftcalc.c | |
parent | 84f6a75a56f4749f91a51a161c1989cbc8807b80 (diff) | |
parent | fa791414601df61d20d860299dba80fdb62565df (diff) | |
download | vcxsrv-039fb6c83783fff3b92f1e7934ce4702cedb1722.tar.gz vcxsrv-039fb6c83783fff3b92f1e7934ce4702cedb1722.tar.bz2 vcxsrv-039fb6c83783fff3b92f1e7934ce4702cedb1722.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
Upgraded freetype to 2.5.0.1
Conflicts:
freetype/src/base/ftcalc.c
freetype/src/base/ftgloadr.c
freetype/src/base/ftgxval.c
freetype/src/base/ftotval.c
freetype/src/base/ftoutln.c
freetype/src/base/ftpfr.c
freetype/src/base/fttrigon.c
freetype/src/cff/cffobjs.c
freetype/src/psaux/afmparse.c
freetype/src/psnames/psmodule.c
freetype/src/raster/ftraster.c
freetype/src/raster/ftrend1.c
freetype/src/sfnt/ttsbit.c
freetype/src/sfnt/ttsbit0.c
freetype/src/truetype/ttobjs.c
freetype/src/truetype/ttsubpix.c
freetype/src/type1/t1afm.c
Diffstat (limited to 'freetype/src/base/ftcalc.c')
-rwxr-xr-x[-rw-r--r--] | freetype/src/base/ftcalc.c | 110 |
1 files changed, 63 insertions, 47 deletions
diff --git a/freetype/src/base/ftcalc.c b/freetype/src/base/ftcalc.c index 3a9b9ed13..27448b30a 100644..100755 --- a/freetype/src/base/ftcalc.c +++ b/freetype/src/base/ftcalc.c @@ -4,7 +4,7 @@ /* */ /* Arithmetic computations (body). */ /* */ -/* Copyright 1996-2006, 2008, 2012 by */ +/* Copyright 1996-2006, 2008, 2012-2013 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -34,6 +34,7 @@ #include <ft2build.h> #include FT_GLYPH_H +#include <freetype/fttrigon.h> #include <freetype/internal/ftcalc.h> #include <freetype/internal/ftdebug.h> #include <freetype/internal/ftobjs.h> @@ -42,13 +43,9 @@ #undef FT_MulFix #endif -/* we need to define a 64-bits data type here */ +/* we need to emulate a 64-bit data type if a real one isn't available */ -#ifdef FT_LONG64 - - typedef FT_INT64 FT_Int64; - -#else +#ifndef FT_LONG64 typedef struct FT_Int64_ { @@ -57,7 +54,7 @@ } FT_Int64; -#endif /* FT_LONG64 */ +#endif /* !FT_LONG64 */ /*************************************************************************/ @@ -103,39 +100,57 @@ } -#ifdef FT_CONFIG_OPTION_OLD_INTERNALS + FT_BASE_DEF ( FT_Int ) + FT_MSB( FT_UInt32 z ) + { + FT_Int shift = 0; - /* documentation is in ftcalc.h */ + /* 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; + } - FT_EXPORT_DEF( FT_Int32 ) - FT_Sqrt32( FT_Int32 x ) - { - FT_UInt32 val, root, newroot, mask; + return shift; + } - root = 0; - mask = (FT_UInt32)0x40000000UL; - val = (FT_UInt32)x; + /* documentation is in ftcalc.h */ - do - { - newroot = root + mask; - if ( newroot <= val ) - { - val -= newroot; - root = newroot + mask; - } + FT_BASE_DEF( FT_Fixed ) + FT_Hypot( FT_Fixed x, + FT_Fixed y ) + { + FT_Vector v; - root >>= 1; - mask >>= 2; - } while ( mask != 0 ); + v.x = x; + v.y = y; - return root; + return FT_Vector_Length( &v ); } -#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */ - #ifdef FT_LONG64 @@ -163,8 +178,6 @@ } -#ifdef TT_USE_BYTECODE_INTERPRETER - /* documentation is in ftcalc.h */ FT_BASE_DEF( FT_Long ) @@ -187,8 +200,6 @@ return ( s > 0 ) ? d : -d; } -#endif /* TT_USE_BYTECODE_INTERPRETER */ - /* documentation is in freetype.h */ @@ -235,16 +246,25 @@ FT_Int32 s; FT_UInt32 q; + s = 1; - if ( a < 0 ) { a = -a; s = -1; } - if ( b < 0 ) { b = -b; s = -s; } + if ( a < 0 ) + { + a = -a; + s = -1; + } + if ( b < 0 ) + { + b = -b; + s = -s; + } if ( b == 0 ) /* check for division by 0 */ q = 0x7FFFFFFFL; else /* compute result directly */ - q = (FT_UInt32)( ( ( (FT_Int64)a << 16 ) + ( b >> 1 ) ) / b ); + q = (FT_UInt32)( ( ( (FT_UInt64)a << 16 ) + ( b >> 1 ) ) / b ); return ( s < 0 ? -(FT_Long)q : (FT_Long)q ); } @@ -392,8 +412,6 @@ } -#ifdef TT_USE_BYTECODE_INTERPRETER - FT_BASE_DEF( FT_Long ) FT_MulDiv_No_Round( FT_Long a, FT_Long b, @@ -426,8 +444,6 @@ return ( s < 0 ? -a : a ); } -#endif /* TT_USE_BYTECODE_INTERPRETER */ - /* documentation is in freetype.h */ @@ -552,7 +568,7 @@ else if ( ( a >> 16 ) == 0 ) { /* compute result directly */ - q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b; + q = (FT_UInt32)( ( (FT_ULong)a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b; } else { @@ -560,8 +576,8 @@ FT_Int64 temp, temp2; - temp.hi = (FT_Int32) ( a >> 16 ); - temp.lo = (FT_UInt32)( a << 16 ); + temp.hi = (FT_Int32)( a >> 16 ); + temp.lo = (FT_UInt32)a << 16; temp2.hi = 0; temp2.lo = (FT_UInt32)( b >> 1 ); FT_Add64( &temp, &temp2, &temp ); @@ -727,14 +743,14 @@ if ( !matrix ) - return FT_Err_Invalid_Argument; + return FT_THROW( Invalid_Argument ); /* compute discriminant */ delta = FT_MulFix( matrix->xx, matrix->yy ) - FT_MulFix( matrix->xy, matrix->yx ); if ( !delta ) - return FT_Err_Invalid_Argument; /* matrix can't be inverted */ + return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */ matrix->xy = - FT_DivFix( matrix->xy, delta ); matrix->yx = - FT_DivFix( matrix->yx, delta ); |