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-2012 by */ | 7 /* Copyright 2000-2003, 2005-2013 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 87 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
88 /* messages during execution. */ | 88 /* messages during execution. */ |
89 /* */ | 89 /* */ |
90 #undef FT_COMPONENT | 90 #undef FT_COMPONENT |
91 #define FT_COMPONENT trace_smooth | 91 #define FT_COMPONENT trace_smooth |
92 | 92 |
93 | 93 |
94 #ifdef _STANDALONE_ | 94 #ifdef _STANDALONE_ |
95 | 95 |
96 | 96 |
| 97 /* Auxiliary macros for token concatenation. */ |
| 98 #define FT_ERR_XCAT( x, y ) x ## y |
| 99 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) |
| 100 |
| 101 |
97 /* define this to dump debugging information */ | 102 /* define this to dump debugging information */ |
98 /* #define FT_DEBUG_LEVEL_TRACE */ | 103 /* #define FT_DEBUG_LEVEL_TRACE */ |
99 | 104 |
100 | 105 |
101 #ifdef FT_DEBUG_LEVEL_TRACE | 106 #ifdef FT_DEBUG_LEVEL_TRACE |
102 #include <stdio.h> | 107 #include <stdio.h> |
103 #include <stdarg.h> | 108 #include <stdarg.h> |
104 #endif | 109 #endif |
105 | 110 |
106 #include <stddef.h> | 111 #include <stddef.h> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 ... ) | 152 ... ) |
148 { | 153 { |
149 va_list ap; | 154 va_list ap; |
150 | 155 |
151 | 156 |
152 va_start( ap, fmt ); | 157 va_start( ap, fmt ); |
153 vfprintf( stderr, fmt, ap ); | 158 vfprintf( stderr, fmt, ap ); |
154 va_end( ap ); | 159 va_end( ap ); |
155 } | 160 } |
156 | 161 |
| 162 |
| 163 /* empty function useful for setting a breakpoint to catch errors */ |
| 164 int |
| 165 FT_Throw( int error, |
| 166 int line, |
| 167 const char* file ) |
| 168 { |
| 169 FT_UNUSED( error ); |
| 170 FT_UNUSED( line ); |
| 171 FT_UNUSED( file ); |
| 172 |
| 173 return 0; |
| 174 } |
| 175 |
| 176 |
157 /* we don't handle tracing levels in stand-alone mode; */ | 177 /* we don't handle tracing levels in stand-alone mode; */ |
158 #ifndef FT_TRACE5 | 178 #ifndef FT_TRACE5 |
159 #define FT_TRACE5( varformat ) FT_Message varformat | 179 #define FT_TRACE5( varformat ) FT_Message varformat |
160 #endif | 180 #endif |
161 #ifndef FT_TRACE7 | 181 #ifndef FT_TRACE7 |
162 #define FT_TRACE7( varformat ) FT_Message varformat | 182 #define FT_TRACE7( varformat ) FT_Message varformat |
163 #endif | 183 #endif |
164 #ifndef FT_ERROR | 184 #ifndef FT_ERROR |
165 #define FT_ERROR( varformat ) FT_Message varformat | 185 #define FT_ERROR( varformat ) FT_Message varformat |
166 #endif | 186 #endif |
167 | 187 |
| 188 #define FT_THROW( e ) \ |
| 189 ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \ |
| 190 __LINE__, \ |
| 191 __FILE__ ) | \ |
| 192 FT_ERR_CAT( ErrRaster, e ) ) |
| 193 |
168 #else /* !FT_DEBUG_LEVEL_TRACE */ | 194 #else /* !FT_DEBUG_LEVEL_TRACE */ |
169 | 195 |
170 #define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */ | 196 #define FT_TRACE5( x ) do { } while ( 0 ) /* nothing */ |
171 #define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */ | 197 #define FT_TRACE7( x ) do { } while ( 0 ) /* nothing */ |
172 #define FT_ERROR( x ) do { } while ( 0 ) /* nothing */ | 198 #define FT_ERROR( x ) do { } while ( 0 ) /* nothing */ |
| 199 #define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e ) |
| 200 |
173 | 201 |
174 #endif /* !FT_DEBUG_LEVEL_TRACE */ | 202 #endif /* !FT_DEBUG_LEVEL_TRACE */ |
175 | 203 |
176 | 204 |
177 #define FT_DEFINE_OUTLINE_FUNCS( class_, \ | 205 #define FT_DEFINE_OUTLINE_FUNCS( class_, \ |
178 move_to_, line_to_, \ | 206 move_to_, line_to_, \ |
179 conic_to_, cubic_to_, \ | 207 conic_to_, cubic_to_, \ |
180 shift_, delta_ ) \ | 208 shift_, delta_ ) \ |
181 static const FT_Outline_Funcs class_ = \ | 209 static const FT_Outline_Funcs class_ = \ |
182 { \ | 210 { \ |
(...skipping 12 matching lines...) Expand all Loading... |
195 const FT_Raster_Funcs class_ = \ | 223 const FT_Raster_Funcs class_ = \ |
196 { \ | 224 { \ |
197 glyph_format_, \ | 225 glyph_format_, \ |
198 raster_new_, \ | 226 raster_new_, \ |
199 raster_reset_, \ | 227 raster_reset_, \ |
200 raster_set_mode_, \ | 228 raster_set_mode_, \ |
201 raster_render_, \ | 229 raster_render_, \ |
202 raster_done_ \ | 230 raster_done_ \ |
203 }; | 231 }; |
204 | 232 |
| 233 |
205 #else /* !_STANDALONE_ */ | 234 #else /* !_STANDALONE_ */ |
206 | 235 |
207 | 236 |
208 #include <ft2build.h> | 237 #include <ft2build.h> |
209 #include "ftgrays.h" | 238 #include "ftgrays.h" |
210 #include FT_INTERNAL_OBJECTS_H | 239 #include FT_INTERNAL_OBJECTS_H |
211 #include FT_INTERNAL_DEBUG_H | 240 #include FT_INTERNAL_DEBUG_H |
212 #include FT_OUTLINE_H | 241 #include FT_OUTLINE_H |
213 | 242 |
214 #include "ftsmerrs.h" | 243 #include "ftsmerrs.h" |
215 | 244 |
216 #include "ftspic.h" | 245 #include "ftspic.h" |
217 | 246 |
218 #define ErrRaster_Invalid_Mode Smooth_Err_Cannot_Render_Glyph | 247 #define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph |
219 #define ErrRaster_Invalid_Outline Smooth_Err_Invalid_Outline | 248 #define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory |
220 #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory | 249 #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory |
221 #define ErrRaster_Invalid_Argument Smooth_Err_Invalid_Argument | 250 |
222 | 251 |
223 #endif /* !_STANDALONE_ */ | 252 #endif /* !_STANDALONE_ */ |
224 | 253 |
| 254 |
225 #ifndef FT_MEM_SET | 255 #ifndef FT_MEM_SET |
226 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) | 256 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) |
227 #endif | 257 #endif |
228 | 258 |
229 #ifndef FT_MEM_ZERO | 259 #ifndef FT_MEM_ZERO |
230 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) | 260 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) |
231 #endif | 261 #endif |
232 | 262 |
233 /* as usual, for the speed hungry :-) */ | 263 /* as usual, for the speed hungry :-) */ |
234 | 264 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 /* approximately determine the size of integers using an ANSI-C header */ | 335 /* approximately determine the size of integers using an ANSI-C header */ |
306 #if FT_UINT_MAX == 0xFFFFU | 336 #if FT_UINT_MAX == 0xFFFFU |
307 typedef long TArea; | 337 typedef long TArea; |
308 #else | 338 #else |
309 typedef int TArea; | 339 typedef int TArea; |
310 #endif | 340 #endif |
311 | 341 |
312 #endif /* PIXEL_BITS >= 8 */ | 342 #endif /* PIXEL_BITS >= 8 */ |
313 | 343 |
314 | 344 |
315 /* maximal number of gray spans in a call to the span callback */ | 345 /* maximum number of gray spans in a call to the span callback */ |
316 #define FT_MAX_GRAY_SPANS 32 | 346 #define FT_MAX_GRAY_SPANS 32 |
317 | 347 |
318 | 348 |
319 typedef struct TCell_* PCell; | 349 typedef struct TCell_* PCell; |
320 | 350 |
321 typedef struct TCell_ | 351 typedef struct TCell_ |
322 { | 352 { |
323 TPos x; /* same with gray_TWorker.ex */ | 353 TPos x; /* same with gray_TWorker.ex */ |
324 TCoord cover; /* same with gray_TWorker.cover */ | 354 TCoord cover; /* same with gray_TWorker.cover */ |
325 TArea area; | 355 TArea area; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 /* */ | 623 /* */ |
594 /* Render a scanline as one or more cells. */ | 624 /* Render a scanline as one or more cells. */ |
595 /* */ | 625 /* */ |
596 static void | 626 static void |
597 gray_render_scanline( RAS_ARG_ TCoord ey, | 627 gray_render_scanline( RAS_ARG_ TCoord ey, |
598 TPos x1, | 628 TPos x1, |
599 TCoord y1, | 629 TCoord y1, |
600 TPos x2, | 630 TPos x2, |
601 TCoord y2 ) | 631 TCoord y2 ) |
602 { | 632 { |
603 TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem; | 633 TCoord ex1, ex2, fx1, fx2, delta, mod; |
604 long p, first, dx; | 634 long p, first, dx; |
605 int incr; | 635 int incr; |
606 | 636 |
607 | 637 |
608 dx = x2 - x1; | 638 dx = x2 - x1; |
609 | 639 |
610 ex1 = TRUNC( x1 ); | 640 ex1 = TRUNC( x1 ); |
611 ex2 = TRUNC( x2 ); | 641 ex2 = TRUNC( x2 ); |
612 fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); | 642 fx1 = (TCoord)( x1 - SUBPIXELS( ex1 ) ); |
613 fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); | 643 fx2 = (TCoord)( x2 - SUBPIXELS( ex2 ) ); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 | 684 |
655 ras.area += (TArea)(( fx1 + first ) * delta); | 685 ras.area += (TArea)(( fx1 + first ) * delta); |
656 ras.cover += delta; | 686 ras.cover += delta; |
657 | 687 |
658 ex1 += incr; | 688 ex1 += incr; |
659 gray_set_cell( RAS_VAR_ ex1, ey ); | 689 gray_set_cell( RAS_VAR_ ex1, ey ); |
660 y1 += delta; | 690 y1 += delta; |
661 | 691 |
662 if ( ex1 != ex2 ) | 692 if ( ex1 != ex2 ) |
663 { | 693 { |
| 694 TCoord lift, rem; |
| 695 |
| 696 |
664 p = ONE_PIXEL * ( y2 - y1 + delta ); | 697 p = ONE_PIXEL * ( y2 - y1 + delta ); |
665 lift = (TCoord)( p / dx ); | 698 lift = (TCoord)( p / dx ); |
666 rem = (TCoord)( p % dx ); | 699 rem = (TCoord)( p % dx ); |
667 if ( rem < 0 ) | 700 if ( rem < 0 ) |
668 { | 701 { |
669 lift--; | 702 lift--; |
670 rem += (TCoord)dx; | 703 rem += (TCoord)dx; |
671 } | 704 } |
672 | 705 |
673 mod -= (int)dx; | 706 mod -= (int)dx; |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 goto Split; | 1117 goto Split; |
1085 | 1118 |
1086 /* s is L * the perpendicular distance from P2 to the line P0-P3. */ | 1119 /* s is L * the perpendicular distance from P2 to the line P0-P3. */ |
1087 dx2 = arc[2].x - arc[0].x; | 1120 dx2 = arc[2].x - arc[0].x; |
1088 dy2 = arc[2].y - arc[0].y; | 1121 dy2 = arc[2].y - arc[0].y; |
1089 s = FT_ABS( dy * dx2 - dx * dy2 ); | 1122 s = FT_ABS( dy * dx2 - dx * dy2 ); |
1090 | 1123 |
1091 if ( s > s_limit ) | 1124 if ( s > s_limit ) |
1092 goto Split; | 1125 goto Split; |
1093 | 1126 |
1094 /* If P1 or P2 is outside P0-P3, split the curve. */ | 1127 /* Split super curvy segments where the off points are so far |
1095 if ( dy * dy1 + dx * dx1 < 0 || | 1128 from the chord that the angles P0-P1-P3 or P0-P2-P3 become |
1096 dy * dy2 + dx * dx2 < 0 || | 1129 acute as detected by appropriate dot products. */ |
1097 dy * (arc[3].y - arc[1].y) + dx * (arc[3].x - arc[1].x) < 0 || | 1130 if ( dx1 * ( dx1 - dx ) + dy1 * ( dy1 - dy ) > 0 || |
1098 dy * (arc[3].y - arc[2].y) + dx * (arc[3].x - arc[2].x) < 0 ) | 1131 dx2 * ( dx2 - dx ) + dy2 * ( dy2 - dy ) > 0 ) |
1099 goto Split; | 1132 goto Split; |
1100 | 1133 |
1101 /* No reason to split. */ | 1134 /* No reason to split. */ |
1102 goto Draw; | 1135 goto Draw; |
1103 } | 1136 } |
1104 | 1137 |
1105 Split: | 1138 Split: |
1106 gray_split_cubic( arc ); | 1139 gray_split_cubic( arc ); |
1107 arc += 3; | 1140 arc += 3; |
1108 continue; | 1141 continue; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1220 } | 1253 } |
1221 } | 1254 } |
1222 | 1255 |
1223 | 1256 |
1224 static void | 1257 static void |
1225 gray_hline( RAS_ARG_ TCoord x, | 1258 gray_hline( RAS_ARG_ TCoord x, |
1226 TCoord y, | 1259 TCoord y, |
1227 TPos area, | 1260 TPos area, |
1228 TCoord acount ) | 1261 TCoord acount ) |
1229 { | 1262 { |
1230 FT_Span* span; | 1263 int coverage; |
1231 int count; | |
1232 int coverage; | |
1233 | 1264 |
1234 | 1265 |
1235 /* compute the coverage line's coverage, depending on the */ | 1266 /* compute the coverage line's coverage, depending on the */ |
1236 /* outline fill rule */ | 1267 /* outline fill rule */ |
1237 /* */ | 1268 /* */ |
1238 /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ | 1269 /* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */ |
1239 /* */ | 1270 /* */ |
1240 coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); | 1271 coverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) ); |
1241 /* use range 0..256 */ | 1272 /* use range 0..256 */ |
1242 if ( coverage < 0 ) | 1273 if ( coverage < 0 ) |
(...skipping 21 matching lines...) Expand all Loading... |
1264 /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */ | 1295 /* FT_Span.x is a 16-bit short, so limit our coordinates appropriately */ |
1265 if ( x >= 32767 ) | 1296 if ( x >= 32767 ) |
1266 x = 32767; | 1297 x = 32767; |
1267 | 1298 |
1268 /* FT_Span.y is an integer, so limit our coordinates appropriately */ | 1299 /* FT_Span.y is an integer, so limit our coordinates appropriately */ |
1269 if ( y >= FT_INT_MAX ) | 1300 if ( y >= FT_INT_MAX ) |
1270 y = FT_INT_MAX; | 1301 y = FT_INT_MAX; |
1271 | 1302 |
1272 if ( coverage ) | 1303 if ( coverage ) |
1273 { | 1304 { |
| 1305 FT_Span* span; |
| 1306 int count; |
| 1307 |
| 1308 |
1274 /* see whether we can add this span to the current list */ | 1309 /* see whether we can add this span to the current list */ |
1275 count = ras.num_gray_spans; | 1310 count = ras.num_gray_spans; |
1276 span = ras.gray_spans + count - 1; | 1311 span = ras.gray_spans + count - 1; |
1277 if ( count > 0 && | 1312 if ( count > 0 && |
1278 ras.span_y == y && | 1313 ras.span_y == y && |
1279 (int)span->x + span->len == (int)x && | 1314 (int)span->x + span->len == (int)x && |
1280 span->coverage == coverage ) | 1315 span->coverage == coverage ) |
1281 { | 1316 { |
1282 span->len = (unsigned short)( span->len + acount ); | 1317 span->len = (unsigned short)( span->len + acount ); |
1283 return; | 1318 return; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 | 1428 |
1394 if ( cover != 0 ) | 1429 if ( cover != 0 ) |
1395 gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), | 1430 gray_hline( RAS_VAR_ x, yindex, cover * ( ONE_PIXEL * 2 ), |
1396 ras.count_ex - x ); | 1431 ras.count_ex - x ); |
1397 } | 1432 } |
1398 | 1433 |
1399 if ( ras.render_span && ras.num_gray_spans > 0 ) | 1434 if ( ras.render_span && ras.num_gray_spans > 0 ) |
1400 ras.render_span( ras.span_y, ras.num_gray_spans, | 1435 ras.render_span( ras.span_y, ras.num_gray_spans, |
1401 ras.gray_spans, ras.render_span_data ); | 1436 ras.gray_spans, ras.render_span_data ); |
1402 | 1437 |
| 1438 #ifdef FT_DEBUG_LEVEL_TRACE |
| 1439 |
| 1440 if ( ras.num_gray_spans > 0 ) |
| 1441 { |
| 1442 FT_Span* span; |
| 1443 int n; |
| 1444 |
| 1445 |
| 1446 FT_TRACE7(( "y = %3d ", ras.span_y )); |
| 1447 span = ras.gray_spans; |
| 1448 for ( n = 0; n < ras.num_gray_spans; n++, span++ ) |
| 1449 FT_TRACE7(( "[%d..%d]:%02x ", |
| 1450 span->x, span->x + span->len - 1, span->coverage )); |
| 1451 FT_TRACE7(( "\n" )); |
| 1452 } |
| 1453 |
1403 FT_TRACE7(( "gray_sweep: end\n" )); | 1454 FT_TRACE7(( "gray_sweep: end\n" )); |
| 1455 |
| 1456 #endif /* FT_DEBUG_LEVEL_TRACE */ |
| 1457 |
1404 } | 1458 } |
1405 | 1459 |
1406 | 1460 |
1407 #ifdef _STANDALONE_ | 1461 #ifdef _STANDALONE_ |
1408 | 1462 |
1409 /*************************************************************************/ | 1463 /*************************************************************************/ |
1410 /* */ | 1464 /* */ |
1411 /* The following function should only compile in stand-alone mode, */ | 1465 /* The following function should only compile in stand-alone mode, */ |
1412 /* i.e., when building this component without the rest of FreeType. */ | 1466 /* i.e., when building this component without the rest of FreeType. */ |
1413 /* */ | 1467 /* */ |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1514 |
1461 int n; /* index of contour in outline */ | 1515 int n; /* index of contour in outline */ |
1462 int first; /* index of first point in contour */ | 1516 int first; /* index of first point in contour */ |
1463 char tag; /* current point's state */ | 1517 char tag; /* current point's state */ |
1464 | 1518 |
1465 int shift; | 1519 int shift; |
1466 TPos delta; | 1520 TPos delta; |
1467 | 1521 |
1468 | 1522 |
1469 if ( !outline || !func_interface ) | 1523 if ( !outline || !func_interface ) |
1470 return ErrRaster_Invalid_Argument; | 1524 return FT_THROW( Invalid_Argument ); |
1471 | 1525 |
1472 shift = func_interface->shift; | 1526 shift = func_interface->shift; |
1473 delta = func_interface->delta; | 1527 delta = func_interface->delta; |
1474 first = 0; | 1528 first = 0; |
1475 | 1529 |
1476 for ( n = 0; n < outline->n_contours; n++ ) | 1530 for ( n = 0; n < outline->n_contours; n++ ) |
1477 { | 1531 { |
1478 int last; /* index of last point in contour */ | 1532 int last; /* index of last point in contour */ |
1479 | 1533 |
1480 | 1534 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 } | 1727 } |
1674 | 1728 |
1675 FT_TRACE5(( "FT_Outline_Decompose: Done\n", n )); | 1729 FT_TRACE5(( "FT_Outline_Decompose: Done\n", n )); |
1676 return 0; | 1730 return 0; |
1677 | 1731 |
1678 Exit: | 1732 Exit: |
1679 FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); | 1733 FT_TRACE5(( "FT_Outline_Decompose: Error %d\n", error )); |
1680 return error; | 1734 return error; |
1681 | 1735 |
1682 Invalid_Outline: | 1736 Invalid_Outline: |
1683 return ErrRaster_Invalid_Outline; | 1737 return FT_THROW( Invalid_Outline ); |
1684 } | 1738 } |
1685 | 1739 |
1686 #endif /* _STANDALONE_ */ | 1740 #endif /* _STANDALONE_ */ |
1687 | 1741 |
1688 | 1742 |
1689 typedef struct gray_TBand_ | 1743 typedef struct gray_TBand_ |
1690 { | 1744 { |
1691 TPos min, max; | 1745 TPos min, max; |
1692 | 1746 |
1693 } gray_TBand; | 1747 } gray_TBand; |
(...skipping 17 matching lines...) Expand all Loading... |
1711 FT_Outline_Funcs func_interface; | 1765 FT_Outline_Funcs func_interface; |
1712 Init_Class_func_interface(&func_interface); | 1766 Init_Class_func_interface(&func_interface); |
1713 #endif | 1767 #endif |
1714 | 1768 |
1715 if ( ft_setjmp( ras.jump_buffer ) == 0 ) | 1769 if ( ft_setjmp( ras.jump_buffer ) == 0 ) |
1716 { | 1770 { |
1717 error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); | 1771 error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); |
1718 gray_record_cell( RAS_VAR ); | 1772 gray_record_cell( RAS_VAR ); |
1719 } | 1773 } |
1720 else | 1774 else |
1721 error = ErrRaster_Memory_Overflow; | 1775 error = FT_THROW( Memory_Overflow ); |
1722 | 1776 |
1723 return error; | 1777 return error; |
1724 } | 1778 } |
1725 | 1779 |
1726 | 1780 |
1727 static int | 1781 static int |
1728 gray_convert_glyph( RAS_ARG ) | 1782 gray_convert_glyph( RAS_ARG ) |
1729 { | 1783 { |
1730 gray_TBand bands[40]; | 1784 gray_TBand bands[40]; |
1731 gray_TBand* volatile band; | 1785 gray_TBand* volatile band; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 static int | 1918 static int |
1865 gray_raster_render( gray_PRaster raster, | 1919 gray_raster_render( gray_PRaster raster, |
1866 const FT_Raster_Params* params ) | 1920 const FT_Raster_Params* params ) |
1867 { | 1921 { |
1868 const FT_Outline* outline = (const FT_Outline*)params->source; | 1922 const FT_Outline* outline = (const FT_Outline*)params->source; |
1869 const FT_Bitmap* target_map = params->target; | 1923 const FT_Bitmap* target_map = params->target; |
1870 gray_PWorker worker; | 1924 gray_PWorker worker; |
1871 | 1925 |
1872 | 1926 |
1873 if ( !raster || !raster->buffer || !raster->buffer_size ) | 1927 if ( !raster || !raster->buffer || !raster->buffer_size ) |
1874 return ErrRaster_Invalid_Argument; | 1928 return FT_THROW( Invalid_Argument ); |
1875 | 1929 |
1876 if ( !outline ) | 1930 if ( !outline ) |
1877 return ErrRaster_Invalid_Outline; | 1931 return FT_THROW( Invalid_Outline ); |
1878 | 1932 |
1879 /* return immediately if the outline is empty */ | 1933 /* return immediately if the outline is empty */ |
1880 if ( outline->n_points == 0 || outline->n_contours <= 0 ) | 1934 if ( outline->n_points == 0 || outline->n_contours <= 0 ) |
1881 return 0; | 1935 return 0; |
1882 | 1936 |
1883 if ( !outline->contours || !outline->points ) | 1937 if ( !outline->contours || !outline->points ) |
1884 return ErrRaster_Invalid_Outline; | 1938 return FT_THROW( Invalid_Outline ); |
1885 | 1939 |
1886 if ( outline->n_points != | 1940 if ( outline->n_points != |
1887 outline->contours[outline->n_contours - 1] + 1 ) | 1941 outline->contours[outline->n_contours - 1] + 1 ) |
1888 return ErrRaster_Invalid_Outline; | 1942 return FT_THROW( Invalid_Outline ); |
1889 | 1943 |
1890 worker = raster->worker; | 1944 worker = raster->worker; |
1891 | 1945 |
1892 /* if direct mode is not set, we must have a target bitmap */ | 1946 /* if direct mode is not set, we must have a target bitmap */ |
1893 if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) | 1947 if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) |
1894 { | 1948 { |
1895 if ( !target_map ) | 1949 if ( !target_map ) |
1896 return ErrRaster_Invalid_Argument; | 1950 return FT_THROW( Invalid_Argument ); |
1897 | 1951 |
1898 /* nothing to do */ | 1952 /* nothing to do */ |
1899 if ( !target_map->width || !target_map->rows ) | 1953 if ( !target_map->width || !target_map->rows ) |
1900 return 0; | 1954 return 0; |
1901 | 1955 |
1902 if ( !target_map->buffer ) | 1956 if ( !target_map->buffer ) |
1903 return ErrRaster_Invalid_Argument; | 1957 return FT_THROW( Invalid_Argument ); |
1904 } | 1958 } |
1905 | 1959 |
1906 /* this version does not support monochrome rendering */ | 1960 /* this version does not support monochrome rendering */ |
1907 if ( !( params->flags & FT_RASTER_FLAG_AA ) ) | 1961 if ( !( params->flags & FT_RASTER_FLAG_AA ) ) |
1908 return ErrRaster_Invalid_Mode; | 1962 return FT_THROW( Invalid_Mode ); |
1909 | 1963 |
1910 /* compute clipping box */ | 1964 /* compute clipping box */ |
1911 if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) | 1965 if ( !( params->flags & FT_RASTER_FLAG_DIRECT ) ) |
1912 { | 1966 { |
1913 /* compute clip box from target pixmap */ | 1967 /* compute clip box from target pixmap */ |
1914 ras.clip_box.xMin = 0; | 1968 ras.clip_box.xMin = 0; |
1915 ras.clip_box.yMin = 0; | 1969 ras.clip_box.yMin = 0; |
1916 ras.clip_box.xMax = target_map->width; | 1970 ras.clip_box.xMax = target_map->width; |
1917 ras.clip_box.yMax = target_map->rows; | 1971 ras.clip_box.yMax = target_map->rows; |
1918 } | 1972 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 (FT_Raster_Done_Func) gray_raster_done | 2111 (FT_Raster_Done_Func) gray_raster_done |
2058 ) | 2112 ) |
2059 | 2113 |
2060 | 2114 |
2061 /* END */ | 2115 /* END */ |
2062 | 2116 |
2063 | 2117 |
2064 /* Local Variables: */ | 2118 /* Local Variables: */ |
2065 /* coding: utf-8 */ | 2119 /* coding: utf-8 */ |
2066 /* End: */ | 2120 /* End: */ |
OLD | NEW |