37 #include FT_INTERNAL_CALC_H
38 #include FT_INTERNAL_DEBUG_H
39 #include FT_INTERNAL_OBJECTS_H
41 #ifdef FT_MULFIX_INLINED
53 typedef struct FT_Int64_
70 #define FT_COMPONENT trace_calc
81 return ( a >= 0 ) ? ( a + 0x8000L ) & ~0xFFFFL
82 : -((-a + 0x8000L ) & ~0xFFFFL );
91 return ( a >= 0 ) ? ( a + 0xFFFFL ) & ~0xFFFFL
92 : -((-a + 0xFFFFL ) & ~0xFFFFL );
101 return ( a >= 0 ) ? a & ~0xFFFFL
102 : -((-
a) & ~0xFFFFL );
106 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS
111 FT_Sqrt32( FT_Int32
x )
113 FT_UInt32
val, root, newroot,
mask;
117 mask = (FT_UInt32)0x40000000UL;
122 newroot = root +
mask;
123 if ( newroot <= val )
126 root = newroot +
mask;
132 }
while ( mask != 0 );
155 if ( a < 0 ) { a = -
a; s = -1; }
156 if ( b < 0 ) { b = -
b; s = -
s; }
157 if ( c < 0 ) { c = -
c; s = -
s; }
162 return ( s > 0 ) ? d : -
d;
166 #ifdef TT_USE_BYTECODE_INTERPRETER
180 if ( a < 0 ) { a = -
a; s = -1; }
181 if ( b < 0 ) { b = -
b; s = -
s; }
182 if ( c < 0 ) { c = -
c; s = -
s; }
187 return ( s > 0 ) ? d : -
d;
199 #ifdef FT_MULFIX_ASSEMBLER
201 return FT_MULFIX_ASSEMBLER( a, b );
223 return ( s > 0 ) ? c : -
c;
239 if ( a < 0 ) { a = -
a; s = -1; }
240 if ( b < 0 ) { b = -
b; s = -
s; }
247 q = (FT_UInt32)( ( ( (
FT_Int64)a << 16 ) + ( b >> 1 ) ) /
b );
261 FT_UInt32 lo1, hi1, lo2, hi2,
lo,
hi,
i1,
i2;
264 lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
265 lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
274 hi += (FT_UInt32)( i1 < i2 ) << 16;
301 return (FT_UInt32)0x7FFFFFFFL;
327 register FT_UInt32
lo,
hi;
331 hi = x->hi + y->hi + ( lo < x->lo );
366 if ( a == 0 || b == c )
374 a = ( a * b + ( c >> 1 ) ) /
c;
376 else if ( (FT_Int32)c > 0 )
381 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
384 temp2.lo = (FT_UInt32)(c >> 1);
391 return ( s < 0 ? -a : a );
395 #ifdef TT_USE_BYTECODE_INTERPRETER
405 if ( a == 0 || b == c )
415 else if ( (FT_Int32)c > 0 )
420 ft_multo64( (FT_Int32)a, (FT_Int32)b, &temp );
426 return ( s < 0 ? -a : a );
438 #ifdef FT_MULFIX_ASSEMBLER
440 return FT_MULFIX_ASSEMBLER( a, b );
455 if ( a == 0 || b == 0x10000L )
476 sa = ( a >> (
sizeof (
a ) * 8 - 1 ) );
478 sb = ( b >> (
sizeof (
b ) * 8 - 1 ) );
484 if ( ua <= 2048 && ub <= 1048576L )
485 ua = ( ua * ub + 0x8000U ) >> 16;
491 ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
492 ( ( al * ( ub & 0xFFFFU ) + 0x8000U ) >> 16 );
506 if ( a == 0 || b == 0x10000L )
515 if ( ua <= 2048 && ub <= 1048576L )
516 ua = ( ua * ub + 0x8000UL ) >> 16;
522 ua = ( ua >> 16 ) * ub + al * ( ub >> 16 ) +
523 ( ( al * ( ub & 0xFFFFUL ) + 0x8000UL ) >> 16 );
544 s = (FT_Int32)a; a =
FT_ABS( a );
545 s ^= (FT_Int32)b; b =
FT_ABS( b );
547 if ( (FT_UInt32)b == 0 )
550 q = (FT_UInt32)0x7FFFFFFFL;
552 else if ( ( a >> 16 ) == 0 )
555 q = (FT_UInt32)( ( a << 16 ) + ( b >> 1 ) ) / (FT_UInt32)b;
563 temp.hi = (FT_Int32) ( a >> 16 );
564 temp.lo = (FT_UInt32)( a << 16 );
566 temp2.lo = (FT_UInt32)( b >> 1 );
571 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
580 FT_MulTo64( FT_Int32 x,
594 z->lo = (FT_UInt32)-(FT_Int32)z->lo;
595 z->hi = ~z->hi + !( z->lo );
610 FT_UInt32
q,
r,
i,
lo;
616 x->lo = (FT_UInt32)-(FT_Int32)x->lo;
617 x->hi = ~x->hi + !x->lo;
629 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
635 if ( r >= (FT_UInt32)y )
636 return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
640 for ( i = 0; i < 32; i++ )
646 if ( r >= (FT_UInt32)y )
654 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
670 x->lo = (FT_UInt32)-(FT_Int32)x->lo;
671 x->hi = ~x->hi + !x->lo;
679 q = ( x->lo + ( y >> 1 ) ) /
y;
683 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
688 return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
716 b->xx = xx; b->xy = xy;
717 b->yx = yx; b->yy = yy;
733 delta =
FT_MulFix( matrix->xx, matrix->yy ) -
739 matrix->xy = -
FT_DivFix( matrix->xy, delta );
740 matrix->yx = -
FT_DivFix( matrix->yx, delta );
761 FT_Long val = 0x10000L * scaling;
772 b->xx = xx; b->xy = xy;
773 b->yx = yx; b->yy = yy;
786 FT_Long val = 0x10000L * scaling;
789 if ( !vector || !matrix )
792 xz =
FT_MulDiv( vector->x, matrix->xx, val ) +
795 yz =
FT_MulDiv( vector->x, matrix->yx, val ) +
808 FT_UInt32 root, rem_hi, rem_lo, test_div;
821 rem_hi = ( rem_hi << 2 ) | ( rem_lo >> 30 );
824 test_div = ( root << 1 ) + 1;
826 if ( rem_hi >= test_div )
834 return (FT_Int32)root;
857 else if ( in_x == 0 )
864 else if ( out_y == 0 )
871 else if ( out_x == 0 )
888 result = 1 - 2 * ( delta < 0 );
896 ft_multo64( (FT_Int32)in_x, (FT_Int32)out_y, &z1 );
897 ft_multo64( (FT_Int32)in_y, (FT_Int32)out_x, &z2 );
901 else if ( z1.hi < z2.hi )
903 else if ( z1.lo > z2.lo )
905 else if ( z1.lo < z2.lo )
929 FT_Pos d_in, d_out, d_corner;
954 return ( d_in + d_out - d_corner ) < ( d_corner >> 4 );
FT_DivFix(FT_Long a, FT_Long b)
GLuint const GLfloat * val
FT_BEGIN_HEADER typedef signed long FT_Pos
static FT_UInt32 ft_div64by32(FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 y)
return FT_Err_Invalid_Argument
FT_Matrix_Multiply(const FT_Matrix *a, FT_Matrix *b)
GLboolean GLboolean GLboolean GLboolean a
return Display return Display Bool Bool int d
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint GLint i2
ft_corner_is_flat(FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
static void FT_Add64(FT_Int64 *x, FT_Int64 *y, FT_Int64 *z)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
FT_BEGIN_HEADER FT_SqrtFixed(FT_Int32 x)
const GLubyte GLuint GLuint GLuint GLuint alpha GLboolean GLboolean GLboolean GLboolean alpha GLint GLint GLsizei GLsizei GLenum type GLenum GLint GLenum GLint GLint GLsizei GLsizei GLint border GLenum GLint GLint GLint GLint GLint GLsizei GLsizei height GLsizei GLsizei GLenum GLenum const GLvoid *pixels GLenum GLint i1
ft_corner_orientation(FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
FT_Vector_Transform_Scaled(FT_Vector *vector, const FT_Matrix *matrix, FT_Long scaling)
EGLSurface EGLint EGLint y
FT_MulFix(FT_Long a, FT_Long b)
static void ft_multo64(FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
GLdouble GLdouble GLdouble GLdouble q
GLint GLint GLint GLint GLint GLint GLint GLbitfield mask
FT_Matrix_Multiply_Scaled(const FT_Matrix *a, FT_Matrix *b, FT_Long scaling)
GLdouble GLdouble GLdouble r
GLdouble GLdouble GLdouble b
GLint GLint GLint GLint z
FT_Matrix_Invert(FT_Matrix *matrix)
struct FT_Int64_ FT_Int64