Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentest_bbox.c
Go to the documentation of this file.
00001 #include <ft2build.h> 00002 #include FT_FREETYPE_H 00003 #include FT_BBOX_H 00004 00005 00006 #include <time.h> /* for clock() */ 00007 00008 /* SunOS 4.1.* does not define CLOCKS_PER_SEC, so include <sys/param.h> */ 00009 /* to get the HZ macro which is the equivalent. */ 00010 #if defined(__sun__) && !defined(SVR4) && !defined(__SVR4) 00011 #include <sys/param.h> 00012 #define CLOCKS_PER_SEC HZ 00013 #endif 00014 00015 static long 00016 get_time( void ) 00017 { 00018 return clock() * 10000L / CLOCKS_PER_SEC; 00019 } 00020 00021 00022 00023 00024 /* test bbox computations */ 00025 00026 #define XSCALE 65536 00027 #define XX(x) ((FT_Pos)(x*XSCALE)) 00028 #define XVEC(x,y) { XX(x), XX(y) } 00029 #define XVAL(x) ((x)/(1.0*XSCALE)) 00030 00031 /* dummy outline #1 */ 00032 static FT_Vector dummy_vec_1[4] = 00033 { 00034 #if 1 00035 XVEC( 408.9111, 535.3164 ), 00036 XVEC( 455.8887, 634.396 ), 00037 XVEC( -37.8765, 786.2207 ), 00038 XVEC( 164.6074, 535.3164 ) 00039 #else 00040 { (FT_Int32)0x0198E93DL , (FT_Int32)0x021750FFL }, /* 408.9111, 535.3164 */ 00041 { (FT_Int32)0x01C7E312L , (FT_Int32)0x027A6560L }, /* 455.8887, 634.3960 */ 00042 { (FT_Int32)0xFFDA1F9EL , (FT_Int32)0x0312387FL }, /* -37.8765, 786.2207 */ 00043 { (FT_Int32)0x00A49B7EL , (FT_Int32)0x021750FFL } /* 164.6074, 535.3164 */ 00044 #endif 00045 }; 00046 00047 static char dummy_tag_1[4] = 00048 { 00049 FT_CURVE_TAG_ON, 00050 FT_CURVE_TAG_CUBIC, 00051 FT_CURVE_TAG_CUBIC, 00052 FT_CURVE_TAG_ON 00053 }; 00054 00055 static short dummy_contour_1[1] = 00056 { 00057 3 00058 }; 00059 00060 static FT_Outline dummy_outline_1 = 00061 { 00062 1, 00063 4, 00064 dummy_vec_1, 00065 dummy_tag_1, 00066 dummy_contour_1, 00067 0 00068 }; 00069 00070 00071 /* dummy outline #2 */ 00072 static FT_Vector dummy_vec_2[4] = 00073 { 00074 XVEC( 100.0, 100.0 ), 00075 XVEC( 100.0, 200.0 ), 00076 XVEC( 200.0, 200.0 ), 00077 XVEC( 200.0, 133.0 ) 00078 }; 00079 00080 static FT_Outline dummy_outline_2 = 00081 { 00082 1, 00083 4, 00084 dummy_vec_2, 00085 dummy_tag_1, 00086 dummy_contour_1, 00087 0 00088 }; 00089 00090 00091 static void 00092 dump_outline( FT_Outline* outline ) 00093 { 00094 FT_BBox bbox; 00095 00096 /* compute and display cbox */ 00097 FT_Outline_Get_CBox( outline, &bbox ); 00098 printf( "cbox = [%.2f %.2f %.2f %.2f]\n", 00099 XVAL( bbox.xMin ), 00100 XVAL( bbox.yMin ), 00101 XVAL( bbox.xMax ), 00102 XVAL( bbox.yMax ) ); 00103 00104 /* compute and display bbox */ 00105 FT_Outline_Get_BBox( outline, &bbox ); 00106 printf( "bbox = [%.2f %.2f %.2f %.2f]\n", 00107 XVAL( bbox.xMin ), 00108 XVAL( bbox.yMin ), 00109 XVAL( bbox.xMax ), 00110 XVAL( bbox.yMax ) ); 00111 } 00112 00113 00114 00115 static void 00116 profile_outline( FT_Outline* outline, 00117 long repeat ) 00118 { 00119 FT_BBox bbox; 00120 long count; 00121 long time0; 00122 00123 time0 = get_time(); 00124 for ( count = repeat; count > 0; count-- ) 00125 FT_Outline_Get_CBox( outline, &bbox ); 00126 00127 time0 = get_time() - time0; 00128 printf( "time = %5.2f cbox = [%.2f %.2f %.2f %.2f]\n", 00129 ((double)time0/10000.0), 00130 XVAL( bbox.xMin ), 00131 XVAL( bbox.yMin ), 00132 XVAL( bbox.xMax ), 00133 XVAL( bbox.yMax ) ); 00134 00135 00136 time0 = get_time(); 00137 for ( count = repeat; count > 0; count-- ) 00138 FT_Outline_Get_BBox( outline, &bbox ); 00139 00140 time0 = get_time() - time0; 00141 printf( "time = %5.2f bbox = [%.2f %.2f %.2f %.2f]\n", 00142 ((double)time0/10000.0), 00143 XVAL( bbox.xMin ), 00144 XVAL( bbox.yMin ), 00145 XVAL( bbox.xMax ), 00146 XVAL( bbox.yMax ) ); 00147 } 00148 00149 #define REPEAT 100000L 00150 00151 int main( int argc, char** argv ) 00152 { 00153 printf( "outline #1\n" ); 00154 profile_outline( &dummy_outline_1, REPEAT ); 00155 00156 printf( "outline #2\n" ); 00157 profile_outline( &dummy_outline_2, REPEAT ); 00158 return 0; 00159 } 00160 Generated on Sun May 27 2012 04:34:02 for ReactOS by
1.7.6.1
|