ReactOS 0.4.15-dev-8428-g6910fa6
ftcalc.c File Reference
#include <ft2build.h>
Include dependency graph for ftcalc.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FT_Int64_
 

Macros

#define FT_COMPONENT   trace_calc
 
#define FT_MOVE_SIGN(x, x_unsigned, s)
 

Typedefs

typedef struct FT_Int64_ FT_Int64
 

Functions

 FT_RoundFix (FT_Fixed a)
 
 FT_CeilFix (FT_Fixed a)
 
 FT_FloorFix (FT_Fixed a)
 
 FT_MSB (FT_UInt32 z)
 
 FT_Hypot (FT_Fixed x, FT_Fixed y)
 
static void ft_multo64 (FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
 
static FT_UInt32 ft_div64by32 (FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 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_MulDiv_No_Round (FT_Long a_, FT_Long b_, FT_Long c_)
 
 FT_MulFix (FT_Long a_, FT_Long b_)
 
 FT_DivFix (FT_Long a_, FT_Long b_)
 
 FT_Matrix_Multiply (const FT_Matrix *a, FT_Matrix *b)
 
 FT_Matrix_Invert (FT_Matrix *matrix)
 
 FT_Matrix_Multiply_Scaled (const FT_Matrix *a, FT_Matrix *b, FT_Long scaling)
 
 FT_Vector_Transform_Scaled (FT_Vector *vector, const FT_Matrix *matrix, FT_Long scaling)
 
 FT_Vector_NormLen (FT_Vector *vector)
 
 ft_corner_orientation (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 
 ft_corner_is_flat (FT_Pos in_x, FT_Pos in_y, FT_Pos out_x, FT_Pos out_y)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_calc

Definition at line 68 of file ftcalc.c.

◆ FT_MOVE_SIGN

#define FT_MOVE_SIGN (   x,
  x_unsigned,
  s 
)
Value:
FT_BEGIN_STMNT \
if ( x < 0 ) \
{ \
x_unsigned = 0U - (x_unsigned); \
s = -s; \
} \
#define U(x)
Definition: wordpad.c:45
#define FT_END_STMNT
Definition: ftconfig.h:353
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble s
Definition: gl.h:2039

Definition at line 73 of file ftcalc.c.

Typedef Documentation

◆ FT_Int64

Function Documentation

◆ FT_Add64()

static void FT_Add64 ( FT_Int64 x,
FT_Int64 y,
FT_Int64 z 
)
static

Definition at line 351 of file ftcalc.c.

354 {
355 FT_UInt32 lo, hi;
356
357
358 lo = x->lo + y->lo;
359 hi = x->hi + y->hi + ( lo < x->lo );
360
361 z->lo = lo;
362 z->hi = hi;
363 }
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by FT_DivFix(), and FT_MulDiv().

◆ FT_CeilFix()

FT_CeilFix ( FT_Fixed  a)

Definition at line 97 of file ftcalc.c.

98 {
99 return ( ADD_LONG( a, 0xFFFFL ) ) & ~0xFFFFL;
100 }
#define ADD_LONG(a, b)
Definition: ftcalc.h:420
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ ft_corner_is_flat()

ft_corner_is_flat ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 975 of file ftcalc.c.

979 {
980 FT_Pos ax = in_x + out_x;
981 FT_Pos ay = in_y + out_y;
982
983 FT_Pos d_in, d_out, d_hypot;
984
985
986 /* The idea of this function is to compare the length of the */
987 /* hypotenuse with the `in' and `out' length. The `corner' */
988 /* represented by `in' and `out' is flat if the hypotenuse's */
989 /* length isn't too large. */
990 /* */
991 /* This approach has the advantage that the angle between */
992 /* `in' and `out' is not checked. In case one of the two */
993 /* vectors is `dominant', this is, much larger than the */
994 /* other vector, we thus always have a flat corner. */
995 /* */
996 /* hypotenuse */
997 /* x---------------------------x */
998 /* \ / */
999 /* \ / */
1000 /* in \ / out */
1001 /* \ / */
1002 /* o */
1003 /* Point */
1004
1005 d_in = FT_HYPOT( in_x, in_y );
1006 d_out = FT_HYPOT( out_x, out_y );
1007 d_hypot = FT_HYPOT( ax, ay );
1008
1009 /* now do a simple length comparison: */
1010 /* */
1011 /* d_in + d_out < 17/16 d_hypot */
1012
1013 return ( d_in + d_out - d_hypot ) < ( d_hypot >> 4 );
1014 }
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:58
#define FT_HYPOT(x, y)
Definition: ftobjs.h:81
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw ax
Definition: synth_sse3d.h:180

Referenced by af_glyph_hints_reload().

◆ ft_corner_orientation()

ft_corner_orientation ( FT_Pos  in_x,
FT_Pos  in_y,
FT_Pos  out_x,
FT_Pos  out_y 
)

Definition at line 911 of file ftcalc.c.

915 {
916#ifdef FT_LONG64
917
918 FT_Int64 delta = (FT_Int64)in_x * out_y - (FT_Int64)in_y * out_x;
919
920
921 return ( delta > 0 ) - ( delta < 0 );
922
923#else
924
926
927
928 /* we silently ignore overflow errors, since such large values */
929 /* lead to even more (harmless) rendering errors later on */
930 if ( ADD_LONG( FT_ABS( in_x ), FT_ABS( out_y ) ) <= 131071L &&
931 ADD_LONG( FT_ABS( in_y ), FT_ABS( out_x ) ) <= 131071L )
932 {
933 FT_Long z1 = MUL_LONG( in_x, out_y );
934 FT_Long z2 = MUL_LONG( in_y, out_x );
935
936
937 if ( z1 > z2 )
938 result = +1;
939 else if ( z1 < z2 )
940 result = -1;
941 else
942 result = 0;
943 }
944 else /* products might overflow 32 bits */
945 {
946 FT_Int64 z1, z2;
947
948
949 /* XXX: this function does not allow 64-bit arguments */
950 ft_multo64( (FT_UInt32)in_x, (FT_UInt32)out_y, &z1 );
951 ft_multo64( (FT_UInt32)in_y, (FT_UInt32)out_x, &z2 );
952
953 if ( z1.hi > z2.hi )
954 result = +1;
955 else if ( z1.hi < z2.hi )
956 result = -1;
957 else if ( z1.lo > z2.lo )
958 result = +1;
959 else if ( z1.lo < z2.lo )
960 result = -1;
961 else
962 result = 0;
963 }
964
965 /* XXX: only the sign of return value, +1/0/-1 must be used */
966 return result;
967
968#endif
969 }
static void ft_multo64(FT_UInt32 x, FT_UInt32 y, FT_Int64 *z)
Definition: ftcalc.c:280
struct FT_Int64_ FT_Int64
#define MUL_LONG(a, b)
Definition: ftcalc.h:424
#define FT_ABS(a)
Definition: ftobjs.h:74
signed long FT_Long
Definition: fttypes.h:242
signed int FT_Int
Definition: fttypes.h:220
GLuint64EXT * result
Definition: glext.h:11304
FT_UInt32 lo
Definition: ftcalc.c:53
FT_UInt32 hi
Definition: ftcalc.c:54

◆ ft_div64by32()

static FT_UInt32 ft_div64by32 ( FT_UInt32  hi,
FT_UInt32  lo,
FT_UInt32  y 
)
static

Definition at line 312 of file ftcalc.c.

315 {
316 FT_UInt32 r, q;
317 FT_Int i;
318
319
320 if ( hi >= y )
321 return (FT_UInt32)0x7FFFFFFFL;
322
323 /* We shift as many bits as we can into the high register, perform */
324 /* 32-bit division with modulo there, then work through the remaining */
325 /* bits with long division. This optimization is especially noticeable */
326 /* for smaller dividends that barely use the high register. */
327
328 i = 31 - FT_MSB( hi );
329 r = ( hi << i ) | ( lo >> ( 32 - i ) ); lo <<= i; /* left 64-bit shift */
330 q = r / y;
331 r -= q * y; /* remainder */
332
333 i = 32 - i; /* bits remaining in low register */
334 do
335 {
336 q <<= 1;
337 r = ( r << 1 ) | ( lo >> 31 ); lo <<= 1;
338
339 if ( r >= y )
340 {
341 r -= y;
342 q |= 1;
343 }
344 } while ( --i );
345
346 return q;
347 }
FT_MSB(FT_UInt32 z)
Definition: ftcalc.c:114
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by FT_DivFix(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_DivFix()

FT_DivFix ( FT_Long  a_,
FT_Long  b_ 
)

Definition at line 608 of file ftcalc.c.

610 {
611 FT_Int s = 1;
612 FT_UInt32 a, b, q;
613 FT_Long q_;
614
615
616 /* XXX: this function does not allow 64-bit arguments */
617
618 a = (FT_UInt32)a_;
619 b = (FT_UInt32)b_;
620
621 FT_MOVE_SIGN( a_, a, s );
622 FT_MOVE_SIGN( b_, b, s );
623
624 if ( b == 0 )
625 {
626 /* check for division by 0 */
627 q = 0x7FFFFFFFUL;
628 }
629 else if ( a <= 65535UL - ( b >> 17 ) )
630 {
631 /* compute result directly */
632 q = ( ( a << 16 ) + ( b >> 1 ) ) / b;
633 }
634 else
635 {
636 /* we need more bits; we have to do it by hand */
637 FT_Int64 temp, temp2;
638
639
640 temp.hi = a >> 16;
641 temp.lo = a << 16;
642 temp2.hi = 0;
643 temp2.lo = b >> 1;
644
645 FT_Add64( &temp, &temp2, &temp );
646 q = ft_div64by32( temp.hi, temp.lo, b );
647 }
648
649 q_ = (FT_Long)q;
650
651 return s < 0 ? NEG_LONG( q_ ) : q_;
652 }
static void FT_Add64(FT_Int64 *x, FT_Int64 *y, FT_Int64 *z)
Definition: ftcalc.c:351
#define FT_MOVE_SIGN(x, x_unsigned, s)
Definition: ftcalc.c:73
static FT_UInt32 ft_div64by32(FT_UInt32 hi, FT_UInt32 lo, FT_UInt32 y)
Definition: ftcalc.c:312
#define NEG_LONG(a)
Definition: ftcalc.h:426
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define a
Definition: ke_i.h:78
#define b
Definition: ke_i.h:79
static calc_node_t temp
Definition: rpn_ieee.c:38

Referenced by af_glyph_hints_align_strong_points(), af_iup_interp(), af_latin_hints_compute_edges(), af_loader_compute_darkening(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), cf2_blues_init(), cf2_checkTransform(), cf2_computeDarkening(), cf2_font_setup(), cf2_getBlueMetrics(), cf2_glyphpath_computeIntersection(), cf2_hintmap_adjustHints(), cf2_interpT2CharString(), cff_blend_build_vector(), cff_face_init(), cff_parse_fixed_dynamic(), cff_parse_real(), cid_parse_font_matrix(), compute_glyph_metrics(), FT_Matrix_Invert(), FT_Request_Metrics(), FT_Select_Metrics(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), ft_stroker_inside(), ft_stroker_outside(), FT_Tan(), mm_axis_unmap(), pfr_get_metrics(), PS_Conv_ToFixed(), psh_globals_new(), psh_glyph_find_strong_points(), psh_glyph_interpolate_other_points(), t1_parse_font_matrix(), t42_parse_font_matrix(), and tt_size_reset().

◆ FT_FloorFix()

FT_FloorFix ( FT_Fixed  a)

Definition at line 106 of file ftcalc.c.

107 {
108 return a & ~0xFFFFL;
109 }

◆ FT_Hypot()

FT_Hypot ( FT_Fixed  x,
FT_Fixed  y 
)

Definition at line 155 of file ftcalc.c.

157 {
158 FT_Vector v;
159
160
161 v.x = x;
162 v.y = y;
163
164 return FT_Vector_Length( &v );
165 }
FT_Vector_Length(FT_Vector *vec)
Definition: fttrigon.c:426
const GLdouble * v
Definition: gl.h:2040

Referenced by TT_Process_Composite_Component().

◆ FT_Matrix_Invert()

FT_Matrix_Invert ( FT_Matrix matrix)

Definition at line 689 of file ftcalc.c.

690 {
691 FT_Pos delta, xx, yy;
692
693
694 if ( !matrix )
695 return FT_THROW( Invalid_Argument );
696
697 /* compute discriminant */
698 delta = FT_MulFix( matrix->xx, matrix->yy ) -
699 FT_MulFix( matrix->xy, matrix->yx );
700
701 if ( !delta )
702 return FT_THROW( Invalid_Argument ); /* matrix can't be inverted */
703
704 matrix->xy = - FT_DivFix( matrix->xy, delta );
705 matrix->yx = - FT_DivFix( matrix->yx, delta );
706
707 xx = matrix->xx;
708 yy = matrix->yy;
709
710 matrix->xx = FT_DivFix( yy, delta );
711 matrix->yy = FT_DivFix( xx, delta );
712
713 return FT_Err_Ok;
714 }
return FT_Err_Ok
Definition: ftbbox.c:511
FT_MulFix(FT_Long a_, FT_Long b_)
Definition: ftcalc.c:509
FT_DivFix(FT_Long a_, FT_Long b_)
Definition: ftcalc.c:608
#define FT_THROW(e)
Definition: ftdebug.h:213
GLuint GLenum matrix
Definition: glext.h:9407
int xx
Definition: npserver.c:29

Referenced by af_loader_load_glyph().

◆ FT_Matrix_Multiply()

FT_Matrix_Multiply ( const FT_Matrix a,
FT_Matrix b 
)

Definition at line 661 of file ftcalc.c.

663 {
664 FT_Fixed xx, xy, yx, yy;
665
666
667 if ( !a || !b )
668 return;
669
670 xx = ADD_LONG( FT_MulFix( a->xx, b->xx ),
671 FT_MulFix( a->xy, b->yx ) );
672 xy = ADD_LONG( FT_MulFix( a->xx, b->xy ),
673 FT_MulFix( a->xy, b->yy ) );
674 yx = ADD_LONG( FT_MulFix( a->yx, b->xx ),
675 FT_MulFix( a->yy, b->yx ) );
676 yy = ADD_LONG( FT_MulFix( a->yx, b->xy ),
677 FT_MulFix( a->yy, b->yy ) );
678
679 b->xx = xx;
680 b->xy = xy;
681 b->yx = yx;
682 b->yy = yy;
683 }
signed long FT_Fixed
Definition: fttypes.h:288

Referenced by ftGdiGetGlyphOutline(), and IntExtTextOutW().

◆ FT_Matrix_Multiply_Scaled()

FT_Matrix_Multiply_Scaled ( const FT_Matrix a,
FT_Matrix b,
FT_Long  scaling 
)

Definition at line 720 of file ftcalc.c.

723 {
724 FT_Fixed xx, xy, yx, yy;
725
726 FT_Long val = 0x10000L * scaling;
727
728
729 if ( !a || !b )
730 return;
731
732 xx = ADD_LONG( FT_MulDiv( a->xx, b->xx, val ),
733 FT_MulDiv( a->xy, b->yx, val ) );
734 xy = ADD_LONG( FT_MulDiv( a->xx, b->xy, val ),
735 FT_MulDiv( a->xy, b->yy, val ) );
736 yx = ADD_LONG( FT_MulDiv( a->yx, b->xx, val ),
737 FT_MulDiv( a->yy, b->yx, val ) );
738 yy = ADD_LONG( FT_MulDiv( a->yx, b->xy, val ),
739 FT_MulDiv( a->yy, b->yy, val ) );
740
741 b->xx = xx;
742 b->xy = xy;
743 b->yx = yx;
744 b->yy = yy;
745 }
FT_MulDiv(FT_Long a_, FT_Long b_, FT_Long c_)
Definition: ftcalc.c:416
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by cff_face_init().

◆ FT_MSB()

FT_MSB ( FT_UInt32  z)

Definition at line 114 of file ftcalc.c.

115 {
116 FT_Int shift = 0;
117
118
119 /* determine msb bit index in `shift' */
120 if ( z & 0xFFFF0000UL )
121 {
122 z >>= 16;
123 shift += 16;
124 }
125 if ( z & 0x0000FF00UL )
126 {
127 z >>= 8;
128 shift += 8;
129 }
130 if ( z & 0x000000F0UL )
131 {
132 z >>= 4;
133 shift += 4;
134 }
135 if ( z & 0x0000000CUL )
136 {
137 z >>= 2;
138 shift += 2;
139 }
140 if ( z & 0x00000002UL )
141 {
142 /* z >>= 1; */
143 shift += 1;
144 }
145
146 return shift;
147 }
#define shift
Definition: input.c:1755

Referenced by af_loader_compute_darkening(), cf2_computeDarkening(), cubic_peak(), ft_div64by32(), FT_Outline_Get_Orientation(), ft_trig_prenorm(), FT_Vector_NormLen(), and pfr_face_get_kerning().

◆ FT_MulDiv()

FT_MulDiv ( FT_Long  a_,
FT_Long  b_,
FT_Long  c_ 
)

Definition at line 416 of file ftcalc.c.

419 {
420 FT_Int s = 1;
421 FT_UInt32 a, b, c;
422
423
424 /* XXX: this function does not allow 64-bit arguments */
425
426 a = (FT_UInt32)a_;
427 b = (FT_UInt32)b_;
428 c = (FT_UInt32)c_;
429
430 FT_MOVE_SIGN( a_, a, s );
431 FT_MOVE_SIGN( b_, b, s );
432 FT_MOVE_SIGN( c_, c, s );
433
434 if ( c == 0 )
435 a = 0x7FFFFFFFUL;
436
437 else if ( a + b <= 129894UL - ( c >> 17 ) )
438 a = ( a * b + ( c >> 1 ) ) / c;
439
440 else
441 {
442 FT_Int64 temp, temp2;
443
444
445 ft_multo64( a, b, &temp );
446
447 temp2.hi = 0;
448 temp2.lo = c >> 1;
449
450 FT_Add64( &temp, &temp2, &temp );
451
452 /* last attempt to ditch long division */
453 a = ( temp.hi == 0 ) ? temp.lo / c
454 : ft_div64by32( temp.hi, temp.lo, c );
455 }
456
457 a_ = (FT_Long)a;
458
459 return s < 0 ? NEG_LONG( a_ ) : a_;
460 }
const GLubyte * c
Definition: glext.h:8905
#define c
Definition: ke_i.h:80

Referenced by _bdf_parse_glyphs(), _ft_face_scale_advances(), af_latin_hint_edges(), af_latin_metrics_scale_dim(), af_loader_compute_darkening(), BBox_Conic_Check(), BDF_Face_Init(), cf2_blues_init(), cf2_computeDarkening(), cff_face_init(), cff_size_request(), cff_slot_load(), FNT_Face_Init(), FT_Get_Kerning(), FT_Load_Glyph(), FT_Matrix_Multiply_Scaled(), FT_Outline_EmboldenXY(), FT_Request_Metrics(), ft_stroke_border_arcto(), FT_Stroker_ConicTo(), FT_Stroker_CubicTo(), ft_stroker_outside(), FT_Vector_Transform_Scaled(), IntRequestFontSize(), pcf_load_font(), pfr_get_kerning(), pfr_slot_load(), ps_hints_apply(), psh_glyph_interpolate_normal_points(), psh_glyph_interpolate_strong_points(), T1_Get_Track_Kerning(), T1_Set_MM_Design(), TT_Process_Simple_Glyph(), and tt_size_request().

◆ FT_MulDiv_No_Round()

FT_MulDiv_No_Round ( FT_Long  a_,
FT_Long  b_,
FT_Long  c_ 
)

Definition at line 464 of file ftcalc.c.

467 {
468 FT_Int s = 1;
469 FT_UInt32 a, b, c;
470
471
472 /* XXX: this function does not allow 64-bit arguments */
473
474 a = (FT_UInt32)a_;
475 b = (FT_UInt32)b_;
476 c = (FT_UInt32)c_;
477
478 FT_MOVE_SIGN( a_, a, s );
479 FT_MOVE_SIGN( b_, b, s );
480 FT_MOVE_SIGN( c_, c, s );
481
482 if ( c == 0 )
483 a = 0x7FFFFFFFUL;
484
485 else if ( a + b <= 131071UL )
486 a = a * b / c;
487
488 else
489 {
491
492
493 ft_multo64( a, b, &temp );
494
495 /* last attempt to ditch long division */
496 a = ( temp.hi == 0 ) ? temp.lo / c
497 : ft_div64by32( temp.hi, temp.lo, c );
498 }
499
500 a_ = (FT_Long)a;
501
502 return s < 0 ? NEG_LONG( a_ ) : a_;
503 }

◆ FT_MulFix()

FT_MulFix ( FT_Long  a_,
FT_Long  b_ 
)

Definition at line 509 of file ftcalc.c.

511 {
512#ifdef FT_MULFIX_ASSEMBLER
513
514 return FT_MULFIX_ASSEMBLER( a_, b_ );
515
516#elif 0
517
518 /*
519 * This code is nonportable. See comment below.
520 *
521 * However, on a platform where right-shift of a signed quantity fills
522 * the leftmost bits by copying the sign bit, it might be faster.
523 */
524
525 FT_Long sa, sb;
526 FT_UInt32 a, b;
527
528
529 /*
530 * This is a clever way of converting a signed number `a' into its
531 * absolute value (stored back into `a') and its sign. The sign is
532 * stored in `sa'; 0 means `a' was positive or zero, and -1 means `a'
533 * was negative. (Similarly for `b' and `sb').
534 *
535 * Unfortunately, it doesn't work (at least not portably).
536 *
537 * It makes the assumption that right-shift on a negative signed value
538 * fills the leftmost bits by copying the sign bit. This is wrong.
539 * According to K&R 2nd ed, section `A7.8 Shift Operators' on page 206,
540 * the result of right-shift of a negative signed value is
541 * implementation-defined. At least one implementation fills the
542 * leftmost bits with 0s (i.e., it is exactly the same as an unsigned
543 * right shift). This means that when `a' is negative, `sa' ends up
544 * with the value 1 rather than -1. After that, everything else goes
545 * wrong.
546 */
547 sa = ( a_ >> ( sizeof ( a_ ) * 8 - 1 ) );
548 a = ( a_ ^ sa ) - sa;
549 sb = ( b_ >> ( sizeof ( b_ ) * 8 - 1 ) );
550 b = ( b_ ^ sb ) - sb;
551
552 a = (FT_UInt32)a_;
553 b = (FT_UInt32)b_;
554
555 if ( a + ( b >> 8 ) <= 8190UL )
556 a = ( a * b + 0x8000U ) >> 16;
557 else
558 {
559 FT_UInt32 al = a & 0xFFFFUL;
560
561
562 a = ( a >> 16 ) * b + al * ( b >> 16 ) +
563 ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
564 }
565
566 sa ^= sb;
567 a = ( a ^ sa ) - sa;
568
569 return (FT_Long)a;
570
571#else /* 0 */
572
573 FT_Int s = 1;
574 FT_UInt32 a, b;
575
576
577 /* XXX: this function does not allow 64-bit arguments */
578
579 a = (FT_UInt32)a_;
580 b = (FT_UInt32)b_;
581
582 FT_MOVE_SIGN( a_, a, s );
583 FT_MOVE_SIGN( b_, b, s );
584
585 if ( a + ( b >> 8 ) <= 8190UL )
586 a = ( a * b + 0x8000UL ) >> 16;
587 else
588 {
589 FT_UInt32 al = a & 0xFFFFUL;
590
591
592 a = ( a >> 16 ) * b + al * ( b >> 16 ) +
593 ( ( al * ( b & 0xFFFFUL ) + 0x8000UL ) >> 16 );
594 }
595
596 a_ = (FT_Long)a;
597
598 return s < 0 ? NEG_LONG( a_ ) : a_;
599
600#endif /* 0 */
601
602 }
static struct sockaddr_in sa
Definition: adnsresfilter.c:69
superblock * sb
Definition: btrfs.c:4261

Referenced by af_glyph_hints_align_strong_points(), af_glyph_hints_reload(), af_iup_interp(), af_latin_hints_compute_blue_edges(), af_latin_hints_compute_edges(), af_latin_metrics_scale_dim(), af_loader_compute_darkening(), af_loader_embolden_glyph_in_slot(), af_loader_load_glyph(), cf2_blues_init(), cf2_computeDarkening(), cf2_doBlend(), cf2_glyphpath_computeIntersection(), cf2_glyphpath_computeOffset(), cf2_glyphpath_hintPoint(), cf2_hint_init(), cf2_hintmap_insertHint(), cf2_hintmap_map(), cf2_interpT2CharString(), cff_blend_build_vector(), cff_slot_load(), cid_slot_load_glyph(), compute_glyph_metrics(), FillTM(), FT_Get_Kerning(), FT_GlyphSlot_Embolden(), FT_Matrix_Invert(), FT_Matrix_Multiply(), FT_Outline_EmboldenXY(), ft_recompute_scaled_metrics(), FT_Request_Metrics(), ft_stroker_inside(), ft_stroker_outside(), FT_Vector_Transform(), load_truetype_glyph(), pfr_glyph_load_rec(), pfr_slot_load(), ps_hints_apply(), psh_blues_scale_zones(), psh_globals_scale_widths(), psh_glyph_interpolate_normal_points(), psh_glyph_interpolate_other_points(), psh_glyph_interpolate_strong_points(), psh_hint_align(), T1_Load_Glyph(), t1_set_mm_blend(), TT_Load_Glyph(), tt_loader_init(), TT_Process_Composite_Component(), TT_Process_Simple_Glyph(), and tt_size_reset().

◆ ft_multo64()

static void ft_multo64 ( FT_UInt32  x,
FT_UInt32  y,
FT_Int64 z 
)
static

Definition at line 280 of file ftcalc.c.

283 {
284 FT_UInt32 lo1, hi1, lo2, hi2, lo, hi, i1, i2;
285
286
287 lo1 = x & 0x0000FFFFU; hi1 = x >> 16;
288 lo2 = y & 0x0000FFFFU; hi2 = y >> 16;
289
290 lo = lo1 * lo2;
291 i1 = lo1 * hi2;
292 i2 = lo2 * hi1;
293 hi = hi1 * hi2;
294
295 /* Check carry overflow of i1 + i2 */
296 i1 += i2;
297 hi += (FT_UInt32)( i1 < i2 ) << 16;
298
299 hi += i1 >> 16;
300 i1 = i1 << 16;
301
302 /* Check carry overflow of i1 + lo */
303 lo += i1;
304 hi += ( lo < i1 );
305
306 z->lo = lo;
307 z->hi = hi;
308 }

Referenced by ft_corner_orientation(), FT_MulDiv(), and FT_MulDiv_No_Round().

◆ FT_RoundFix()

FT_RoundFix ( FT_Fixed  a)

Definition at line 88 of file ftcalc.c.

89 {
90 return ( ADD_LONG( a, 0x8000L - ( a < 0 ) ) ) & ~0xFFFFL;
91 }

Referenced by cff_parse_font_bbox(), and ps_parser_load_field().

◆ FT_Vector_NormLen()

FT_Vector_NormLen ( FT_Vector vector)

Definition at line 776 of file ftcalc.c.

777 {
778 FT_Int32 x_ = vector->x;
779 FT_Int32 y_ = vector->y;
780 FT_Int32 b, z;
781 FT_UInt32 x, y, u, v, l;
782 FT_Int sx = 1, sy = 1, shift;
783
784
785 x = (FT_UInt32)x_;
786 y = (FT_UInt32)y_;
787
788 FT_MOVE_SIGN( x_, x, sx );
789 FT_MOVE_SIGN( y_, y, sy );
790
791 /* trivial cases */
792 if ( x == 0 )
793 {
794 if ( y > 0 )
795 vector->y = sy * 0x10000;
796 return y;
797 }
798 else if ( y == 0 )
799 {
800 if ( x > 0 )
801 vector->x = sx * 0x10000;
802 return x;
803 }
804
805 /* Estimate length and prenormalize by shifting so that */
806 /* the new approximate length is between 2/3 and 4/3. */
807 /* The magic constant 0xAAAAAAAAUL (2/3 of 2^32) helps */
808 /* achieve this in 16.16 fixed-point representation. */
809 l = x > y ? x + ( y >> 1 )
810 : y + ( x >> 1 );
811
812 shift = 31 - FT_MSB( l );
813 shift -= 15 + ( l >= ( 0xAAAAAAAAUL >> shift ) );
814
815 if ( shift > 0 )
816 {
817 x <<= shift;
818 y <<= shift;
819
820 /* re-estimate length for tiny vectors */
821 l = x > y ? x + ( y >> 1 )
822 : y + ( x >> 1 );
823 }
824 else
825 {
826 x >>= -shift;
827 y >>= -shift;
828 l >>= -shift;
829 }
830
831 /* lower linear approximation for reciprocal length minus one */
832 b = 0x10000 - (FT_Int32)l;
833
834 x_ = (FT_Int32)x;
835 y_ = (FT_Int32)y;
836
837 /* Newton's iterations */
838 do
839 {
840 u = (FT_UInt32)( x_ + ( x_ * b >> 16 ) );
841 v = (FT_UInt32)( y_ + ( y_ * b >> 16 ) );
842
843 /* Normalized squared length in the parentheses approaches 2^32. */
844 /* On two's complement systems, converting to signed gives the */
845 /* difference with 2^32 even if the expression wraps around. */
846 z = -(FT_Int32)( u * u + v * v ) / 0x200;
847 z = z * ( ( 0x10000 + b ) >> 8 ) / 0x10000;
848
849 b += z;
850
851 } while ( z > 0 );
852
853 vector->x = sx < 0 ? -(FT_Pos)u : (FT_Pos)u;
854 vector->y = sy < 0 ? -(FT_Pos)v : (FT_Pos)v;
855
856 /* Conversion to signed helps to recover from likely wrap around */
857 /* in calculating the prenormalized length, because it gives the */
858 /* correct difference with 2^32 on two's complement systems. */
859 l = (FT_UInt32)( 0x10000 + (FT_Int32)( u * x + v * y ) / 0x10000 );
860 if ( shift > 0 )
861 l = ( l + ( 1 << ( shift - 1 ) ) ) >> shift;
862 else
863 l <<= -shift;
864
865 return l;
866 }
r l[0]
Definition: byte_order.h:168
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240

Referenced by FT_Outline_EmboldenXY().

◆ FT_Vector_Transform_Scaled()

FT_Vector_Transform_Scaled ( FT_Vector vector,
const FT_Matrix matrix,
FT_Long  scaling 
)

Definition at line 751 of file ftcalc.c.

754 {
755 FT_Pos xz, yz;
756
757 FT_Long val = 0x10000L * scaling;
758
759
760 if ( !vector || !matrix )
761 return;
762
763 xz = ADD_LONG( FT_MulDiv( vector->x, matrix->xx, val ),
764 FT_MulDiv( vector->y, matrix->xy, val ) );
765 yz = ADD_LONG( FT_MulDiv( vector->x, matrix->yx, val ),
766 FT_MulDiv( vector->y, matrix->yy, val ) );
767
768 vector->x = xz;
769 vector->y = yz;
770 }

Referenced by cff_face_init().