:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / include / freetype / internal / ftcalc.h
1 /***************************************************************************/
2 /*                                                                         */
3 /*  ftcalc.h                                                               */
4 /*                                                                         */
5 /*    Arithmetic computations (specification).                             */
6 /*                                                                         */
7 /*  Copyright 1996-2000 by                                                 */
8 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
9 /*                                                                         */
10 /*  This file is part of the FreeType project, and may only be used,       */
11 /*  modified, and distributed under the terms of the FreeType project      */
12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
13 /*  this file you indicate that you have read the license and              */
14 /*  understand and accept it fully.                                        */
15 /*                                                                         */
16 /***************************************************************************/
17
18
19 #ifndef FTCALC_H
20 #define FTCALC_H
21
22 #include <freetype/freetype.h>
23 #include <freetype/config/ftconfig.h>   /* for LONG64 */
24
25 #ifdef __cplusplus
26   extern "C" {
27 #endif
28
29
30 #ifdef LONG64
31
32
33   typedef INT64  FT_Int64;
34
35 #define ADD_64( x, y, z )  z = (x) + (y)
36 #define MUL_64( x, y, z )  z = (FT_Int64)(x) * (y)
37
38 #define DIV_64( x, y )     ( (x) / (y) )
39
40
41 #ifdef FT_CONFIG_OPTION_OLD_CALCS
42
43 #define SQRT_64( z )  FT_Sqrt64( z )
44
45   FT_EXPORT_DEF( FT_Int32 )  FT_Sqrt64( FT_Int64  l );
46
47 #endif /* FT_CONFIG_OPTION_OLD_CALCS */
48
49
50 #else /* LONG64 */
51
52
53   typedef struct  FT_Int64_
54   {
55     FT_UInt32  lo;
56     FT_UInt32  hi;
57
58   } FT_Int64;
59
60
61 #define ADD_64( x, y, z )  FT_Add64( &x, &y, &z )
62 #define MUL_64( x, y, z )  FT_MulTo64( x, y, &z )
63 #define DIV_64( x, y )     FT_Div64by32( &x, y )
64
65
66   FT_EXPORT_DEF( void )  FT_Add64( FT_Int64*  x,
67                                    FT_Int64*  y,
68                                    FT_Int64*  z );
69
70   FT_EXPORT_DEF( void )  FT_MulTo64( FT_Int32   x,
71                                      FT_Int32   y,
72                                      FT_Int64*  z );
73
74   FT_EXPORT_DEF( FT_Int32 )  FT_Div64by32( FT_Int64*  x,
75                                            FT_Int32   y );
76
77
78 #ifdef FT_CONFIG_OPTION_OLD_CALCS
79
80 #define SQRT_64( z )  FT_Sqrt64( &z )
81
82   FT_EXPORT_DEF( FT_Int32 )  FT_Sqrt64( FT_Int64*  x );
83
84 #endif /* FT_CONFIG_OPTION_OLD_CALCS */
85
86
87 #endif /* LONG64 */
88
89
90 #ifndef FT_CONFIG_OPTION_OLD_CALCS
91
92 #define SQRT_32( x )  FT_Sqrt32( x )
93
94   BASE_DEF( FT_Int32 )  FT_Sqrt32( FT_Int32  x );
95
96 #endif /* !FT_CONFIG_OPTION_OLD_CALCS */
97
98
99   /*************************************************************************/
100   /*                                                                       */
101   /* FT_MulDiv() and FT_MulFix() are declared in freetype.h.               */
102   /*                                                                       */
103   /*************************************************************************/
104
105
106 #define INT_TO_F26DOT6( x )    ( (FT_Long)(x) << 6  )
107 #define INT_TO_F2DOT14( x )    ( (FT_Long)(x) << 14 )
108 #define INT_TO_FIXED( x )      ( (FT_Long)(x) << 16 )
109 #define F2DOT14_TO_FIXED( x )  ( (FT_Long)(x) << 2  )
110 #define FLOAT_TO_FIXED( x )    ( (FT_Long)( x * 65536.0 ) )
111
112 #define ROUND_F26DOT6( x )     ( x >= 0 ? (    ( (x) + 32 ) & -64 )     \
113                                         : ( -( ( 32 - (x) ) & -64 ) ) )
114
115
116 #ifdef __cplusplus
117   }
118 #endif
119
120 #endif /* FTCALC_H */
121
122
123 /* END */