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-2013 by */ | 7 /* Copyright 2000-2003, 2005-2014 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 |
18 /*************************************************************************/ | 18 /*************************************************************************/ |
19 /* */ | 19 /* */ |
20 /* This file can be compiled without the rest of the FreeType engine, by */ | 20 /* This file can be compiled without the rest of the FreeType engine, by */ |
21 /* defining the _STANDALONE_ macro when compiling it. You also need to */ | 21 /* defining the _STANDALONE_ macro when compiling it. You also need to */ |
22 /* put the files `ftgrays.h' and `ftimage.h' into the current */ | 22 /* put the files `ftgrays.h' and `ftimage.h' into the current */ |
23 /* compilation directory. Typically, you could do something like */ | 23 /* compilation directory. Typically, you could do something like */ |
24 /* */ | 24 /* */ |
25 /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ | 25 /* - copy `src/smooth/ftgrays.c' (this file) to your current directory */ |
26 /* */ | 26 /* */ |
27 /* - copy `include/freetype/ftimage.h' and `src/smooth/ftgrays.h' to the */ | 27 /* - copy `include/ftimage.h' and `src/smooth/ftgrays.h' to the same */ |
28 /* same directory */ | 28 /* directory */ |
29 /* */ | 29 /* */ |
30 /* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */ | 30 /* - compile `ftgrays' with the _STANDALONE_ macro defined, as in */ |
31 /* */ | 31 /* */ |
32 /* cc -c -D_STANDALONE_ ftgrays.c */ | 32 /* cc -c -D_STANDALONE_ ftgrays.c */ |
33 /* */ | 33 /* */ |
34 /* The renderer can be initialized with a call to */ | 34 /* The renderer can be initialized with a call to */ |
35 /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ | 35 /* `ft_gray_raster.raster_new'; an anti-aliased bitmap can be generated */ |
36 /* with a call to `ft_gray_raster.raster_render'. */ | 36 /* with a call to `ft_gray_raster.raster_render'. */ |
37 /* */ | 37 /* */ |
38 /* See the comments and documentation in the file `ftimage.h' for more */ | 38 /* See the comments and documentation in the file `ftimage.h' for more */ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. */ | 97 /* Auxiliary macros for token concatenation. */ |
98 #define FT_ERR_XCAT( x, y ) x ## y | 98 #define FT_ERR_XCAT( x, y ) x ## y |
99 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) | 99 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) |
100 | 100 |
| 101 #define FT_BEGIN_STMNT do { |
| 102 #define FT_END_STMNT } while ( 0 ) |
| 103 |
101 | 104 |
102 /* define this to dump debugging information */ | 105 /* define this to dump debugging information */ |
103 /* #define FT_DEBUG_LEVEL_TRACE */ | 106 /* #define FT_DEBUG_LEVEL_TRACE */ |
104 | 107 |
105 | 108 |
106 #ifdef FT_DEBUG_LEVEL_TRACE | 109 #ifdef FT_DEBUG_LEVEL_TRACE |
107 #include <stdio.h> | 110 #include <stdio.h> |
108 #include <stdarg.h> | 111 #include <stdarg.h> |
109 #endif | 112 #endif |
110 | 113 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 raster_reset_, \ | 230 raster_reset_, \ |
228 raster_set_mode_, \ | 231 raster_set_mode_, \ |
229 raster_render_, \ | 232 raster_render_, \ |
230 raster_done_ \ | 233 raster_done_ \ |
231 }; | 234 }; |
232 | 235 |
233 | 236 |
234 #else /* !_STANDALONE_ */ | 237 #else /* !_STANDALONE_ */ |
235 | 238 |
236 | 239 |
237 #include "../../include/ft2build.h" | 240 #include <ft2build.h> |
238 #include "ftgrays.h" | 241 #include "ftgrays.h" |
239 #include "../../include/freetype/internal/ftobjs.h" | 242 #include FT_INTERNAL_OBJECTS_H |
240 #include "../../include/freetype/internal/ftdebug.h" | 243 #include FT_INTERNAL_DEBUG_H |
241 #include "../../include/freetype/ftoutln.h" | 244 #include FT_OUTLINE_H |
242 | 245 |
243 #include "ftsmerrs.h" | 246 #include "ftsmerrs.h" |
244 | 247 |
245 #include "ftspic.h" | 248 #include "ftspic.h" |
246 | 249 |
247 #define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph | 250 #define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph |
248 #define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory | 251 #define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory |
249 #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory | 252 #define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory |
250 | 253 |
251 | 254 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 306 |
304 #if PIXEL_BITS >= 6 | 307 #if PIXEL_BITS >= 6 |
305 #define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) | 308 #define UPSCALE( x ) ( (x) << ( PIXEL_BITS - 6 ) ) |
306 #define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) | 309 #define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) ) |
307 #else | 310 #else |
308 #define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) | 311 #define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) ) |
309 #define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) | 312 #define DOWNSCALE( x ) ( (x) << ( 6 - PIXEL_BITS ) ) |
310 #endif | 313 #endif |
311 | 314 |
312 | 315 |
| 316 /* Compute `dividend / divisor' and return both its quotient and */ |
| 317 /* remainder, cast to a specific type. This macro also ensures that */ |
| 318 /* the remainder is always positive. */ |
| 319 #define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ |
| 320 FT_BEGIN_STMNT \ |
| 321 (quotient) = (type)( (dividend) / (divisor) ); \ |
| 322 (remainder) = (type)( (dividend) % (divisor) ); \ |
| 323 if ( (remainder) < 0 ) \ |
| 324 { \ |
| 325 (quotient)--; \ |
| 326 (remainder) += (type)(divisor); \ |
| 327 } \ |
| 328 FT_END_STMNT |
| 329 |
| 330 #ifdef __arm__ |
| 331 /* Work around a bug specific to GCC which make the compiler fail to */ |
| 332 /* optimize a division and modulo operation on the same parameters */ |
| 333 /* into a single call to `__aeabi_idivmod'. See */ |
| 334 /* */ |
| 335 /* http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43721 */ |
| 336 #undef FT_DIV_MOD |
| 337 #define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \ |
| 338 FT_BEGIN_STMNT \ |
| 339 (quotient) = (type)( (dividend) / (divisor) ); \ |
| 340 (remainder) = (type)( (dividend) - (quotient) * (divisor) ); \ |
| 341 if ( (remainder) < 0 ) \ |
| 342 { \ |
| 343 (quotient)--; \ |
| 344 (remainder) += (type)(divisor); \ |
| 345 } \ |
| 346 FT_END_STMNT |
| 347 #endif /* __arm__ */ |
| 348 |
| 349 |
313 /*************************************************************************/ | 350 /*************************************************************************/ |
314 /* */ | 351 /* */ |
315 /* TYPE DEFINITIONS */ | 352 /* TYPE DEFINITIONS */ |
316 /* */ | 353 /* */ |
317 | 354 |
318 /* don't change the following types to FT_Int or FT_Pos, since we might */ | 355 /* don't change the following types to FT_Int or FT_Pos, since we might */ |
319 /* need to define them to "float" or "double" when experimenting with */ | 356 /* need to define them to "float" or "double" when experimenting with */ |
320 /* new algorithms */ | 357 /* new algorithms */ |
321 | 358 |
322 typedef long TCoord; /* integer scanline/pixel coordinate */ | 359 typedef long TCoord; /* integer scanline/pixel coordinate */ |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 *pcell = cell; | 578 *pcell = cell; |
542 | 579 |
543 Exit: | 580 Exit: |
544 return cell; | 581 return cell; |
545 } | 582 } |
546 | 583 |
547 | 584 |
548 static void | 585 static void |
549 gray_record_cell( RAS_ARG ) | 586 gray_record_cell( RAS_ARG ) |
550 { | 587 { |
551 if ( !ras.invalid && ( ras.area | ras.cover ) ) | 588 if ( ras.area | ras.cover ) |
552 { | 589 { |
553 PCell cell = gray_find_cell( RAS_VAR ); | 590 PCell cell = gray_find_cell( RAS_VAR ); |
554 | 591 |
555 | 592 |
556 cell->area += ras.area; | 593 cell->area += ras.area; |
557 cell->cover += ras.cover; | 594 cell->cover += ras.cover; |
558 } | 595 } |
559 } | 596 } |
560 | 597 |
561 | 598 |
(...skipping 28 matching lines...) Expand all Loading... |
590 | 627 |
591 /* are we moving to a different cell ? */ | 628 /* are we moving to a different cell ? */ |
592 if ( ex != ras.ex || ey != ras.ey ) | 629 if ( ex != ras.ex || ey != ras.ey ) |
593 { | 630 { |
594 /* record the current one if it is valid */ | 631 /* record the current one if it is valid */ |
595 if ( !ras.invalid ) | 632 if ( !ras.invalid ) |
596 gray_record_cell( RAS_VAR ); | 633 gray_record_cell( RAS_VAR ); |
597 | 634 |
598 ras.area = 0; | 635 ras.area = 0; |
599 ras.cover = 0; | 636 ras.cover = 0; |
| 637 ras.ex = ex; |
| 638 ras.ey = ey; |
600 } | 639 } |
601 | 640 |
602 ras.ex = ex; | |
603 ras.ey = ey; | |
604 ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey || | 641 ras.invalid = ( (unsigned)ey >= (unsigned)ras.count_ey || |
605 ex >= ras.count_ex ); | 642 ex >= ras.count_ex ); |
606 } | 643 } |
607 | 644 |
608 | 645 |
609 /*************************************************************************/ | 646 /*************************************************************************/ |
610 /* */ | 647 /* */ |
611 /* Start a new contour at a given cell. */ | 648 /* Start a new contour at a given cell. */ |
612 /* */ | 649 /* */ |
613 static void | 650 static void |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 incr = 1; | 716 incr = 1; |
680 | 717 |
681 if ( dx < 0 ) | 718 if ( dx < 0 ) |
682 { | 719 { |
683 p = fx1 * ( y2 - y1 ); | 720 p = fx1 * ( y2 - y1 ); |
684 first = 0; | 721 first = 0; |
685 incr = -1; | 722 incr = -1; |
686 dx = -dx; | 723 dx = -dx; |
687 } | 724 } |
688 | 725 |
689 delta = (TCoord)( p / dx ); | 726 FT_DIV_MOD( TCoord, p, dx, delta, mod ); |
690 mod = (TCoord)( p % dx ); | |
691 if ( mod < 0 ) | |
692 { | |
693 delta--; | |
694 mod += (TCoord)dx; | |
695 } | |
696 | 727 |
697 ras.area += (TArea)(( fx1 + first ) * delta); | 728 ras.area += (TArea)(( fx1 + first ) * delta); |
698 ras.cover += delta; | 729 ras.cover += delta; |
699 | 730 |
700 ex1 += incr; | 731 ex1 += incr; |
701 gray_set_cell( RAS_VAR_ ex1, ey ); | 732 gray_set_cell( RAS_VAR_ ex1, ey ); |
702 y1 += delta; | 733 y1 += delta; |
703 | 734 |
704 if ( ex1 != ex2 ) | 735 if ( ex1 != ex2 ) |
705 { | 736 { |
706 TCoord lift, rem; | 737 TCoord lift, rem; |
707 | 738 |
708 | 739 |
709 p = ONE_PIXEL * ( y2 - y1 + delta ); | 740 p = ONE_PIXEL * ( y2 - y1 + delta ); |
710 lift = (TCoord)( p / dx ); | 741 FT_DIV_MOD( TCoord, p, dx, lift, rem ); |
711 rem = (TCoord)( p % dx ); | |
712 if ( rem < 0 ) | |
713 { | |
714 lift--; | |
715 rem += (TCoord)dx; | |
716 } | |
717 | 742 |
718 mod -= (int)dx; | 743 mod -= (int)dx; |
719 | 744 |
720 while ( ex1 != ex2 ) | 745 while ( ex1 != ex2 ) |
721 { | 746 { |
722 delta = lift; | 747 delta = lift; |
723 mod += rem; | 748 mod += rem; |
724 if ( mod >= 0 ) | 749 if ( mod >= 0 ) |
725 { | 750 { |
726 mod -= (TCoord)dx; | 751 mod -= (TCoord)dx; |
(...skipping 29 matching lines...) Expand all Loading... |
756 | 781 |
757 | 782 |
758 ey1 = TRUNC( ras.last_ey ); | 783 ey1 = TRUNC( ras.last_ey ); |
759 ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */ | 784 ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */ |
760 fy1 = (TCoord)( ras.y - ras.last_ey ); | 785 fy1 = (TCoord)( ras.y - ras.last_ey ); |
761 fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); | 786 fy2 = (TCoord)( to_y - SUBPIXELS( ey2 ) ); |
762 | 787 |
763 dx = to_x - ras.x; | 788 dx = to_x - ras.x; |
764 dy = to_y - ras.y; | 789 dy = to_y - ras.y; |
765 | 790 |
766 /* XXX: we should do something about the trivial case where dx == 0, */ | |
767 /* as it happens very often! */ | |
768 | |
769 /* perform vertical clipping */ | 791 /* perform vertical clipping */ |
770 { | 792 { |
771 TCoord min, max; | 793 TCoord min, max; |
772 | 794 |
773 | 795 |
774 min = ey1; | 796 min = ey1; |
775 max = ey2; | 797 max = ey2; |
776 if ( ey1 > ey2 ) | 798 if ( ey1 > ey2 ) |
777 { | 799 { |
778 min = ey2; | 800 min = ey2; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 incr = 1; | 859 incr = 1; |
838 | 860 |
839 if ( dy < 0 ) | 861 if ( dy < 0 ) |
840 { | 862 { |
841 p = fy1 * dx; | 863 p = fy1 * dx; |
842 first = 0; | 864 first = 0; |
843 incr = -1; | 865 incr = -1; |
844 dy = -dy; | 866 dy = -dy; |
845 } | 867 } |
846 | 868 |
847 delta = (int)( p / dy ); | 869 FT_DIV_MOD( int, p, dy, delta, mod ); |
848 mod = (int)( p % dy ); | |
849 if ( mod < 0 ) | |
850 { | |
851 delta--; | |
852 mod += (TCoord)dy; | |
853 } | |
854 | 870 |
855 x = ras.x + delta; | 871 x = ras.x + delta; |
856 gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first ); | 872 gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, (TCoord)first ); |
857 | 873 |
858 ey1 += incr; | 874 ey1 += incr; |
859 gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); | 875 gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 ); |
860 | 876 |
861 if ( ey1 != ey2 ) | 877 if ( ey1 != ey2 ) |
862 { | 878 { |
863 p = ONE_PIXEL * dx; | 879 p = ONE_PIXEL * dx; |
864 lift = (int)( p / dy ); | 880 FT_DIV_MOD( int, p, dy, lift, rem ); |
865 rem = (int)( p % dy ); | |
866 if ( rem < 0 ) | |
867 { | |
868 lift--; | |
869 rem += (int)dy; | |
870 } | |
871 mod -= (int)dy; | 881 mod -= (int)dy; |
872 | 882 |
873 while ( ey1 != ey2 ) | 883 while ( ey1 != ey2 ) |
874 { | 884 { |
875 delta = lift; | 885 delta = lift; |
876 mod += rem; | 886 mod += rem; |
877 if ( mod >= 0 ) | 887 if ( mod >= 0 ) |
878 { | 888 { |
879 mod -= (int)dy; | 889 mod -= (int)dy; |
880 delta++; | 890 delta++; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 /* F. Hain, at */ | 1084 /* F. Hain, at */ |
1075 /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camer
a-ready%20CISST02%202.pdf */ | 1085 /* http://www.cis.southalabama.edu/~hain/general/Publications/Bezier/Camer
a-ready%20CISST02%202.pdf */ |
1076 | 1086 |
1077 { | 1087 { |
1078 TPos dx, dy, dx_, dy_; | 1088 TPos dx, dy, dx_, dy_; |
1079 TPos dx1, dy1, dx2, dy2; | 1089 TPos dx1, dy1, dx2, dy2; |
1080 TPos L, s, s_limit; | 1090 TPos L, s, s_limit; |
1081 | 1091 |
1082 | 1092 |
1083 /* dx and dy are x and y components of the P0-P3 chord vector. */ | 1093 /* dx and dy are x and y components of the P0-P3 chord vector. */ |
1084 dx = arc[3].x - arc[0].x; | 1094 dx = dx_ = arc[3].x - arc[0].x; |
1085 dy = arc[3].y - arc[0].y; | 1095 dy = dy_ = arc[3].y - arc[0].y; |
1086 | 1096 |
1087 /* L is an (under)estimate of the Euclidean distance P0-P3. */ | 1097 L = FT_HYPOT( dx_, dy_ ); |
1088 /* */ | |
1089 /* If dx >= dy, then r = sqrt(dx^2 + dy^2) can be overestimated */ | |
1090 /* with least maximum error by */ | |
1091 /* */ | |
1092 /* r_upperbound = dx + (sqrt(2) - 1) * dy , */ | |
1093 /* */ | |
1094 /* where sqrt(2) - 1 can be (over)estimated by 107/256, giving an */ | |
1095 /* error of no more than 8.4%. */ | |
1096 /* */ | |
1097 /* Similarly, some elementary calculus shows that r can be */ | |
1098 /* underestimated with least maximum error by */ | |
1099 /* */ | |
1100 /* r_lowerbound = sqrt(2 + sqrt(2)) / 2 * dx */ | |
1101 /* + sqrt(2 - sqrt(2)) / 2 * dy . */ | |
1102 /* */ | |
1103 /* 236/256 and 97/256 are (under)estimates of the two algebraic */ | |
1104 /* numbers, giving an error of no more than 8.1%. */ | |
1105 | |
1106 dx_ = FT_ABS( dx ); | |
1107 dy_ = FT_ABS( dy ); | |
1108 | |
1109 /* This is the same as */ | |
1110 /* */ | |
1111 /* L = ( 236 * FT_MAX( dx_, dy_ ) */ | |
1112 /* + 97 * FT_MIN( dx_, dy_ ) ) >> 8; */ | |
1113 L = ( dx_ > dy_ ? 236 * dx_ + 97 * dy_ | |
1114 : 97 * dx_ + 236 * dy_ ) >> 8; | |
1115 | 1098 |
1116 /* Avoid possible arithmetic overflow below by splitting. */ | 1099 /* Avoid possible arithmetic overflow below by splitting. */ |
1117 if ( L > 32767 ) | 1100 if ( L > 32767 ) |
1118 goto Split; | 1101 goto Split; |
1119 | 1102 |
1120 /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */ | 1103 /* Max deviation may be as much as (s/L) * 3/4 (if Hain's v = 1). */ |
1121 s_limit = L * (TPos)( ONE_PIXEL / 6 ); | 1104 s_limit = L * (TPos)( ONE_PIXEL / 6 ); |
1122 | 1105 |
1123 /* s is L * the perpendicular distance from P1 to the line P0-P3. */ | 1106 /* s is L * the perpendicular distance from P1 to the line P0-P3. */ |
1124 dx1 = arc[1].x - arc[0].x; | 1107 dx1 = arc[1].x - arc[0].x; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 | 1147 |
1165 | 1148 |
1166 static int | 1149 static int |
1167 gray_move_to( const FT_Vector* to, | 1150 gray_move_to( const FT_Vector* to, |
1168 gray_PWorker worker ) | 1151 gray_PWorker worker ) |
1169 { | 1152 { |
1170 TPos x, y; | 1153 TPos x, y; |
1171 | 1154 |
1172 | 1155 |
1173 /* record current cell, if any */ | 1156 /* record current cell, if any */ |
1174 gray_record_cell( RAS_VAR ); | 1157 if ( !ras.invalid ) |
| 1158 gray_record_cell( RAS_VAR ); |
1175 | 1159 |
1176 /* start to a new position */ | 1160 /* start to a new position */ |
1177 x = UPSCALE( to->x ); | 1161 x = UPSCALE( to->x ); |
1178 y = UPSCALE( to->y ); | 1162 y = UPSCALE( to->y ); |
1179 | 1163 |
1180 gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); | 1164 gray_start_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) ); |
1181 | 1165 |
1182 worker->x = x; | 1166 worker->x = x; |
1183 worker->y = y; | 1167 worker->y = y; |
1184 return 0; | 1168 return 0; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 FT_TRACE7(( "[%d..%d]:%02x ", | 1333 FT_TRACE7(( "[%d..%d]:%02x ", |
1350 span->x, span->x + span->len - 1, span->coverage )); | 1334 span->x, span->x + span->len - 1, span->coverage )); |
1351 FT_TRACE7(( "\n" )); | 1335 FT_TRACE7(( "\n" )); |
1352 } | 1336 } |
1353 | 1337 |
1354 #endif /* FT_DEBUG_LEVEL_TRACE */ | 1338 #endif /* FT_DEBUG_LEVEL_TRACE */ |
1355 | 1339 |
1356 ras.num_gray_spans = 0; | 1340 ras.num_gray_spans = 0; |
1357 ras.span_y = (int)y; | 1341 ras.span_y = (int)y; |
1358 | 1342 |
1359 count = 0; | |
1360 span = ras.gray_spans; | 1343 span = ras.gray_spans; |
1361 } | 1344 } |
1362 else | 1345 else |
1363 span++; | 1346 span++; |
1364 » // Fix the Vulnerability Report FoxIT Reader - MSVR-10-0077. | 1347 |
1365 » // Limited to the value range of 'x', we have to crop it for avoid the
overflow. | |
1366 » if (x < 32768) { | |
1367 /* add a gray span to the current list */ | 1348 /* add a gray span to the current list */ |
1368 span->x = (short)x; | 1349 span->x = (short)x; |
1369 span->len = (unsigned short)acount; | 1350 span->len = (unsigned short)acount; |
1370 span->coverage = (unsigned char)coverage; | 1351 span->coverage = (unsigned char)coverage; |
1371 | 1352 |
1372 ras.num_gray_spans++; | 1353 ras.num_gray_spans++; |
1373 } | |
1374 } | 1354 } |
1375 } | 1355 } |
1376 | 1356 |
1377 | 1357 |
1378 #ifdef FT_DEBUG_LEVEL_TRACE | 1358 #ifdef FT_DEBUG_LEVEL_TRACE |
1379 | 1359 |
1380 /* to be called while in the debugger -- */ | 1360 /* to be called while in the debugger -- */ |
1381 /* this function causes a compiler warning since it is unused otherwise */ | 1361 /* this function causes a compiler warning since it is unused otherwise */ |
1382 static void | 1362 static void |
1383 gray_dump_cells( RAS_ARG ) | 1363 gray_dump_cells( RAS_ARG ) |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 int error; | 1508 int error; |
1529 | 1509 |
1530 int n; /* index of contour in outline */ | 1510 int n; /* index of contour in outline */ |
1531 int first; /* index of first point in contour */ | 1511 int first; /* index of first point in contour */ |
1532 char tag; /* current point's state */ | 1512 char tag; /* current point's state */ |
1533 | 1513 |
1534 int shift; | 1514 int shift; |
1535 TPos delta; | 1515 TPos delta; |
1536 | 1516 |
1537 | 1517 |
1538 if ( !outline || !func_interface ) | 1518 if ( !outline ) |
| 1519 return FT_THROW( Invalid_Outline ); |
| 1520 |
| 1521 if ( !func_interface ) |
1539 return FT_THROW( Invalid_Argument ); | 1522 return FT_THROW( Invalid_Argument ); |
1540 | 1523 |
1541 shift = func_interface->shift; | 1524 shift = func_interface->shift; |
1542 delta = func_interface->delta; | 1525 delta = func_interface->delta; |
1543 first = 0; | 1526 first = 0; |
1544 | 1527 |
1545 for ( n = 0; n < outline->n_contours; n++ ) | 1528 for ( n = 0; n < outline->n_contours; n++ ) |
1546 { | 1529 { |
1547 int last; /* index of last point in contour */ | 1530 int last; /* index of last point in contour */ |
1548 | 1531 |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1773 static int | 1756 static int |
1774 gray_convert_glyph_inner( RAS_ARG ) | 1757 gray_convert_glyph_inner( RAS_ARG ) |
1775 { | 1758 { |
1776 | 1759 |
1777 volatile int error = 0; | 1760 volatile int error = 0; |
1778 | 1761 |
1779 #ifdef FT_CONFIG_OPTION_PIC | 1762 #ifdef FT_CONFIG_OPTION_PIC |
1780 FT_Outline_Funcs func_interface; | 1763 FT_Outline_Funcs func_interface; |
1781 Init_Class_func_interface(&func_interface); | 1764 Init_Class_func_interface(&func_interface); |
1782 #endif | 1765 #endif |
1783 #ifndef _FX_MANAGED_CODE_ | 1766 |
1784 if ( ft_setjmp( ras.jump_buffer ) == 0 ) | 1767 if ( ft_setjmp( ras.jump_buffer ) == 0 ) |
1785 { | 1768 { |
1786 #endif | |
1787 error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); | 1769 error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras ); |
1788 gray_record_cell( RAS_VAR ); | 1770 if ( !ras.invalid ) |
1789 #ifndef _FX_MANAGED_CODE_ | 1771 gray_record_cell( RAS_VAR ); |
1790 » } | 1772 } |
1791 else | 1773 else |
1792 error = FT_THROW( Memory_Overflow ); | 1774 error = FT_THROW( Memory_Overflow ); |
1793 #endif | 1775 |
1794 return error; | 1776 return error; |
1795 } | 1777 } |
1796 | 1778 |
1797 | 1779 |
1798 static int | 1780 static int |
1799 gray_convert_glyph( RAS_ARG ) | 1781 gray_convert_glyph( RAS_ARG ) |
1800 { | 1782 { |
1801 gray_TBand bands[40]; | 1783 gray_TBand bands[40]; |
1802 gray_TBand* volatile band; | 1784 gray_TBand* volatile band; |
1803 int volatile n, num_bands; | 1785 int volatile n, num_bands; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 else | 2093 else |
2112 { | 2094 { |
2113 rast->buffer = NULL; | 2095 rast->buffer = NULL; |
2114 rast->buffer_size = 0; | 2096 rast->buffer_size = 0; |
2115 rast->worker = NULL; | 2097 rast->worker = NULL; |
2116 } | 2098 } |
2117 } | 2099 } |
2118 } | 2100 } |
2119 | 2101 |
2120 | 2102 |
| 2103 static int |
| 2104 gray_raster_set_mode( FT_Raster raster, |
| 2105 unsigned long mode, |
| 2106 void* args ) |
| 2107 { |
| 2108 FT_UNUSED( raster ); |
| 2109 FT_UNUSED( mode ); |
| 2110 FT_UNUSED( args ); |
| 2111 |
| 2112 |
| 2113 return 0; /* nothing to do */ |
| 2114 } |
| 2115 |
| 2116 |
2121 FT_DEFINE_RASTER_FUNCS(ft_grays_raster, | 2117 FT_DEFINE_RASTER_FUNCS(ft_grays_raster, |
2122 FT_GLYPH_FORMAT_OUTLINE, | 2118 FT_GLYPH_FORMAT_OUTLINE, |
2123 | 2119 |
2124 (FT_Raster_New_Func) gray_raster_new, | 2120 (FT_Raster_New_Func) gray_raster_new, |
2125 (FT_Raster_Reset_Func) gray_raster_reset, | 2121 (FT_Raster_Reset_Func) gray_raster_reset, |
2126 (FT_Raster_Set_Mode_Func)0, | 2122 (FT_Raster_Set_Mode_Func)gray_raster_set_mode, |
2127 (FT_Raster_Render_Func) gray_raster_render, | 2123 (FT_Raster_Render_Func) gray_raster_render, |
2128 (FT_Raster_Done_Func) gray_raster_done | 2124 (FT_Raster_Done_Func) gray_raster_done |
2129 ) | 2125 ) |
2130 | 2126 |
2131 | 2127 |
2132 /* END */ | 2128 /* END */ |
2133 | 2129 |
2134 | 2130 |
2135 /* Local Variables: */ | 2131 /* Local Variables: */ |
2136 /* coding: utf-8 */ | 2132 /* coding: utf-8 */ |
2137 /* End: */ | 2133 /* End: */ |
OLD | NEW |