1999-12-17 00:11:37 +01:00
|
|
|
/***************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* ftcalc.c */
|
|
|
|
/* */
|
|
|
|
/* Arithmetic computations (body). */
|
|
|
|
/* */
|
2006-02-17 09:07:09 +01:00
|
|
|
/* Copyright 1996-2001, 2002, 2003, 2004, 2005, 2006 by */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
|
|
|
|
/* */
|
2000-06-05 07:26:15 +02:00
|
|
|
/* This file is part of the FreeType project, and may only be used, */
|
|
|
|
/* modified, and distributed under the terms of the FreeType project */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
|
|
|
|
/* this file you indicate that you have read the license and */
|
|
|
|
/* understand and accept it fully. */
|
|
|
|
/* */
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* Support for 1-complement arithmetic has been totally dropped in this */
|
|
|
|
/* release. You can still write your own code if you need it. */
|
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
2000-01-02 10:41:30 +01:00
|
|
|
/* Implementing basic computation routines. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
2001-03-10 20:02:51 +01:00
|
|
|
/* FT_MulDiv(), FT_MulFix(), FT_DivFix(), FT_RoundFix(), FT_CeilFix(), */
|
|
|
|
/* and FT_FloorFix() are declared in freetype.h. */
|
1999-12-17 00:11:37 +01:00
|
|
|
/* */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2000-12-08 17:17:16 +01:00
|
|
|
|
|
|
|
#include <ft2build.h>
|
|
|
|
#include FT_INTERNAL_CALC_H
|
|
|
|
#include FT_INTERNAL_DEBUG_H
|
|
|
|
#include FT_INTERNAL_OBJECTS_H
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2001-06-14 14:34:00 +02:00
|
|
|
/* we need to define a 64-bits data type here */
|
|
|
|
|
2001-06-16 09:48:30 +02:00
|
|
|
#ifdef FT_LONG64
|
2001-06-14 14:34:00 +02:00
|
|
|
|
|
|
|
typedef FT_INT64 FT_Int64;
|
|
|
|
|
2001-06-16 09:48:30 +02:00
|
|
|
#else
|
2001-06-14 14:34:00 +02:00
|
|
|
|
|
|
|
typedef struct FT_Int64_
|
|
|
|
{
|
|
|
|
FT_UInt32 lo;
|
|
|
|
FT_UInt32 hi;
|
|
|
|
|
|
|
|
} FT_Int64;
|
|
|
|
|
2001-06-16 09:48:30 +02:00
|
|
|
#endif /* FT_LONG64 */
|
2001-06-14 14:34:00 +02:00
|
|
|
|
|
|
|
|
2000-06-03 08:03:11 +02:00
|
|
|
/*************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* The macro FT_COMPONENT is used in trace mode. It is an implicit */
|
|
|
|
/* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
|
|
|
|
/* messages during execution. */
|
|
|
|
/* */
|
|
|
|
#undef FT_COMPONENT
|
|
|
|
#define FT_COMPONENT trace_calc
|
|
|
|
|
2001-03-11 12:28:39 +01:00
|
|
|
|
2001-03-10 20:02:51 +01:00
|
|
|
/* The following three functions are available regardless of whether */
|
2002-04-02 16:50:31 +02:00
|
|
|
/* FT_LONG64 is defined. */
|
2001-03-10 20:02:51 +01:00
|
|
|
|
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Fixed )
|
|
|
|
FT_RoundFix( FT_Fixed a )
|
2001-03-10 20:02:51 +01:00
|
|
|
{
|
2003-12-24 02:10:46 +01:00
|
|
|
return ( a >= 0 ) ? ( a + 0x8000L ) & ~0xFFFFL
|
|
|
|
: -((-a + 0x8000L ) & ~0xFFFFL );
|
2001-03-10 20:02:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Fixed )
|
|
|
|
FT_CeilFix( FT_Fixed a )
|
2001-03-10 20:02:51 +01:00
|
|
|
{
|
2003-12-24 02:10:46 +01:00
|
|
|
return ( a >= 0 ) ? ( a + 0xFFFFL ) & ~0xFFFFL
|
|
|
|
: -((-a + 0xFFFFL ) & ~0xFFFFL );
|
2001-03-10 20:02:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Fixed )
|
|
|
|
FT_FloorFix( FT_Fixed a )
|
2001-03-10 20:02:51 +01:00
|
|
|
{
|
2003-12-24 02:10:46 +01:00
|
|
|
return ( a >= 0 ) ? a & ~0xFFFFL
|
|
|
|
: -((-a) & ~0xFFFFL );
|
2001-03-10 20:02:51 +01:00
|
|
|
}
|
|
|
|
|
2000-06-03 08:03:11 +02:00
|
|
|
|
* builds/amiga/src/base/ftsystem.c, devel/ftoption.h
include/freetype/ftcache.h, include/freetype/ftoutln.h,
include/freetype/cache/ftccache.h, include/freetype/cache/ftccmap.h,
include/freetype/config/ftoption.h, include/freetype/internal/ftcalc.h,
include/freetype/internal/ftdriver.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h, include/freetype/internal/ftrfork.h,
include/freetype/internal/psaux.h, include/freetype/internal/sfnt.h,
include/freetype/internal/t1types.h, include/freetype/internal/tttypes.h,
src/base/ftcalc.c, src/base/ftdbgmem.c, src/base/ftobjs.c,
src/base/ftsystem.c, src/base/ftutil.c, src/bdf/bdfdrivr.c,
src/cache/ftccache.c, src/cache/ftccback.h, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffdrivr.c, src/cid/cidriver.c,
src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c, src/psaux/psauxmod.c,
src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type42/t42drivr.c, src/winfonts/winfnt.c:
massive changes to the internals to respect the internal object layouts
and exported functions of FreeType 2.1.7. Note that the cache sub-system
cannot be fully retrofitted, unfortunately.
2006-02-16 23:45:31 +01:00
|
|
|
#ifdef FT_CONFIG_OPTION_OLD_INTERNALS
|
2005-11-12 18:07:11 +01:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftcalc.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Int32 )
|
|
|
|
FT_Sqrt32( FT_Int32 x )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_ULong val, root, newroot, mask;
|
2000-01-02 10:41:30 +01:00
|
|
|
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
root = 0;
|
2000-05-29 22:46:12 +02:00
|
|
|
mask = 0x40000000L;
|
1999-12-17 00:11:37 +01:00
|
|
|
val = (FT_ULong)x;
|
2000-01-02 10:41:30 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
do
|
|
|
|
{
|
2000-01-02 10:41:30 +01:00
|
|
|
newroot = root + mask;
|
2000-01-07 16:02:05 +01:00
|
|
|
if ( newroot <= val )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
val -= newroot;
|
2000-01-07 16:02:05 +01:00
|
|
|
root = newroot + mask;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-01-02 10:41:30 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
root >>= 1;
|
|
|
|
mask >>= 2;
|
2000-06-29 05:14:25 +02:00
|
|
|
|
|
|
|
} while ( mask != 0 );
|
2000-01-10 18:19:45 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
return root;
|
|
|
|
}
|
2000-05-29 22:46:12 +02:00
|
|
|
|
* builds/amiga/src/base/ftsystem.c, devel/ftoption.h
include/freetype/ftcache.h, include/freetype/ftoutln.h,
include/freetype/cache/ftccache.h, include/freetype/cache/ftccmap.h,
include/freetype/config/ftoption.h, include/freetype/internal/ftcalc.h,
include/freetype/internal/ftdriver.h,
include/freetype/internal/ftmemory.h,
include/freetype/internal/ftobjs.h, include/freetype/internal/ftrfork.h,
include/freetype/internal/psaux.h, include/freetype/internal/sfnt.h,
include/freetype/internal/t1types.h, include/freetype/internal/tttypes.h,
src/base/ftcalc.c, src/base/ftdbgmem.c, src/base/ftobjs.c,
src/base/ftsystem.c, src/base/ftutil.c, src/bdf/bdfdrivr.c,
src/cache/ftccache.c, src/cache/ftccback.h, src/cache/ftccmap.c,
src/cache/ftcmanag.c, src/cff/cffdrivr.c, src/cid/cidriver.c,
src/pcf/pcfdrivr.c, src/pfr/pfrdrivr.c, src/psaux/psauxmod.c,
src/sfnt/sfdriver.c, src/truetype/ttdriver.c, src/type1/t1driver.c,
src/type1/t1objs.c, src/type42/t42drivr.c, src/winfonts/winfnt.c:
massive changes to the internals to respect the internal object layouts
and exported functions of FreeType 2.1.7. Note that the cache sub-system
cannot be fully retrofitted, unfortunately.
2006-02-16 23:45:31 +01:00
|
|
|
#endif /* FT_CONFIG_OPTION_OLD_INTERNALS */
|
2005-11-12 18:07:11 +01:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-07-04 20:12:13 +02:00
|
|
|
#ifdef FT_LONG64
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_MulDiv( FT_Long a,
|
|
|
|
FT_Long b,
|
|
|
|
FT_Long c )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2001-05-08 14:58:07 +02:00
|
|
|
FT_Int s;
|
|
|
|
FT_Long d;
|
2000-05-30 00:40:57 +02:00
|
|
|
|
2001-05-08 15:52:13 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
s = 1;
|
2001-05-08 14:58:07 +02:00
|
|
|
if ( a < 0 ) { a = -a; s = -1; }
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( b < 0 ) { b = -b; s = -s; }
|
|
|
|
if ( c < 0 ) { c = -c; s = -s; }
|
|
|
|
|
2001-06-11 15:26:11 +02:00
|
|
|
d = (FT_Long)( c > 0 ? ( (FT_Int64)a * b + ( c >> 1 ) ) / c
|
2001-08-18 07:09:42 +02:00
|
|
|
: 0x7FFFFFFFL );
|
2001-05-08 14:58:07 +02:00
|
|
|
|
2001-05-08 15:52:13 +02:00
|
|
|
return ( s > 0 ) ? d : -d;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-26 09:24:08 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
/* documentation is in ftcalc.h */
|
|
|
|
|
|
|
|
FT_BASE_DEF( FT_Long )
|
|
|
|
FT_MulDiv_No_Round( FT_Long a,
|
|
|
|
FT_Long b,
|
|
|
|
FT_Long c )
|
|
|
|
{
|
|
|
|
FT_Int s;
|
|
|
|
FT_Long d;
|
|
|
|
|
|
|
|
|
|
|
|
s = 1;
|
|
|
|
if ( a < 0 ) { a = -a; s = -1; }
|
|
|
|
if ( b < 0 ) { b = -b; s = -s; }
|
|
|
|
if ( c < 0 ) { c = -c; s = -s; }
|
|
|
|
|
|
|
|
d = (FT_Long)( c > 0 ? (FT_Int64)a * b / c
|
|
|
|
: 0x7FFFFFFFL );
|
|
|
|
|
|
|
|
return ( s > 0 ) ? d : -d;
|
|
|
|
}
|
|
|
|
|
2003-11-26 09:24:08 +01:00
|
|
|
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_MulFix( FT_Long a,
|
|
|
|
FT_Long b )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2001-05-08 14:58:07 +02:00
|
|
|
FT_Int s = 1;
|
2001-05-08 15:52:13 +02:00
|
|
|
FT_Long c;
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-05-08 14:58:07 +02:00
|
|
|
if ( a < 0 ) { a = -a; s = -1; }
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( b < 0 ) { b = -b; s = -s; }
|
|
|
|
|
2003-06-23 21:26:53 +02:00
|
|
|
c = (FT_Long)( ( (FT_Int64)a * b + 0x8000L ) >> 16 );
|
2001-05-08 15:52:13 +02:00
|
|
|
return ( s > 0 ) ? c : -c ;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2000-01-02 10:41:30 +01:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_DivFix( FT_Long a,
|
|
|
|
FT_Long b )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Int32 s;
|
2000-07-05 06:32:02 +02:00
|
|
|
FT_UInt32 q;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-05-14 16:04:23 +02:00
|
|
|
s = 1;
|
|
|
|
if ( a < 0 ) { a = -a; s = -1; }
|
|
|
|
if ( b < 0 ) { b = -b; s = -s; }
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( b == 0 )
|
2000-05-30 00:40:57 +02:00
|
|
|
/* check for division by 0 */
|
2000-05-29 22:46:12 +02:00
|
|
|
q = 0x7FFFFFFFL;
|
2000-01-10 18:19:45 +01:00
|
|
|
else
|
1999-12-17 00:11:37 +01:00
|
|
|
/* compute result directly */
|
2001-06-11 15:26:11 +02:00
|
|
|
q = (FT_UInt32)( ( ( (FT_Int64)a << 16 ) + ( b >> 1 ) ) / b );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-05-24 17:00:19 +02:00
|
|
|
return ( s < 0 ? -(FT_Long)q : (FT_Long)q );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
#else /* FT_LONG64 */
|
2000-09-02 02:20:42 +02:00
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
|
|
|
|
static void
|
|
|
|
ft_multo64( FT_UInt32 x,
|
|
|
|
FT_UInt32 y,
|
|
|
|
FT_Int64 *z )
|
2000-09-02 02:20:42 +02:00
|
|
|
{
|
2001-04-26 15:34:36 +02:00
|
|
|
FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
|
2001-04-26 02:21:48 +02:00
|
|
|
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
|
|
|
|
lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
|
2000-11-07 18:21:11 +01:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
lo = lo1 * lo2;
|
|
|
|
i1 = lo1 * hi2;
|
|
|
|
i2 = lo2 * hi1;
|
|
|
|
hi = hi1 * hi2;
|
2001-04-26 02:21:48 +02:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
/* Check carry overflow of i1 + i2 */
|
|
|
|
i1 += i2;
|
|
|
|
hi += (FT_UInt32)( i1 < i2 ) << 16;
|
2001-04-26 02:21:48 +02:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
hi += i1 >> 16;
|
|
|
|
i1 = i1 << 16;
|
2001-04-26 02:21:48 +02:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
/* Check carry overflow of i1 + lo */
|
|
|
|
lo += i1;
|
|
|
|
hi += ( lo < i1 );
|
2001-04-26 02:21:48 +02:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
z->lo = lo;
|
|
|
|
z->hi = hi;
|
2000-09-02 02:20:42 +02:00
|
|
|
}
|
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
|
|
|
|
static FT_UInt32
|
|
|
|
ft_div64by32( FT_UInt32 hi,
|
|
|
|
FT_UInt32 lo,
|
2001-04-26 15:34:36 +02:00
|
|
|
FT_UInt32 y )
|
2001-04-26 02:21:48 +02:00
|
|
|
{
|
2001-06-24 19:23:45 +02:00
|
|
|
FT_UInt32 r, q;
|
|
|
|
FT_Int i;
|
2001-04-26 15:34:36 +02:00
|
|
|
|
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
q = 0;
|
2001-04-26 15:34:36 +02:00
|
|
|
r = hi;
|
|
|
|
|
|
|
|
if ( r >= y )
|
|
|
|
return (FT_UInt32)0x7FFFFFFFL;
|
|
|
|
|
|
|
|
i = 32;
|
2001-04-26 02:21:48 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
r <<= 1;
|
|
|
|
q <<= 1;
|
|
|
|
r |= lo >> 31;
|
|
|
|
|
|
|
|
if ( r >= (FT_UInt32)y )
|
|
|
|
{
|
|
|
|
r -= y;
|
|
|
|
q |= 1;
|
|
|
|
}
|
|
|
|
lo <<= 1;
|
2001-04-26 15:34:36 +02:00
|
|
|
} while ( --i );
|
|
|
|
|
|
|
|
return q;
|
2001-04-26 02:21:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-11-12 18:07:11 +01:00
|
|
|
static void
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_Add64( FT_Int64* x,
|
|
|
|
FT_Int64* y,
|
|
|
|
FT_Int64 *z )
|
2001-04-26 02:21:48 +02:00
|
|
|
{
|
|
|
|
register FT_UInt32 lo, hi, max;
|
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
max = x->lo > y->lo ? x->lo : y->lo;
|
|
|
|
lo = x->lo + y->lo;
|
|
|
|
hi = x->hi + y->hi + ( lo < max );
|
|
|
|
|
|
|
|
z->lo = lo;
|
|
|
|
z->hi = hi;
|
|
|
|
}
|
2000-05-02 12:52:28 +02:00
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_MulDiv( FT_Long a,
|
|
|
|
FT_Long b,
|
|
|
|
FT_Long c )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2001-04-26 15:34:36 +02:00
|
|
|
long s;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
if ( a == 0 || b == c )
|
|
|
|
return a;
|
|
|
|
|
2004-03-05 10:26:24 +01:00
|
|
|
s = a; a = FT_ABS( a );
|
|
|
|
s ^= b; b = FT_ABS( b );
|
|
|
|
s ^= c; c = FT_ABS( c );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-06-18 16:23:45 +02:00
|
|
|
if ( a <= 46340L && b <= 46340L && c <= 176095L && c > 0 )
|
2000-05-30 00:40:57 +02:00
|
|
|
a = ( a * b + ( c >> 1 ) ) / c;
|
2003-11-25 19:15:56 +01:00
|
|
|
|
2000-05-30 00:40:57 +02:00
|
|
|
else if ( c > 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Int64 temp, temp2;
|
|
|
|
|
2000-05-30 00:40:57 +02:00
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
ft_multo64( a, b, &temp );
|
2001-04-26 15:34:36 +02:00
|
|
|
|
|
|
|
temp2.hi = 0;
|
|
|
|
temp2.lo = (FT_UInt32)(c >> 1);
|
|
|
|
FT_Add64( &temp, &temp2, &temp );
|
2001-08-18 07:09:42 +02:00
|
|
|
a = ft_div64by32( temp.hi, temp.lo, c );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-05-29 22:55:13 +02:00
|
|
|
else
|
2000-05-30 00:40:57 +02:00
|
|
|
a = 0x7FFFFFFFL;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-06-07 02:00:08 +02:00
|
|
|
return ( s < 0 ? -a : a );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-11-26 09:24:08 +01:00
|
|
|
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
FT_BASE_DEF( FT_Long )
|
|
|
|
FT_MulDiv_No_Round( FT_Long a,
|
|
|
|
FT_Long b,
|
|
|
|
FT_Long c )
|
|
|
|
{
|
|
|
|
long s;
|
|
|
|
|
|
|
|
|
|
|
|
if ( a == 0 || b == c )
|
|
|
|
return a;
|
|
|
|
|
2004-03-05 10:26:24 +01:00
|
|
|
s = a; a = FT_ABS( a );
|
|
|
|
s ^= b; b = FT_ABS( b );
|
|
|
|
s ^= c; c = FT_ABS( c );
|
2003-11-25 19:15:56 +01:00
|
|
|
|
|
|
|
if ( a <= 46340L && b <= 46340L && c > 0 )
|
|
|
|
a = a * b / c;
|
|
|
|
|
|
|
|
else if ( c > 0 )
|
|
|
|
{
|
|
|
|
FT_Int64 temp;
|
|
|
|
|
|
|
|
|
|
|
|
ft_multo64( a, b, &temp );
|
|
|
|
a = ft_div64by32( temp.hi, temp.lo, c );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
a = 0x7FFFFFFFL;
|
|
|
|
|
|
|
|
return ( s < 0 ? -a : a );
|
|
|
|
}
|
|
|
|
|
2003-11-26 09:24:08 +01:00
|
|
|
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
|
|
|
|
|
2003-11-25 19:15:56 +01:00
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_MulFix( FT_Long a,
|
|
|
|
FT_Long b )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2006-05-18 00:55:04 +02:00
|
|
|
/* use inline assembly to speed up things a bit */
|
|
|
|
|
|
|
|
#if defined( __GNUC__ ) && defined( i386 )
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
|
|
|
|
FT_Long result;
|
|
|
|
|
2006-05-18 00:55:04 +02:00
|
|
|
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
__asm__ __volatile__ (
|
2006-05-18 00:55:04 +02:00
|
|
|
"imul %%edx\n"
|
|
|
|
"movl %%edx, %%ecx\n"
|
|
|
|
"sarl $31, %%ecx\n"
|
|
|
|
"addl $0x8000, %%ecx\n"
|
|
|
|
"addl %%ecx, %%eax\n"
|
|
|
|
"adcl $0, %%edx\n"
|
|
|
|
"shrl $16, %%eax\n"
|
|
|
|
"shll $16, %%edx\n"
|
|
|
|
"addl %%edx, %%eax\n"
|
|
|
|
"mov %%eax, %0\n"
|
|
|
|
: "=r"(result)
|
|
|
|
: "a"(a), "d"(b)
|
|
|
|
: "%ecx"
|
|
|
|
);
|
|
|
|
return result;
|
* include/freetype/internal/tttypes.h, src/autofit/afangles.c,
src/autofit/afcjk.c, src/autofit/afhints.c, src/autofit/aflatin.c,
src/autofit/aftypes.h, src/base/ftcalc.c, src/base/ftoutln.c,
src/gzip/ftgzip.c, src/psaux/psconv.c, src/truetype/ttgload.c,
src/type1/t1gload.c:
this is a major patch used to drastically improve the performance
of loading glyphs. This both speeds up loading the glypn vector
themselves and the auto-fitter.
note that we've started using inline assembler with GCC to
implement FT_MulFix, given that this function is so damn
important for the engine's performance.
the resulting speed-up is about 25%.
2006-05-17 15:34:21 +02:00
|
|
|
|
|
|
|
#elif 1
|
2006-05-18 00:55:04 +02:00
|
|
|
|
2005-10-28 18:14:14 +02:00
|
|
|
FT_Long sa, sb;
|
|
|
|
FT_ULong ua, ub;
|
|
|
|
|
|
|
|
|
|
|
|
if ( a == 0 || b == 0x10000L )
|
|
|
|
return a;
|
|
|
|
|
2005-11-12 08:34:40 +01:00
|
|
|
sa = ( a >> ( sizeof ( a ) * 8 - 1 ) );
|
2006-05-18 00:55:04 +02:00
|
|
|
a = ( a ^ sa ) - sa;
|
2005-11-12 08:34:40 +01:00
|
|
|
sb = ( b >> ( sizeof ( b ) * 8 - 1 ) );
|
2006-05-18 00:55:04 +02:00
|
|
|
b = ( b ^ sb ) - sb;
|
2005-10-28 18:14:14 +02:00
|
|
|
|
|
|
|
ua = (FT_ULong)a;
|
|
|
|
ub = (FT_ULong)b;
|
|
|
|
|
|
|
|
if ( ua <= 2048 && ub <= 1048576L )
|
2006-05-18 00:55:04 +02:00
|
|
|
ua = ( ua * ub + 0x8000U ) >> 16;
|
2005-10-28 18:14:14 +02:00
|
|
|
else
|
|
|
|
{
|
2006-05-18 00:55:04 +02:00
|
|
|
FT_ULong al = ua & 0xFFFFU;
|
2005-10-28 18:14:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
|
2006-05-18 00:55:04 +02:00
|
|
|
( ( al * ( ub & 0xFFFFU ) + 0x8000U ) >> 16 );
|
2005-10-28 18:14:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
sa ^= sb,
|
2005-11-12 08:34:40 +01:00
|
|
|
ua = (FT_ULong)(( ua ^ sa ) - sa);
|
2005-10-28 18:14:14 +02:00
|
|
|
|
|
|
|
return (FT_Long)ua;
|
2005-11-12 08:34:40 +01:00
|
|
|
|
|
|
|
#else /* 0 */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
FT_Long s;
|
2000-03-28 13:17:58 +02:00
|
|
|
FT_ULong ua, ub;
|
2000-01-02 10:41:30 +01:00
|
|
|
|
2000-05-29 22:46:12 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( a == 0 || b == 0x10000L )
|
|
|
|
return a;
|
|
|
|
|
2006-05-18 00:55:04 +02:00
|
|
|
s = a; a = FT_ABS( a );
|
|
|
|
s ^= b; b = FT_ABS( b );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-03-28 13:17:58 +02:00
|
|
|
ua = (FT_ULong)a;
|
|
|
|
ub = (FT_ULong)b;
|
|
|
|
|
|
|
|
if ( ua <= 2048 && ub <= 1048576L )
|
2006-05-18 00:55:04 +02:00
|
|
|
ua = ( ua * ub + 0x8000UL ) >> 16;
|
1999-12-17 00:11:37 +01:00
|
|
|
else
|
|
|
|
{
|
2006-05-18 00:55:04 +02:00
|
|
|
FT_ULong al = ua & 0xFFFFUL;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-01-02 10:41:30 +01:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
|
2006-05-18 00:55:04 +02:00
|
|
|
( ( al * ( ub & 0xFFFFUL ) + 0x8000UL ) >> 16 );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
* src/base/ftdbgmem.c (ft_mem_table_resize, ft_mem_table_new,
ft_mem_table_set, ft_mem_debug_alloc, ft_mem_debug_free,
ft_mem_debug_realloc, ft_mem_debug_done, FT_Alloc_Debug,
FT_Realloc_Debug, FT_Free_Debug): Fix compiler warnings.
* src/base/ftcalc.c (FT_MulFix): Ditto.
* src/cff/cffdrivr.c (cff_get_name_index): Ditto.
* src/cff/cffobjs.c (CFF_Size_Get_Global_Funcs, CFF_Size_Init,
CFF_GlyphSlot_Init): Ditto.
* src/cid/cidobjs.c (CID_GlyphSlot_Init,
CID_Size_Get_Globals_Funcs): Ditto.
* src/type1/t1objs.c (T1_Size_Get_Globals_Funcs, T1_GlyphSlot_Init):
Ditto.
* src/pshinter/pshmod.c (pshinter_interface): Use `static const'.
* src/winfonts/winfnt.c (FNT_Get_Next_Char): Remove unused
variables.
* include/freetype/internal/psaux.h (T1_Builder_Funcs): Renamed
to...
(T1_Builder_FuncsRec): This.
(T1_Builder_Funcs): New typedef.
(PSAux_Interface): Remove compiler warnings.
* src/psaux/psauxmod.c (t1_builder_funcs), src/psaux/psobjs.h
(t1_builder_funcs): Updated.
* src/pshinter/pshglob.h (PSH_Blue_Align): Replaced with ...
(PSH_BLUE_ALIGN_{NONE,TOP,BOT}): New defines.
(PSH_AlignmentRec): Updated.
* include/freetype/internal/ftstream.h (GET_Char, GET_Byte): Fix
typo.
* include/freetype/internal/ftgloadr.h (FT_SubGlyph): Ditto.
* src/base/ftstream (FT_Get_Char): Rename to...
(FT_Stream_Get_Char): This.
* src/base/ftnames.c (FT_Get_Sfnt_Name): s/index/idx/ -- `index' is
a built-in function in gcc, causing warning messages with gcc 3.0.
* src/autohint/ahglyph.c (ah_outline_load): Ditto.
* src/autohint/ahglobal.c (ah_hinter_compute_blues): Ditto.
* src/cache/ftcmanag.c (ftc_family_table_alloc,
ftc_family_table_free, FTC_Manager_Done, FTC_Manager_Register_Cache):
Ditto.
* src/cff/cffload.c (cff_new_index, cff_done_index,
cff_explicit_index, CFF_Access_Element, CFF_Forget_Element,
CFF_Get_Name, CFF_Get_String, CFF_Load_SubFont, CFF_Load_Font,
CFF_Done_Font): Ditto.
* src/psaux/psobjs.c (PS_Table_Add, PS_Parser_LoadField): Ditto.
* src/psaux/t1decode.c (T1_Decoder_Parse_Charstrings): Ditto.
* src/pshinter/pshrec.c (ps_mask_test_bit, ps_mask_clear_bit,
ps_mask_set_bit, ps_dimension_add_t1stem, ps_hints_t1stem3,
* src/pshinter/pshalgo1.c (psh1_hint_table_record,
psh1_hint_table_record_mask, psh1_hint_table_activate_mask): Ditto.
* src/pshinter/pshalgo2.c (psh2_hint_table_record,
psh2_hint_table_record_mask, psh2_hint_table_activate_mask): Ditto.
* src/sfnt/ttpost.c (Load_Format_20, Load_Format_25,
TT_Get_PS_Name): Ditto.
* src/truetype/ttgload.c (TT_Get_Metrics, Get_HMetrics,
load_truetype_glyph): Ditto.
* src/type1/t1load.c (parse_subrs, T1_Open_Face): Ditto.
* src/type1/t1afm.c (T1_Get_Kerning): Ditto.
* include/freetype/cache/ftcmanag.h (ftc_family_table_free): Ditto.
2002-03-07 22:59:59 +01:00
|
|
|
return ( s < 0 ? -(FT_Long)ua : (FT_Long)ua );
|
2005-11-12 08:34:40 +01:00
|
|
|
|
|
|
|
#endif /* 0 */
|
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in freetype.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Long )
|
|
|
|
FT_DivFix( FT_Long a,
|
|
|
|
FT_Long b )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Int32 s;
|
2000-07-05 06:32:02 +02:00
|
|
|
FT_UInt32 q;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-01-02 10:41:30 +01:00
|
|
|
|
2004-03-05 10:26:24 +01:00
|
|
|
s = a; a = FT_ABS(a);
|
|
|
|
s ^= b; b = FT_ABS(b);
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
if ( b == 0 )
|
2000-05-30 00:40:57 +02:00
|
|
|
{
|
|
|
|
/* check for division by 0 */
|
2000-05-29 22:46:12 +02:00
|
|
|
q = 0x7FFFFFFFL;
|
2000-05-30 00:40:57 +02:00
|
|
|
}
|
|
|
|
else if ( ( a >> 16 ) == 0 )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
/* compute result directly */
|
2001-04-26 02:21:48 +02:00
|
|
|
q = (FT_UInt32)( (a << 16) + (b >> 1) ) / (FT_UInt32)b;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-06-29 05:14:25 +02:00
|
|
|
/* we need more bits; we have to do it by hand */
|
2000-09-02 02:20:42 +02:00
|
|
|
FT_Int64 temp, temp2;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-09-02 02:20:42 +02:00
|
|
|
temp.hi = (FT_Int32) (a >> 16);
|
|
|
|
temp.lo = (FT_UInt32)(a << 16);
|
2001-04-26 02:21:48 +02:00
|
|
|
temp2.hi = 0;
|
|
|
|
temp2.lo = (FT_UInt32)( b >> 1 );
|
2000-09-02 02:20:42 +02:00
|
|
|
FT_Add64( &temp, &temp2, &temp );
|
2001-04-26 02:21:48 +02:00
|
|
|
q = ft_div64by32( temp.hi, temp.lo, b );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
* src/base/ftcalc.c (FT_MulTo64): Commented out.
* include/freetype/internal/ftcalc.h (FT_SqrtFixed), src/base/ftcalc.c
(FT_SqrtFixed), include/freetype/internal/ftdebug.h
(FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message, FT_Panic),
src/base/ftdebug.c (FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message,
FT_Panic), include/freetype/internal/ftobjs.h (FT_New_Memory,
FT_Done_Memory), include/freetype/internal/ftstream.h
(FT_Stream_Open), src/base/ftsystem.c (FT_New_Memory, FT_Done_Memory,
FT_Stream_Open): s/FT_EXPORT/FT_BASE/.
* builds/exports.mk: Manually add TT_New_Context to EXPORTS_LIST too.
2005-11-17 02:53:07 +01:00
|
|
|
#if 0
|
|
|
|
|
2000-11-07 18:21:11 +01:00
|
|
|
/* documentation is in ftcalc.h */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( void )
|
|
|
|
FT_MulTo64( FT_Int32 x,
|
|
|
|
FT_Int32 y,
|
|
|
|
FT_Int64 *z )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
2001-04-26 15:34:36 +02:00
|
|
|
FT_Int32 s;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
|
2004-03-05 10:26:24 +01:00
|
|
|
s = x; x = FT_ABS( x );
|
|
|
|
s ^= y; y = FT_ABS( y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
ft_multo64( x, y, z );
|
2001-04-26 15:34:36 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
if ( s < 0 )
|
|
|
|
{
|
2000-07-05 06:32:02 +02:00
|
|
|
z->lo = (FT_UInt32)-(FT_Int32)z->lo;
|
2000-06-29 05:14:25 +02:00
|
|
|
z->hi = ~z->hi + !( z->lo );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-18 11:51:09 +02:00
|
|
|
/* apparently, the second version of this code is not compiled correctly */
|
2005-11-12 18:07:11 +01:00
|
|
|
/* on Mac machines with the MPW C compiler.. tsk, tsk, tsk... */
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2001-10-18 11:51:09 +02:00
|
|
|
#if 1
|
2002-04-02 16:50:31 +02:00
|
|
|
|
2001-10-18 11:51:09 +02:00
|
|
|
FT_EXPORT_DEF( FT_Int32 )
|
|
|
|
FT_Div64by32( FT_Int64* x,
|
|
|
|
FT_Int32 y )
|
|
|
|
{
|
|
|
|
FT_Int32 s;
|
|
|
|
FT_UInt32 q, r, i, lo;
|
|
|
|
|
|
|
|
|
|
|
|
s = x->hi;
|
|
|
|
if ( s < 0 )
|
|
|
|
{
|
|
|
|
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
|
2001-12-05 02:22:05 +01:00
|
|
|
x->hi = ~x->hi + !x->lo;
|
2001-10-18 11:51:09 +02:00
|
|
|
}
|
2004-03-05 10:26:24 +01:00
|
|
|
s ^= y; y = FT_ABS( y );
|
2001-10-18 11:51:09 +02:00
|
|
|
|
|
|
|
/* Shortcut */
|
|
|
|
if ( x->hi == 0 )
|
|
|
|
{
|
|
|
|
if ( y > 0 )
|
|
|
|
q = x->lo / y;
|
|
|
|
else
|
|
|
|
q = 0x7FFFFFFFL;
|
|
|
|
|
|
|
|
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
|
|
|
}
|
|
|
|
|
|
|
|
r = x->hi;
|
|
|
|
lo = x->lo;
|
|
|
|
|
|
|
|
if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
|
|
|
|
return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
|
|
|
|
/* Return Max/Min Int32 if division overflow. */
|
|
|
|
/* This includes division by zero! */
|
|
|
|
q = 0;
|
|
|
|
for ( i = 0; i < 32; i++ )
|
|
|
|
{
|
|
|
|
r <<= 1;
|
|
|
|
q <<= 1;
|
|
|
|
r |= lo >> 31;
|
|
|
|
|
|
|
|
if ( r >= (FT_UInt32)y )
|
|
|
|
{
|
|
|
|
r -= y;
|
|
|
|
q |= 1;
|
|
|
|
}
|
|
|
|
lo <<= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
|
|
|
}
|
2002-04-02 16:50:31 +02:00
|
|
|
|
|
|
|
#else /* 0 */
|
|
|
|
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_EXPORT_DEF( FT_Int32 )
|
|
|
|
FT_Div64by32( FT_Int64* x,
|
|
|
|
FT_Int32 y )
|
1999-12-17 00:11:37 +01:00
|
|
|
{
|
|
|
|
FT_Int32 s;
|
2001-04-26 02:21:48 +02:00
|
|
|
FT_UInt32 q;
|
1999-12-17 00:11:37 +01:00
|
|
|
|
2000-05-30 00:40:57 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
s = x->hi;
|
|
|
|
if ( s < 0 )
|
|
|
|
{
|
2000-07-05 06:32:02 +02:00
|
|
|
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
|
2001-12-05 02:22:05 +01:00
|
|
|
x->hi = ~x->hi + !x->lo;
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2004-03-05 10:26:24 +01:00
|
|
|
s ^= y; y = FT_ABS( y );
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* Shortcut */
|
|
|
|
if ( x->hi == 0 )
|
|
|
|
{
|
2000-05-30 00:40:57 +02:00
|
|
|
if ( y > 0 )
|
2001-04-26 15:34:36 +02:00
|
|
|
q = ( x->lo + ( y >> 1 ) ) / y;
|
2000-05-30 00:40:57 +02:00
|
|
|
else
|
|
|
|
q = 0x7FFFFFFFL;
|
2000-05-29 22:55:13 +02:00
|
|
|
|
2000-06-07 02:00:08 +02:00
|
|
|
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
|
|
|
|
2001-04-26 02:21:48 +02:00
|
|
|
q = ft_div64by32( x->hi, x->lo, y );
|
2001-04-26 15:34:36 +02:00
|
|
|
|
2000-06-07 02:00:08 +02:00
|
|
|
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
|
1999-12-17 00:11:37 +01:00
|
|
|
}
|
2000-09-02 02:20:42 +02:00
|
|
|
|
2002-04-02 16:50:31 +02:00
|
|
|
#endif /* 0 */
|
2001-04-25 20:11:16 +02:00
|
|
|
|
2005-11-12 18:07:11 +01:00
|
|
|
#endif /* 0 */
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
|
2001-04-26 00:56:30 +02:00
|
|
|
#endif /* FT_LONG64 */
|
|
|
|
|
|
|
|
|
2004-12-14 00:16:59 +01:00
|
|
|
/* documentation is in ftcalc.h */
|
2001-04-26 15:34:36 +02:00
|
|
|
|
* src/base/ftcalc.c (FT_MulTo64): Commented out.
* include/freetype/internal/ftcalc.h (FT_SqrtFixed), src/base/ftcalc.c
(FT_SqrtFixed), include/freetype/internal/ftdebug.h
(FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message, FT_Panic),
src/base/ftdebug.c (FT_Trace_Get_Count, FT_Trace_Get_Name, FT_Message,
FT_Panic), include/freetype/internal/ftobjs.h (FT_New_Memory,
FT_Done_Memory), include/freetype/internal/ftstream.h
(FT_Stream_Open), src/base/ftsystem.c (FT_New_Memory, FT_Done_Memory,
FT_Stream_Open): s/FT_EXPORT/FT_BASE/.
* builds/exports.mk: Manually add TT_New_Context to EXPORTS_LIST too.
2005-11-17 02:53:07 +01:00
|
|
|
FT_BASE_DEF( FT_Int32 )
|
2001-06-27 18:18:10 +02:00
|
|
|
FT_SqrtFixed( FT_Int32 x )
|
2000-09-02 02:20:42 +02:00
|
|
|
{
|
2001-04-25 20:11:16 +02:00
|
|
|
FT_UInt32 root, rem_hi, rem_lo, test_div;
|
|
|
|
FT_Int count;
|
2000-10-31 21:42:18 +01:00
|
|
|
|
2001-04-26 15:34:36 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
root = 0;
|
2000-09-02 02:20:42 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
if ( x > 0 )
|
|
|
|
{
|
|
|
|
rem_hi = 0;
|
|
|
|
rem_lo = x;
|
2001-04-26 00:56:30 +02:00
|
|
|
count = 24;
|
2001-04-26 15:34:36 +02:00
|
|
|
do
|
2001-04-25 20:11:16 +02:00
|
|
|
{
|
2001-04-26 15:34:36 +02:00
|
|
|
rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 );
|
2001-04-25 20:11:16 +02:00
|
|
|
rem_lo <<= 2;
|
|
|
|
root <<= 1;
|
2001-04-26 15:34:36 +02:00
|
|
|
test_div = ( root << 1 ) + 1;
|
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
if ( rem_hi >= test_div )
|
|
|
|
{
|
|
|
|
rem_hi -= test_div;
|
|
|
|
root += 1;
|
|
|
|
}
|
2001-04-26 15:34:36 +02:00
|
|
|
} while ( --count );
|
2001-04-25 20:11:16 +02:00
|
|
|
}
|
2000-09-12 00:50:13 +02:00
|
|
|
|
2001-04-25 20:11:16 +02:00
|
|
|
return (FT_Int32)root;
|
|
|
|
}
|
2000-05-02 12:52:28 +02:00
|
|
|
|
1999-12-17 00:11:37 +01:00
|
|
|
|
|
|
|
/* END */
|