ReactOS 0.4.15-dev-8145-ga541a46
test_bbox.c
Go to the documentation of this file.
1#include <ft2build.h>
2#include FT_FREETYPE_H
3#include FT_BBOX_H
4
5
6#include <time.h> /* for clock() */
7
8/* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */
9/* to get the HZ macro which is the equivalent. */
10#if defined(__sun__) && !defined(SVR4) && !defined(__SVR4)
11#include <sys/param.h>
12#define CLOCKS_PER_SEC HZ
13#endif
14
15 static long
16 get_time( void )
17 {
18 return clock() * 10000L / CLOCKS_PER_SEC;
19 }
20
21
22
23
24 /* test bbox computations */
25
26#define XSCALE 65536
27#define XX(x) ((FT_Pos)(x*XSCALE))
28#define XVEC(x,y) { XX(x), XX(y) }
29#define XVAL(x) ((x)/(1.0*XSCALE))
30
31 /* dummy outline #1 */
33 {
34#if 1
35 XVEC( 408.9111, 535.3164 ),
36 XVEC( 455.8887, 634.396 ),
37 XVEC( -37.8765, 786.2207 ),
38 XVEC( 164.6074, 535.3164 )
39#else
40 { (FT_Int32)0x0198E93DL , (FT_Int32)0x021750FFL }, /* 408.9111, 535.3164 */
41 { (FT_Int32)0x01C7E312L , (FT_Int32)0x027A6560L }, /* 455.8887, 634.3960 */
42 { (FT_Int32)0xFFDA1F9EL , (FT_Int32)0x0312387FL }, /* -37.8765, 786.2207 */
43 { (FT_Int32)0x00A49B7EL , (FT_Int32)0x021750FFL } /* 164.6074, 535.3164 */
44#endif
45 };
46
47 static char dummy_tag_1[4] =
48 {
53 };
54
55 static short dummy_contour_1[1] =
56 {
57 3
58 };
59
61 {
62 1,
63 4,
67 0
68 };
69
70
71 /* dummy outline #2 */
73 {
74 XVEC( 100.0, 100.0 ),
75 XVEC( 100.0, 200.0 ),
76 XVEC( 200.0, 200.0 ),
77 XVEC( 200.0, 133.0 )
78 };
79
81 {
82 1,
83 4,
87 0
88 };
89
90
91 /* dummy outline #3 with bbox of [0 100 128 128] precisely */
93 {
94 XVEC( 100.0, 127.0 ),
95 XVEC( 200.0, 127.0 ),
96 XVEC( 0.0, 136.0 ),
97 XVEC( 0.0, 100.0 )
98 };
99
101 {
102 1,
103 4,
107 0
108 };
109
110
111 static void
113 {
115
116 /* compute and display cbox */
118 printf( "cbox = [%.2f %.2f %.2f %.2f]\n",
119 XVAL( bbox.xMin ),
120 XVAL( bbox.yMin ),
121 XVAL( bbox.xMax ),
122 XVAL( bbox.yMax ) );
123
124 /* compute and display bbox */
126 printf( "bbox = [%.2f %.2f %.2f %.2f]\n",
127 XVAL( bbox.xMin ),
128 XVAL( bbox.yMin ),
129 XVAL( bbox.xMax ),
130 XVAL( bbox.yMax ) );
131 }
132
133
134
135 static void
137 long repeat )
138 {
140 long count;
141 long time0;
142
143 time0 = get_time();
144 for ( count = repeat; count > 0; count-- )
146
147 time0 = get_time() - time0;
148 printf( "time = %6.3f cbox = [%8.4f %8.4f %8.4f %8.4f]\n",
149 ((double)time0/10000.0),
150 XVAL( bbox.xMin ),
151 XVAL( bbox.yMin ),
152 XVAL( bbox.xMax ),
153 XVAL( bbox.yMax ) );
154 printf( "cbox_hex = [%08X %08X %08X %08X]\n",
156
157
158 time0 = get_time();
159 for ( count = repeat; count > 0; count-- )
161
162 time0 = get_time() - time0;
163 printf( "time = %6.3f bbox = [%8.4f %8.4f %8.4f %8.4f]\n",
164 ((double)time0/10000.0),
165 XVAL( bbox.xMin ),
166 XVAL( bbox.yMin ),
167 XVAL( bbox.xMax ),
168 XVAL( bbox.yMax ) );
169 printf( "bbox_hex = [%08X %08X %08X %08X]\n",
171 }
172
173#define REPEAT 1000000L
174
175 int main( int argc, char** argv )
176 {
177 printf( "outline #1\n" );
179
180 printf( "outline #2\n" );
182
183 printf( "outline #3\n" );
185
186 return 0;
187 }
188
static int argc
Definition: ServiceArgs.c:12
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:97
FT_BBox bbox
Definition: ftbbox.c:446
FT_BEGIN_HEADER FT_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox)
#define FT_CURVE_TAG_CUBIC
Definition: ftimage.h:455
#define FT_CURVE_TAG_ON
Definition: ftimage.h:453
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:478
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define argv
Definition: mplay32.c:18
#define CLOCKS_PER_SEC
Definition: time.h:81
_Check_return_ _CRTIMP clock_t __cdecl clock(void)
Definition: clock.c:23
FT_Pos xMin
Definition: ftimage.h:117
FT_Pos yMax
Definition: ftimage.h:118
FT_Pos yMin
Definition: ftimage.h:117
FT_Pos xMax
Definition: ftimage.h:118
Definition: mesh.c:5330
static FT_Vector dummy_vec_3[4]
Definition: test_bbox.c:92
#define REPEAT
Definition: test_bbox.c:173
static char dummy_tag_1[4]
Definition: test_bbox.c:47
static long get_time(void)
Definition: test_bbox.c:16
static FT_Vector dummy_vec_2[4]
Definition: test_bbox.c:72
static FT_Outline dummy_outline_2
Definition: test_bbox.c:80
static void profile_outline(FT_Outline *outline, long repeat)
Definition: test_bbox.c:136
static FT_Outline dummy_outline_3
Definition: test_bbox.c:100
static void dump_outline(FT_Outline *outline)
Definition: test_bbox.c:112
#define XVEC(x, y)
Definition: test_bbox.c:28
static FT_Vector dummy_vec_1[4]
Definition: test_bbox.c:32
#define XVAL(x)
Definition: test_bbox.c:29
static short dummy_contour_1[1]
Definition: test_bbox.c:55
static FT_Outline dummy_outline_1
Definition: test_bbox.c:60
static int repeat
Definition: xmllint.c:137