OLD | NEW |
1 /***************************************************************************/ | 1 /***************************************************************************/ |
2 /* */ | 2 /* */ |
3 /* ftgrays.c */ | 3 /* ftgrays.c */ |
4 /* */ | 4 /* */ |
5 /* A new `perfect' anti-aliasing renderer (body). */ | 5 /* A new `perfect' anti-aliasing renderer (body). */ |
6 /* */ | 6 /* */ |
7 /* Copyright 2000-2003, 2005-2011 by */ | 7 /* Copyright 2000-2003, 2005-2012 by */ |
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
9 /* */ | 9 /* */ |
10 /* This file is part of the FreeType project, and may only be used, */ | 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 */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
15 /* */ | 15 /* */ |
16 /***************************************************************************/ | 16 /***************************************************************************/ |
17 | 17 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 #ifndef FT_MEM_SET | 225 #ifndef FT_MEM_SET |
226 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) | 226 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) |
227 #endif | 227 #endif |
228 | 228 |
229 #ifndef FT_MEM_ZERO | 229 #ifndef FT_MEM_ZERO |
230 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) | 230 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) |
231 #endif | 231 #endif |
232 | 232 |
233 /* as usual, for the speed hungry :-) */ | 233 /* as usual, for the speed hungry :-) */ |
234 | 234 |
| 235 #undef RAS_ARG |
| 236 #undef RAS_ARG_ |
| 237 #undef RAS_VAR |
| 238 #undef RAS_VAR_ |
| 239 |
235 #ifndef FT_STATIC_RASTER | 240 #ifndef FT_STATIC_RASTER |
236 | 241 |
237 #define RAS_ARG PWorker worker | 242 #define RAS_ARG gray_PWorker worker |
238 #define RAS_ARG_ PWorker worker, | 243 #define RAS_ARG_ gray_PWorker worker, |
239 | 244 |
240 #define RAS_VAR worker | 245 #define RAS_VAR worker |
241 #define RAS_VAR_ worker, | 246 #define RAS_VAR_ worker, |
242 | 247 |
243 #else /* FT_STATIC_RASTER */ | 248 #else /* FT_STATIC_RASTER */ |
244 | 249 |
245 #define RAS_ARG /* empty */ | 250 #define RAS_ARG /* empty */ |
246 #define RAS_ARG_ /* empty */ | 251 #define RAS_ARG_ /* empty */ |
247 #define RAS_VAR /* empty */ | 252 #define RAS_VAR /* empty */ |
248 #define RAS_VAR_ /* empty */ | 253 #define RAS_VAR_ /* empty */ |
249 | 254 |
250 #endif /* FT_STATIC_RASTER */ | 255 #endif /* FT_STATIC_RASTER */ |
251 | 256 |
252 | 257 |
253 /* must be at least 6 bits! */ | 258 /* must be at least 6 bits! */ |
254 #define PIXEL_BITS 8 | 259 #define PIXEL_BITS 8 |
255 | 260 |
| 261 #undef FLOOR |
| 262 #undef CEILING |
| 263 #undef TRUNC |
| 264 #undef SCALED |
| 265 |
256 #define ONE_PIXEL ( 1L << PIXEL_BITS ) | 266 #define ONE_PIXEL ( 1L << PIXEL_BITS ) |
257 #define PIXEL_MASK ( -1L << PIXEL_BITS ) | 267 #define PIXEL_MASK ( -1L << PIXEL_BITS ) |
258 #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) | 268 #define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) ) |
259 #define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) | 269 #define SUBPIXELS( x ) ( (TPos)(x) << PIXEL_BITS ) |
260 #define FLOOR( x ) ( (x) & -ONE_PIXEL ) | 270 #define FLOOR( x ) ( (x) & -ONE_PIXEL ) |
261 #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) | 271 #define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL ) |
262 #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) | 272 #define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL ) |
263 | 273 |
264 #if PIXEL_BITS >= 6 | 274 #if PIXEL_BITS >= 6 |
265 #define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) | 275 #define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 313 |
304 | 314 |
305 /* maximal number of gray spans in a call to the span callback */ | 315 /* maximal number of gray spans in a call to the span callback */ |
306 #define FT_MAX_GRAY_SPANS 32 | 316 #define FT_MAX_GRAY_SPANS 32 |
307 | 317 |
308 | 318 |
309 typedef struct TCell_* PCell; | 319 typedef struct TCell_* PCell; |
310 | 320 |
311 typedef struct TCell_ | 321 typedef struct TCell_ |
312 { | 322 { |
313 TPos x; /* same with TWorker.ex */ | 323 TPos x; /* same with gray_TWorker.ex */ |
314 TCoord cover; /* same with TWorker.cover */ | 324 TCoord cover; /* same with gray_TWorker.cover */ |
315 TArea area; | 325 TArea area; |
316 PCell next; | 326 PCell next; |
317 | 327 |
318 } TCell; | 328 } TCell; |
319 | 329 |
320 | 330 |
321 typedef struct TWorker_ | 331 typedef struct gray_TWorker_ |
322 { | 332 { |
323 TCoord ex, ey; | 333 TCoord ex, ey; |
324 TPos min_ex, max_ex; | 334 TPos min_ex, max_ex; |
325 TPos min_ey, max_ey; | 335 TPos min_ey, max_ey; |
326 TPos count_ex, count_ey; | 336 TPos count_ex, count_ey; |
327 | 337 |
328 TArea area; | 338 TArea area; |
329 TCoord cover; | 339 TCoord cover; |
330 int invalid; | 340 int invalid; |
331 | 341 |
332 PCell cells; | 342 PCell cells; |
333 FT_PtrDist max_cells; | 343 FT_PtrDist max_cells; |
334 FT_PtrDist num_cells; | 344 FT_PtrDist num_cells; |
335 | 345 |
336 TCoord cx, cy; | 346 TCoord cx, cy; |
337 TPos x, y; | 347 TPos x, y; |
338 | 348 |
339 TPos last_ey; | 349 TPos last_ey; |
340 | 350 |
341 FT_Vector bez_stack[32 * 3 + 1]; | 351 FT_Vector bez_stack[32 * 3 + 1]; |
342 int lev_stack[32]; | 352 int lev_stack[32]; |
(...skipping 13 matching lines...) Expand all Loading... |
356 int band_shoot; | 366 int band_shoot; |
357 | 367 |
358 ft_jmp_buf jump_buffer; | 368 ft_jmp_buf jump_buffer; |
359 | 369 |
360 void* buffer; | 370 void* buffer; |
361 long buffer_size; | 371 long buffer_size; |
362 | 372 |
363 PCell* ycells; | 373 PCell* ycells; |
364 TPos ycount; | 374 TPos ycount; |
365 | 375 |
366 } TWorker, *PWorker; | 376 } gray_TWorker, *gray_PWorker; |
367 | 377 |
368 | 378 |
369 #ifndef FT_STATIC_RASTER | 379 #ifndef FT_STATIC_RASTER |
370 #define ras (*worker) | 380 #define ras (*worker) |
371 #else | 381 #else |
372 static TWorker ras; | 382 static gray_TWorker ras; |
373 #endif | 383 #endif |
374 | 384 |
375 | 385 |
376 typedef struct TRaster_ | 386 typedef struct gray_TRaster_ |
377 { | 387 { |
378 void* buffer; | 388 void* buffer; |
379 long buffer_size; | 389 long buffer_size; |
380 int band_size; | 390 int band_size; |
381 void* memory; | 391 void* memory; |
382 PWorker worker; | 392 gray_PWorker worker; |
383 | 393 |
384 } TRaster, *PRaster; | 394 } gray_TRaster, *gray_PRaster; |
385 | 395 |
386 | 396 |
387 | 397 |
388 /*************************************************************************/ | 398 /*************************************************************************/ |
389 /* */ | 399 /* */ |
390 /* Initialize the cells table. */ | 400 /* Initialize the cells table. */ |
391 /* */ | 401 /* */ |
392 static void | 402 static void |
393 gray_init_cells( RAS_ARG_ void* buffer, | 403 gray_init_cells( RAS_ARG_ void* buffer, |
394 long byte_size ) | 404 long byte_size ) |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 b = base[1].y = ( base[0].y + b ) / 2; | 875 b = base[1].y = ( base[0].y + b ) / 2; |
866 base[2].y = ( a + b ) / 2; | 876 base[2].y = ( a + b ) / 2; |
867 } | 877 } |
868 | 878 |
869 | 879 |
870 static void | 880 static void |
871 gray_render_conic( RAS_ARG_ const FT_Vector* control, | 881 gray_render_conic( RAS_ARG_ const FT_Vector* control, |
872 const FT_Vector* to ) | 882 const FT_Vector* to ) |
873 { | 883 { |
874 TPos dx, dy; | 884 TPos dx, dy; |
| 885 TPos min, max, y; |
875 int top, level; | 886 int top, level; |
876 int* levels; | 887 int* levels; |
877 FT_Vector* arc; | 888 FT_Vector* arc; |
878 | 889 |
879 | 890 |
| 891 levels = ras.lev_stack; |
| 892 |
880 arc = ras.bez_stack; | 893 arc = ras.bez_stack; |
881 arc[0].x = UPSCALE( to->x ); | 894 arc[0].x = UPSCALE( to->x ); |
882 arc[0].y = UPSCALE( to->y ); | 895 arc[0].y = UPSCALE( to->y ); |
883 arc[1].x = UPSCALE( control->x ); | 896 arc[1].x = UPSCALE( control->x ); |
884 arc[1].y = UPSCALE( control->y ); | 897 arc[1].y = UPSCALE( control->y ); |
885 arc[2].x = ras.x; | 898 arc[2].x = ras.x; |
886 arc[2].y = ras.y; | 899 arc[2].y = ras.y; |
| 900 top = 0; |
887 | 901 |
888 dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x ); | 902 dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x ); |
889 dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y ); | 903 dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y ); |
890 if ( dx < dy ) | 904 if ( dx < dy ) |
891 dx = dy; | 905 dx = dy; |
892 | 906 |
| 907 if ( dx < ONE_PIXEL / 4 ) |
| 908 goto Draw; |
| 909 |
| 910 /* short-cut the arc that crosses the current band */ |
| 911 min = max = arc[0].y; |
| 912 |
| 913 y = arc[1].y; |
| 914 if ( y < min ) min = y; |
| 915 if ( y > max ) max = y; |
| 916 |
| 917 y = arc[2].y; |
| 918 if ( y < min ) min = y; |
| 919 if ( y > max ) max = y; |
| 920 |
| 921 if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) |
| 922 goto Draw; |
| 923 |
893 level = 0; | 924 level = 0; |
894 while ( dx > ONE_PIXEL / 6 ) | 925 do |
895 { | 926 { |
896 dx >>= 2; | 927 dx >>= 2; |
897 level++; | 928 level++; |
898 } | 929 } while ( dx > ONE_PIXEL / 4 ); |
899 | 930 |
900 levels = ras.lev_stack; | |
901 levels[0] = level; | 931 levels[0] = level; |
902 top = 0; | |
903 | 932 |
904 do | 933 do |
905 { | 934 { |
906 level = levels[top]; | 935 level = levels[top]; |
907 if ( level > 1 ) | 936 if ( level > 0 ) |
908 { | 937 { |
909 /* check that the arc crosses the current band */ | |
910 TPos min, max, y; | |
911 | |
912 | |
913 min = max = arc[0].y; | |
914 | |
915 y = arc[1].y; | |
916 if ( y < min ) min = y; | |
917 if ( y > max ) max = y; | |
918 | |
919 y = arc[2].y; | |
920 if ( y < min ) min = y; | |
921 if ( y > max ) max = y; | |
922 | |
923 if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) | |
924 goto Draw; | |
925 | |
926 gray_split_conic( arc ); | 938 gray_split_conic( arc ); |
927 arc += 2; | 939 arc += 2; |
928 top++; | 940 top++; |
929 levels[top] = levels[top - 1] = level - 1; | 941 levels[top] = levels[top - 1] = level - 1; |
930 continue; | 942 continue; |
931 } | 943 } |
932 | 944 |
933 Draw: | 945 Draw: |
934 gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); | 946 gray_render_line( RAS_VAR_ arc[0].x, arc[0].y ); |
935 top--; | 947 top--; |
(...skipping 30 matching lines...) Expand all Loading... |
966 base[3].y = ( a + b ) / 2; | 978 base[3].y = ( a + b ) / 2; |
967 } | 979 } |
968 | 980 |
969 | 981 |
970 static void | 982 static void |
971 gray_render_cubic( RAS_ARG_ const FT_Vector* control1, | 983 gray_render_cubic( RAS_ARG_ const FT_Vector* control1, |
972 const FT_Vector* control2, | 984 const FT_Vector* control2, |
973 const FT_Vector* to ) | 985 const FT_Vector* to ) |
974 { | 986 { |
975 FT_Vector* arc; | 987 FT_Vector* arc; |
| 988 TPos min, max, y; |
976 | 989 |
977 | 990 |
978 arc = ras.bez_stack; | 991 arc = ras.bez_stack; |
979 arc[0].x = UPSCALE( to->x ); | 992 arc[0].x = UPSCALE( to->x ); |
980 arc[0].y = UPSCALE( to->y ); | 993 arc[0].y = UPSCALE( to->y ); |
981 arc[1].x = UPSCALE( control2->x ); | 994 arc[1].x = UPSCALE( control2->x ); |
982 arc[1].y = UPSCALE( control2->y ); | 995 arc[1].y = UPSCALE( control2->y ); |
983 arc[2].x = UPSCALE( control1->x ); | 996 arc[2].x = UPSCALE( control1->x ); |
984 arc[2].y = UPSCALE( control1->y ); | 997 arc[2].y = UPSCALE( control1->y ); |
985 arc[3].x = ras.x; | 998 arc[3].x = ras.x; |
986 arc[3].y = ras.y; | 999 arc[3].y = ras.y; |
987 | 1000 |
| 1001 /* Short-cut the arc that crosses the current band. */ |
| 1002 min = max = arc[0].y; |
| 1003 |
| 1004 y = arc[1].y; |
| 1005 if ( y < min ) |
| 1006 min = y; |
| 1007 if ( y > max ) |
| 1008 max = y; |
| 1009 |
| 1010 y = arc[2].y; |
| 1011 if ( y < min ) |
| 1012 min = y; |
| 1013 if ( y > max ) |
| 1014 max = y; |
| 1015 |
| 1016 y = arc[3].y; |
| 1017 if ( y < min ) |
| 1018 min = y; |
| 1019 if ( y > max ) |
| 1020 max = y; |
| 1021 |
| 1022 if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) |
| 1023 goto Draw; |
| 1024 |
988 for (;;) | 1025 for (;;) |
989 { | 1026 { |
990 /* Check that the arc crosses the current band. */ | |
991 TPos min, max, y; | |
992 | |
993 | |
994 min = max = arc[0].y; | |
995 | |
996 y = arc[1].y; | |
997 if ( y < min ) | |
998 min = y; | |
999 if ( y > max ) | |
1000 max = y; | |
1001 | |
1002 y = arc[2].y; | |
1003 if ( y < min ) | |
1004 min = y; | |
1005 if ( y > max ) | |
1006 max = y; | |
1007 | |
1008 y = arc[3].y; | |
1009 if ( y < min ) | |
1010 min = y; | |
1011 if ( y > max ) | |
1012 max = y; | |
1013 | |
1014 if ( TRUNC( min ) >= ras.max_ey || TRUNC( max ) < ras.min_ey ) | |
1015 goto Draw; | |
1016 | |
1017 /* Decide whether to split or draw. See `Rapid Termination */ | 1027 /* Decide whether to split or draw. See `Rapid Termination */ |
1018 /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */ | 1028 /* Evaluation for Recursive Subdivision of Bezier Curves' by Thomas */ |
1019 /* F. Hain, at */ | 1029 /* F. Hain, at */ |
1020 /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camer
a-ready%20CISST02%202.pdf */ | 1030 /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camer
a-ready%20CISST02%202.pdf */ |
1021 | 1031 |
1022 { | 1032 { |
1023 TPos dx, dy, dx_, dy_; | 1033 TPos dx, dy, dx_, dy_; |
1024 TPos dx1, dy1, dx2, dy2; | 1034 TPos dx1, dy1, dx2, dy2; |
1025 TPos L, s, s_limit; | 1035 TPos L, s, s_limit; |
1026 | 1036 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1103 if ( arc == ras.bez_stack ) | 1113 if ( arc == ras.bez_stack ) |
1104 return; | 1114 return; |
1105 | 1115 |
1106 arc -= 3; | 1116 arc -= 3; |
1107 } | 1117 } |
1108 } | 1118 } |
1109 | 1119 |
1110 | 1120 |
1111 static int | 1121 static int |
1112 gray_move_to( const FT_Vector* to, | 1122 gray_move_to( const FT_Vector* to, |
1113 PWorker worker ) | 1123 gray_PWorker worker ) |
1114 { | 1124 { |
1115 TPos x, y; | 1125 TPos x, y; |
1116 | 1126 |
1117 | 1127 |
1118 /* record current cell, if any */ | 1128 /* record current cell, if any */ |
1119 gray_record_cell( RAS_VAR ); | 1129 gray_record_cell( RAS_VAR ); |
1120 | 1130 |
1121 /* start to a new position */ | 1131 /* start to a new position */ |
1122 x = UPSCALE( to->x ); | 1132 x = UPSCALE( to->x ); |
1123 y = UPSCALE( to->y ); | 1133 y = UPSCALE( to->y ); |
1124 | 1134 |
1125 gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); | 1135 gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); |
1126 | 1136 |
1127 worker->x = x; | 1137 worker->x = x; |
1128 worker->y = y; | 1138 worker->y = y; |
1129 return 0; | 1139 return 0; |
1130 } | 1140 } |
1131 | 1141 |
1132 | 1142 |
1133 static int | 1143 static int |
1134 gray_line_to( const FT_Vector* to, | 1144 gray_line_to( const FT_Vector* to, |
1135 PWorker worker ) | 1145 gray_PWorker worker ) |
1136 { | 1146 { |
1137 gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); | 1147 gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) ); |
1138 return 0; | 1148 return 0; |
1139 } | 1149 } |
1140 | 1150 |
1141 | 1151 |
1142 static int | 1152 static int |
1143 gray_conic_to( const FT_Vector* control, | 1153 gray_conic_to( const FT_Vector* control, |
1144 const FT_Vector* to, | 1154 const FT_Vector* to, |
1145 PWorker worker ) | 1155 gray_PWorker worker ) |
1146 { | 1156 { |
1147 gray_render_conic( RAS_VAR_ control, to ); | 1157 gray_render_conic( RAS_VAR_ control, to ); |
1148 return 0; | 1158 return 0; |
1149 } | 1159 } |
1150 | 1160 |
1151 | 1161 |
1152 static int | 1162 static int |
1153 gray_cubic_to( const FT_Vector* control1, | 1163 gray_cubic_to( const FT_Vector* control1, |
1154 const FT_Vector* control2, | 1164 const FT_Vector* control2, |
1155 const FT_Vector* to, | 1165 const FT_Vector* to, |
1156 PWorker worker ) | 1166 gray_PWorker worker ) |
1157 { | 1167 { |
1158 gray_render_cubic( RAS_VAR_ control1, control2, to ); | 1168 gray_render_cubic( RAS_VAR_ control1, control2, to ); |
1159 return 0; | 1169 return 0; |
1160 } | 1170 } |
1161 | 1171 |
1162 | 1172 |
1163 static void | 1173 static void |
1164 gray_render_span( int y, | 1174 gray_render_span( int y, |
1165 int count, | 1175 int count, |
1166 const FT_Span* spans, | 1176 const FT_Span* spans, |
1167 PWorker worker ) | 1177 gray_PWorker worker ) |
1168 { | 1178 { |
1169 unsigned char* p; | 1179 unsigned char* p; |
1170 FT_Bitmap* map = &worker->target; | 1180 FT_Bitmap* map = &worker->target; |
1171 | 1181 |
1172 | 1182 |
1173 /* first of all, compute the scanline offset */ | 1183 /* first of all, compute the scanline offset */ |
1174 p = (unsigned char*)map->buffer - y * map->pitch; | 1184 p = (unsigned char*)map->buffer - y * map->pitch; |
1175 if ( map->pitch >= 0 ) | 1185 if ( map->pitch >= 0 ) |
1176 p += (unsigned)( ( map->rows - 1 ) * map->pitch ); | 1186 p += (unsigned)( ( map->rows - 1 ) * map->pitch ); |
1177 | 1187 |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); | 1679 FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); |
1670 return error; | 1680 return error; |
1671 | 1681 |
1672 Invalid_Outline: | 1682 Invalid_Outline: |
1673 return ErrRaster_Invalid_Outline; | 1683 return ErrRaster_Invalid_Outline; |
1674 } | 1684 } |
1675 | 1685 |
1676 #endif /* _STANDALONE_ */ | 1686 #endif /* _STANDALONE_ */ |
1677 | 1687 |
1678 | 1688 |
1679 typedef struct TBand_ | 1689 typedef struct gray_TBand_ |
1680 { | 1690 { |
1681 TPos min, max; | 1691 TPos min, max; |
1682 | 1692 |
1683 } TBand; | 1693 } gray_TBand; |
1684 | 1694 |
1685 FT_DEFINE_OUTLINE_FUNCS(func_interface, | 1695 FT_DEFINE_OUTLINE_FUNCS(func_interface, |
1686 (FT_Outline_MoveTo_Func) gray_move_to, | 1696 (FT_Outline_MoveTo_Func) gray_move_to, |
1687 (FT_Outline_LineTo_Func) gray_line_to, | 1697 (FT_Outline_LineTo_Func) gray_line_to, |
1688 (FT_Outline_ConicTo_Func)gray_conic_to, | 1698 (FT_Outline_ConicTo_Func)gray_conic_to, |
1689 (FT_Outline_CubicTo_Func)gray_cubic_to, | 1699 (FT_Outline_CubicTo_Func)gray_cubic_to, |
1690 0, | 1700 0, |
1691 0 | 1701 0 |
1692 ) | 1702 ) |
1693 | 1703 |
(...skipping 16 matching lines...) Expand all Loading... |
1710 else | 1720 else |
1711 error = ErrRaster_Memory_Overflow; | 1721 error = ErrRaster_Memory_Overflow; |
1712 | 1722 |
1713 return error; | 1723 return error; |
1714 } | 1724 } |
1715 | 1725 |
1716 | 1726 |
1717 static int | 1727 static int |
1718 gray_convert_glyph( RAS_ARG ) | 1728 gray_convert_glyph( RAS_ARG ) |
1719 { | 1729 { |
1720 TBand bands[40]; | 1730 gray_TBand bands[40]; |
1721 TBand* volatile band; | 1731 gray_TBand* volatile band; |
1722 int volatile n, num_bands; | 1732 int volatile n, num_bands; |
1723 TPos volatile min, max, max_y; | 1733 TPos volatile min, max, max_y; |
1724 FT_BBox* clip; | 1734 FT_BBox* clip; |
1725 | 1735 |
1726 | 1736 |
1727 /* Set up state in the raster object */ | 1737 /* Set up state in the raster object */ |
1728 gray_compute_cbox( RAS_VAR ); | 1738 gray_compute_cbox( RAS_VAR ); |
1729 | 1739 |
1730 /* clip to target bitmap, exit if nothing to do */ | 1740 /* clip to target bitmap, exit if nothing to do */ |
1731 clip = &ras.clip_box; | 1741 clip = &ras.clip_box; |
1732 | 1742 |
1733 if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax || | 1743 if ( ras.max_ex <= clip->xMin || ras.min_ex >= clip->xMax || |
1734 ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax ) | 1744 ras.max_ey <= clip->yMin || ras.min_ey >= clip->yMax ) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1778 | 1788 |
1779 ras.ycells = (PCell*)ras.buffer; | 1789 ras.ycells = (PCell*)ras.buffer; |
1780 ras.ycount = band->max - band->min; | 1790 ras.ycount = band->max - band->min; |
1781 | 1791 |
1782 cell_start = sizeof ( PCell ) * ras.ycount; | 1792 cell_start = sizeof ( PCell ) * ras.ycount; |
1783 cell_mod = cell_start % sizeof ( TCell ); | 1793 cell_mod = cell_start % sizeof ( TCell ); |
1784 if ( cell_mod > 0 ) | 1794 if ( cell_mod > 0 ) |
1785 cell_start += sizeof ( TCell ) - cell_mod; | 1795 cell_start += sizeof ( TCell ) - cell_mod; |
1786 | 1796 |
1787 cell_end = ras.buffer_size; | 1797 cell_end = ras.buffer_size; |
1788 cell_end -= cell_end % sizeof( TCell ); | 1798 cell_end -= cell_end % sizeof ( TCell ); |
1789 | 1799 |
1790 cells_max = (PCell)( (char*)ras.buffer + cell_end ); | 1800 cells_max = (PCell)( (char*)ras.buffer + cell_end ); |
1791 ras.cells = (PCell)( (char*)ras.buffer + cell_start ); | 1801 ras.cells = (PCell)( (char*)ras.buffer + cell_start ); |
1792 if ( ras.cells >= cells_max ) | 1802 if ( ras.cells >= cells_max ) |
1793 goto ReduceBands; | 1803 goto ReduceBands; |
1794 | 1804 |
1795 ras.max_cells = cells_max - ras.cells; | 1805 ras.max_cells = cells_max - ras.cells; |
1796 if ( ras.max_cells < 2 ) | 1806 if ( ras.max_cells < 2 ) |
1797 goto ReduceBands; | 1807 goto ReduceBands; |
1798 | 1808 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1845 } | 1855 } |
1846 | 1856 |
1847 if ( ras.band_shoot > 8 && ras.band_size > 16 ) | 1857 if ( ras.band_shoot > 8 && ras.band_size > 16 ) |
1848 ras.band_size = ras.band_size / 2; | 1858 ras.band_size = ras.band_size / 2; |
1849 | 1859 |
1850 return 0; | 1860 return 0; |
1851 } | 1861 } |
1852 | 1862 |
1853 | 1863 |
1854 static int | 1864 static int |
1855 gray_raster_render( PRaster raster, | 1865 gray_raster_render( gray_PRaster raster, |
1856 const FT_Raster_Params* params ) | 1866 const FT_Raster_Params* params ) |
1857 { | 1867 { |
1858 const FT_Outline* outline = (const FT_Outline*)params->source; | 1868 const FT_Outline* outline = (const FT_Outline*)params->source; |
1859 const FT_Bitmap* target_map = params->target; | 1869 const FT_Bitmap* target_map = params->target; |
1860 PWorker worker; | 1870 gray_PWorker worker; |
1861 | 1871 |
1862 | 1872 |
1863 if ( !raster || !raster->buffer || !raster->buffer_size ) | 1873 if ( !raster || !raster->buffer || !raster->buffer_size ) |
1864 return ErrRaster_Invalid_Argument; | 1874 return ErrRaster_Invalid_Argument; |
1865 | 1875 |
1866 if ( !outline ) | 1876 if ( !outline ) |
1867 return ErrRaster_Invalid_Outline; | 1877 return ErrRaster_Invalid_Outline; |
1868 | 1878 |
1869 /* return immediately if the outline is empty */ | 1879 /* return immediately if the outline is empty */ |
1870 if ( outline->n_points == 0 || outline->n_contours <= 0 ) | 1880 if ( outline->n_points == 0 || outline->n_contours <= 0 ) |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1942 | 1952 |
1943 /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/ | 1953 /**** RASTER OBJECT CREATION: In stand-alone mode, we simply use *****/ |
1944 /**** a static object. *****/ | 1954 /**** a static object. *****/ |
1945 | 1955 |
1946 #ifdef _STANDALONE_ | 1956 #ifdef _STANDALONE_ |
1947 | 1957 |
1948 static int | 1958 static int |
1949 gray_raster_new( void* memory, | 1959 gray_raster_new( void* memory, |
1950 FT_Raster* araster ) | 1960 FT_Raster* araster ) |
1951 { | 1961 { |
1952 static TRaster the_raster; | 1962 static gray_TRaster the_raster; |
1953 | 1963 |
1954 FT_UNUSED( memory ); | 1964 FT_UNUSED( memory ); |
1955 | 1965 |
1956 | 1966 |
1957 *araster = (FT_Raster)&the_raster; | 1967 *araster = (FT_Raster)&the_raster; |
1958 FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); | 1968 FT_MEM_ZERO( &the_raster, sizeof ( the_raster ) ); |
1959 | 1969 |
1960 return 0; | 1970 return 0; |
1961 } | 1971 } |
1962 | 1972 |
1963 | 1973 |
1964 static void | 1974 static void |
1965 gray_raster_done( FT_Raster raster ) | 1975 gray_raster_done( FT_Raster raster ) |
1966 { | 1976 { |
1967 /* nothing */ | 1977 /* nothing */ |
1968 FT_UNUSED( raster ); | 1978 FT_UNUSED( raster ); |
1969 } | 1979 } |
1970 | 1980 |
1971 #else /* !_STANDALONE_ */ | 1981 #else /* !_STANDALONE_ */ |
1972 | 1982 |
1973 static int | 1983 static int |
1974 gray_raster_new( FT_Memory memory, | 1984 gray_raster_new( FT_Memory memory, |
1975 FT_Raster* araster ) | 1985 FT_Raster* araster ) |
1976 { | 1986 { |
1977 FT_Error error; | 1987 FT_Error error; |
1978 PRaster raster = NULL; | 1988 gray_PRaster raster = NULL; |
1979 | 1989 |
1980 | 1990 |
1981 *araster = 0; | 1991 *araster = 0; |
1982 if ( !FT_ALLOC( raster, sizeof ( TRaster ) ) ) | 1992 if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) ) |
1983 { | 1993 { |
1984 raster->memory = memory; | 1994 raster->memory = memory; |
1985 *araster = (FT_Raster)raster; | 1995 *araster = (FT_Raster)raster; |
1986 } | 1996 } |
1987 | 1997 |
1988 return error; | 1998 return error; |
1989 } | 1999 } |
1990 | 2000 |
1991 | 2001 |
1992 static void | 2002 static void |
1993 gray_raster_done( FT_Raster raster ) | 2003 gray_raster_done( FT_Raster raster ) |
1994 { | 2004 { |
1995 FT_Memory memory = (FT_Memory)((PRaster)raster)->memory; | 2005 FT_Memory memory = (FT_Memory)((gray_PRaster)raster)->memory; |
1996 | 2006 |
1997 | 2007 |
1998 FT_FREE( raster ); | 2008 FT_FREE( raster ); |
1999 } | 2009 } |
2000 | 2010 |
2001 #endif /* !_STANDALONE_ */ | 2011 #endif /* !_STANDALONE_ */ |
2002 | 2012 |
2003 | 2013 |
2004 static void | 2014 static void |
2005 gray_raster_reset( FT_Raster raster, | 2015 gray_raster_reset( FT_Raster raster, |
2006 char* pool_base, | 2016 char* pool_base, |
2007 long pool_size ) | 2017 long pool_size ) |
2008 { | 2018 { |
2009 PRaster rast = (PRaster)raster; | 2019 gray_PRaster rast = (gray_PRaster)raster; |
2010 | 2020 |
2011 | 2021 |
2012 if ( raster ) | 2022 if ( raster ) |
2013 { | 2023 { |
2014 if ( pool_base && pool_size >= (long)sizeof ( TWorker ) + 2048 ) | 2024 if ( pool_base && pool_size >= (long)sizeof ( gray_TWorker ) + 2048 ) |
2015 { | 2025 { |
2016 PWorker worker = (PWorker)pool_base; | 2026 gray_PWorker worker = (gray_PWorker)pool_base; |
2017 | 2027 |
2018 | 2028 |
2019 rast->worker = worker; | 2029 rast->worker = worker; |
2020 rast->buffer = pool_base + | 2030 rast->buffer = pool_base + |
2021 ( ( sizeof ( TWorker ) + sizeof ( TCell ) - 1 ) & | 2031 ( ( sizeof ( gray_TWorker ) + |
| 2032 sizeof ( TCell ) - 1 ) & |
2022 ~( sizeof ( TCell ) - 1 ) ); | 2033 ~( sizeof ( TCell ) - 1 ) ); |
2023 rast->buffer_size = (long)( ( pool_base + pool_size ) - | 2034 rast->buffer_size = (long)( ( pool_base + pool_size ) - |
2024 (char*)rast->buffer ) & | 2035 (char*)rast->buffer ) & |
2025 ~( sizeof ( TCell ) - 1 ); | 2036 ~( sizeof ( TCell ) - 1 ); |
2026 rast->band_size = (int)( rast->buffer_size / | 2037 rast->band_size = (int)( rast->buffer_size / |
2027 ( sizeof ( TCell ) * 8 ) ); | 2038 ( sizeof ( TCell ) * 8 ) ); |
2028 } | 2039 } |
2029 else | 2040 else |
2030 { | 2041 { |
2031 rast->buffer = NULL; | 2042 rast->buffer = NULL; |
(...skipping 14 matching lines...) Expand all Loading... |
2046 (FT_Raster_Done_Func) gray_raster_done | 2057 (FT_Raster_Done_Func) gray_raster_done |
2047 ) | 2058 ) |
2048 | 2059 |
2049 | 2060 |
2050 /* END */ | 2061 /* END */ |
2051 | 2062 |
2052 | 2063 |
2053 /* Local Variables: */ | 2064 /* Local Variables: */ |
2054 /* coding: utf-8 */ | 2065 /* coding: utf-8 */ |
2055 /* End: */ | 2066 /* End: */ |
OLD | NEW |