zenilib: zenilib/jni/external/freetype2/src/tools/test_bbox.c Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 */
32 static FT_Vector dummy_vec_1[4] =
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 {
49 FT_CURVE_TAG_ON,
50 FT_CURVE_TAG_CUBIC,
51 FT_CURVE_TAG_CUBIC,
52 FT_CURVE_TAG_ON
53 };
54
55 static short dummy_contour_1[1] =
56 {
57 3
58 };
59
60 static FT_Outline dummy_outline_1 =
61 {
62 1,
63 4,
64 dummy_vec_1,
65 dummy_tag_1,
66 dummy_contour_1,
67 0
68 };
69
70
71 /* dummy outline #2 */
72 static FT_Vector dummy_vec_2[4] =
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
80 static FT_Outline dummy_outline_2 =
81 {
82 1,
83 4,
84 dummy_vec_2,
85 dummy_tag_1,
86 dummy_contour_1,
87 0
88 };
89
90
91 static void
92 dump_outline( FT_Outline* outline )
93 {
94 FT_BBox bbox;
95
96 /* compute and display cbox */
97 FT_Outline_Get_CBox( outline, &bbox );
98 printf( "cbox = [%.2f %.2f %.2f %.2f]\n",
99 XVAL( bbox.xMin ),
100 XVAL( bbox.yMin ),
101 XVAL( bbox.xMax ),
102 XVAL( bbox.yMax ) );
103
104 /* compute and display bbox */
105 FT_Outline_Get_BBox( outline, &bbox );
106 printf( "bbox = [%.2f %.2f %.2f %.2f]\n",
107 XVAL( bbox.xMin ),
108 XVAL( bbox.yMin ),
109 XVAL( bbox.xMax ),
110 XVAL( bbox.yMax ) );
111 }
112
113
114
115 static void
116 profile_outline( FT_Outline* outline,
117 long repeat )
118 {
119 FT_BBox bbox;
120 long count;
121 long time0;
122
123 time0 = get_time();
124 for ( count = repeat; count > 0; count-- )
125 FT_Outline_Get_CBox( outline, &bbox );
126
127 time0 = get_time() - time0;
128 printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n",
129 ((double)time0/10000.0),
130 XVAL( bbox.xMin ),
131 XVAL( bbox.yMin ),
132 XVAL( bbox.xMax ),
133 XVAL( bbox.yMax ) );
134
135
136 time0 = get_time();
137 for ( count = repeat; count > 0; count-- )
138 FT_Outline_Get_BBox( outline, &bbox );
139
140 time0 = get_time() - time0;
141 printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n",
142 ((double)time0/10000.0),
143 XVAL( bbox.xMin ),
144 XVAL( bbox.yMin ),
145 XVAL( bbox.xMax ),
146 XVAL( bbox.yMax ) );
147 }
148
149 #define REPEAT 100000L
150
151 int main( int argc, char** argv )
152 {
153 printf( "outline #1\n" );
154 profile_outline( &dummy_outline_1, REPEAT );
155
156 printf( "outline #2\n" );
157 profile_outline( &dummy_outline_2, REPEAT );
158 return 0;
159 }
160
FT_Outline_Get_BBox
FT_BEGIN_HEADER FT_Outline_Get_BBox(FT_Outline *outline, FT_BBox *abbox)
dummy_tag_1
static char dummy_tag_1[4]
Definition: test_bbox.c:47
profile_outline
static void profile_outline(FT_Outline *outline, long repeat)
Definition: test_bbox.c:116
main
int main(int argc, char **argv)
Definition: bootstrap.cpp:102
FT_CURVE_TAG_CUBIC
#define FT_CURVE_TAG_CUBIC
Definition: ftimage.h:518
bbox
FT_BBox bbox
Definition: ftbbox.c:578
dump_outline
static void dump_outline(FT_Outline *outline)
Definition: test_bbox.c:92
FT_Outline_
Definition: ftimage.h:383
dummy_contour_1
static short dummy_contour_1[1]
Definition: test_bbox.c:55
dummy_outline_2
static FT_Outline dummy_outline_2
Definition: test_bbox.c:80
get_time
static long get_time(void)
Definition: test_bbox.c:16
FT_Outline_Get_CBox
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
Definition: ftoutln.c:460
dummy_vec_1
static FT_Vector dummy_vec_1[4]
Definition: test_bbox.c:32
dummy_outline_1
static FT_Outline dummy_outline_1
Definition: test_bbox.c:60
REPEAT
#define REPEAT
Definition: test_bbox.c:149
FT_BBox_::yMax
FT_Pos yMax
Definition: ftimage.h:119
FT_BBox_::xMin
FT_Pos xMin
Definition: ftimage.h:118
dummy_vec_2
static FT_Vector dummy_vec_2[4]
Definition: test_bbox.c:72
count
GLint GLsizei count
Definition: gl2ext.h:1011
FT_Vector_
Definition: ftimage.h:75
FT_BBox_::xMax
FT_Pos xMax
Definition: ftimage.h:119
XVAL
#define XVAL(x)
Definition: test_bbox.c:29
ft2build.h
XVEC
#define XVEC(x, y)
Definition: test_bbox.c:28
FT_CURVE_TAG_ON
#define FT_CURVE_TAG_ON
Definition: ftimage.h:516
FT_BBox_::yMin
FT_Pos yMin
Definition: ftimage.h:118
FT_BBox_
Definition: ftimage.h:116