| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftraster.c */ | 3 /* ftraster.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* The FreeType glyph rasterizer (body). */ | 5 /* The FreeType glyph rasterizer (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 1996-2003, 2005, 2007-2012 by */ | 7 /* Copyright 1996-2003, 2005, 2007-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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 #include <string.h> /* for memset */ | 54 #include <string.h> /* for memset */ |
| 55 | 55 |
| 56 #include "ftmisc.h" | 56 #include "ftmisc.h" |
| 57 #include "ftimage.h" | 57 #include "ftimage.h" |
| 58 | 58 |
| 59 #else /* !_STANDALONE_ */ | 59 #else /* !_STANDALONE_ */ |
| 60 | 60 |
| 61 #include <ft2build.h> | 61 #include <ft2build.h> |
| 62 #include "ftraster.h" | 62 #include "ftraster.h" |
| 63 #include FT_INTERNAL_CALC_H /* for FT_MulDiv only */ | 63 #include FT_INTERNAL_CALC_H /* for FT_MulDiv and FT_MulDiv_No_Round */ |
| 64 | 64 |
| 65 #include "rastpic.h" | 65 #include "rastpic.h" |
| 66 | 66 |
| 67 #endif /* !_STANDALONE_ */ | 67 #endif /* !_STANDALONE_ */ |
| 68 | 68 |
| 69 | 69 |
| 70 /*************************************************************************/ | 70 /*************************************************************************/ |
| 71 /* */ | 71 /* */ |
| 72 /* A simple technical note on how the raster works */ | 72 /* A simple technical note on how the raster works */ |
| 73 /* ----------------------------------------------- */ | 73 /* ----------------------------------------------- */ |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ | 172 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */ |
| 173 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ | 173 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */ |
| 174 /* messages during execution. */ | 174 /* messages during execution. */ |
| 175 /* */ | 175 /* */ |
| 176 #undef FT_COMPONENT | 176 #undef FT_COMPONENT |
| 177 #define FT_COMPONENT trace_raster | 177 #define FT_COMPONENT trace_raster |
| 178 | 178 |
| 179 | 179 |
| 180 #ifdef _STANDALONE_ | 180 #ifdef _STANDALONE_ |
| 181 | 181 |
| 182 /* Auxiliary macros for token concatenation. */ |
| 183 #define FT_ERR_XCAT( x, y ) x ## y |
| 184 #define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) |
| 182 | 185 |
| 183 /* This macro is used to indicate that a function parameter is unused. */ | 186 /* This macro is used to indicate that a function parameter is unused. */ |
| 184 /* Its purpose is simply to reduce compiler warnings. Note also that */ | 187 /* Its purpose is simply to reduce compiler warnings. Note also that */ |
| 185 /* simply defining it as `(void)x' doesn't avoid warnings with certain */ | 188 /* simply defining it as `(void)x' doesn't avoid warnings with certain */ |
| 186 /* ANSI compilers (e.g. LCC). */ | 189 /* ANSI compilers (e.g. LCC). */ |
| 187 #define FT_UNUSED( x ) (x) = (x) | 190 #define FT_UNUSED( x ) (x) = (x) |
| 188 | 191 |
| 189 /* Disable the tracing mechanism for simplicity -- developers can */ | 192 /* Disable the tracing mechanism for simplicity -- developers can */ |
| 190 /* activate it easily by redefining these two macros. */ | 193 /* activate it easily by redefining these macros. */ |
| 191 #ifndef FT_ERROR | 194 #ifndef FT_ERROR |
| 192 #define FT_ERROR( x ) do { } while ( 0 ) /* nothing */ | 195 #define FT_ERROR( x ) do { } while ( 0 ) /* nothing */ |
| 193 #endif | 196 #endif |
| 194 | 197 |
| 195 #ifndef FT_TRACE | 198 #ifndef FT_TRACE |
| 196 #define FT_TRACE( x ) do { } while ( 0 ) /* nothing */ | 199 #define FT_TRACE( x ) do { } while ( 0 ) /* nothing */ |
| 197 #define FT_TRACE1( x ) do { } while ( 0 ) /* nothing */ | 200 #define FT_TRACE1( x ) do { } while ( 0 ) /* nothing */ |
| 198 #define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */ | 201 #define FT_TRACE6( x ) do { } while ( 0 ) /* nothing */ |
| 199 #endif | 202 #endif |
| 200 | 203 |
| 204 #ifndef FT_THROW |
| 205 #define FT_THROW( e ) FT_ERR_CAT( Raster_Err_, e ) |
| 206 #endif |
| 207 |
| 201 #define Raster_Err_None 0 | 208 #define Raster_Err_None 0 |
| 202 #define Raster_Err_Not_Ini -1 | 209 #define Raster_Err_Not_Ini -1 |
| 203 #define Raster_Err_Overflow -2 | 210 #define Raster_Err_Overflow -2 |
| 204 #define Raster_Err_Neg_Height -3 | 211 #define Raster_Err_Neg_Height -3 |
| 205 #define Raster_Err_Invalid -4 | 212 #define Raster_Err_Invalid -4 |
| 206 #define Raster_Err_Unsupported -5 | 213 #define Raster_Err_Unsupported -5 |
| 207 | 214 |
| 208 #define ft_memset memset | 215 #define ft_memset memset |
| 209 | 216 |
| 210 #define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \ | 217 #define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, \ |
| 211 raster_reset_, raster_set_mode_, \ | 218 raster_reset_, raster_set_mode_, \ |
| 212 raster_render_, raster_done_ ) \ | 219 raster_render_, raster_done_ ) \ |
| 213 const FT_Raster_Funcs class_ = \ | 220 const FT_Raster_Funcs class_ = \ |
| 214 { \ | 221 { \ |
| 215 glyph_format_, \ | 222 glyph_format_, \ |
| 216 raster_new_, \ | 223 raster_new_, \ |
| 217 raster_reset_, \ | 224 raster_reset_, \ |
| 218 raster_set_mode_, \ | 225 raster_set_mode_, \ |
| 219 raster_render_, \ | 226 raster_render_, \ |
| 220 raster_done_ \ | 227 raster_done_ \ |
| 221 }; | 228 }; |
| 222 | 229 |
| 223 #else /* !_STANDALONE_ */ | 230 #else /* !_STANDALONE_ */ |
| 224 | 231 |
| 225 | 232 |
| 226 #include FT_INTERNAL_OBJECTS_H | 233 #include FT_INTERNAL_OBJECTS_H |
| 227 #include FT_INTERNAL_DEBUG_H /* for FT_TRACE() and FT_ERROR() */ | 234 #include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */ |
| 228 | 235 |
| 229 #include "rasterrs.h" | 236 #include "rasterrs.h" |
| 230 | 237 |
| 231 #define Raster_Err_None Raster_Err_Ok | 238 #define Raster_Err_None FT_Err_Ok |
| 232 #define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized | 239 #define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized |
| 233 #define Raster_Err_Overflow Raster_Err_Raster_Overflow | 240 #define Raster_Err_Overflow Raster_Err_Raster_Overflow |
| 234 #define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height | 241 #define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height |
| 235 #define Raster_Err_Invalid Raster_Err_Invalid_Outline | 242 #define Raster_Err_Invalid Raster_Err_Invalid_Outline |
| 236 #define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph | 243 #define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph |
| 237 | 244 |
| 238 | 245 |
| 239 #endif /* !_STANDALONE_ */ | 246 #endif /* !_STANDALONE_ */ |
| 240 | 247 |
| 241 | 248 |
| 242 #ifndef FT_MEM_SET | 249 #ifndef FT_MEM_SET |
| 243 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) | 250 #define FT_MEM_SET( d, s, c ) ft_memset( d, s, c ) |
| 244 #endif | 251 #endif |
| 245 | 252 |
| 246 #ifndef FT_MEM_ZERO | 253 #ifndef FT_MEM_ZERO |
| 247 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) | 254 #define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count ) |
| 248 #endif | 255 #endif |
| 249 | 256 |
| 250 /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */ | 257 /* FMulDiv means `Fast MulDiv'; it is used in case where `b' is */ |
| 251 /* typically a small value and the result of a*b is known to fit into */ | 258 /* typically a small value and the result of a*b is known to fit into */ |
| 252 /* 32 bits. */ | 259 /* 32 bits. */ |
| 253 #define FMulDiv( a, b, c ) ( (a) * (b) / (c) ) | 260 #define FMulDiv( a, b, c ) ( (a) * (b) / (c) ) |
| 254 | 261 |
| 255 /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */ | 262 /* On the other hand, SMulDiv means `Slow MulDiv', and is used typically */ |
| 256 /* for clipping computations. It simply uses the FT_MulDiv() function */ | 263 /* for clipping computations. It simply uses the FT_MulDiv() function */ |
| 257 /* defined in `ftcalc.h'. */ | 264 /* defined in `ftcalc.h'. */ |
| 258 #define SMulDiv FT_MulDiv | 265 #define SMulDiv FT_MulDiv |
| 266 #define SMulDiv_No_Round FT_MulDiv_No_Round |
| 259 | 267 |
| 260 /* The rasterizer is a very general purpose component; please leave */ | 268 /* The rasterizer is a very general purpose component; please leave */ |
| 261 /* the following redefinitions there (you never know your target */ | 269 /* the following redefinitions there (you never know your target */ |
| 262 /* environment). */ | 270 /* environment). */ |
| 263 | 271 |
| 264 #ifndef TRUE | 272 #ifndef TRUE |
| 265 #define TRUE 1 | 273 #define TRUE 1 |
| 266 #endif | 274 #endif |
| 267 | 275 |
| 268 #ifndef FALSE | 276 #ifndef FALSE |
| (...skipping 26 matching lines...) Expand all Loading... |
| 295 /** SIMPLE TYPE DECLARATIONS **/ | 303 /** SIMPLE TYPE DECLARATIONS **/ |
| 296 /** **/ | 304 /** **/ |
| 297 /*************************************************************************/ | 305 /*************************************************************************/ |
| 298 /*************************************************************************/ | 306 /*************************************************************************/ |
| 299 | 307 |
| 300 typedef int Int; | 308 typedef int Int; |
| 301 typedef unsigned int UInt; | 309 typedef unsigned int UInt; |
| 302 typedef short Short; | 310 typedef short Short; |
| 303 typedef unsigned short UShort, *PUShort; | 311 typedef unsigned short UShort, *PUShort; |
| 304 typedef long Long, *PLong; | 312 typedef long Long, *PLong; |
| 313 typedef unsigned long ULong; |
| 305 | 314 |
| 306 typedef unsigned char Byte, *PByte; | 315 typedef unsigned char Byte, *PByte; |
| 307 typedef char Bool; | 316 typedef char Bool; |
| 308 | 317 |
| 309 | 318 |
| 310 typedef union Alignment_ | 319 typedef union Alignment_ |
| 311 { | 320 { |
| 312 long l; | 321 long l; |
| 313 void* p; | 322 void* p; |
| 314 void (*f)(void); | 323 void (*f)(void); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 442 |
| 434 | 443 |
| 435 /* NOTE: These operations are only valid on 2's complement processors */ | 444 /* NOTE: These operations are only valid on 2's complement processors */ |
| 436 #undef FLOOR | 445 #undef FLOOR |
| 437 #undef CEILING | 446 #undef CEILING |
| 438 #undef TRUNC | 447 #undef TRUNC |
| 439 #undef SCALED | 448 #undef SCALED |
| 440 | 449 |
| 441 #define FLOOR( x ) ( (x) & -ras.precision ) | 450 #define FLOOR( x ) ( (x) & -ras.precision ) |
| 442 #define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision ) | 451 #define CEILING( x ) ( ( (x) + ras.precision - 1 ) & -ras.precision ) |
| 443 #define TRUNC( x ) ( (signed long)(x) >> ras.precision_bits ) | 452 #define TRUNC( x ) ( (Long)(x) >> ras.precision_bits ) |
| 444 #define FRAC( x ) ( (x) & ( ras.precision - 1 ) ) | 453 #define FRAC( x ) ( (x) & ( ras.precision - 1 ) ) |
| 445 #define SCALED( x ) ( ( (x) << ras.scale_shift ) - ras.precision_half ) | 454 #define SCALED( x ) ( ( (ULong)(x) << ras.scale_shift ) - ras.precision_half ) |
| 446 | 455 |
| 447 #define IS_BOTTOM_OVERSHOOT( x ) ( CEILING( x ) - x >= ras.precision_half ) | 456 #define IS_BOTTOM_OVERSHOOT( x ) ( CEILING( x ) - x >= ras.precision_half ) |
| 448 #define IS_TOP_OVERSHOOT( x ) ( x - FLOOR( x ) >= ras.precision_half ) | 457 #define IS_TOP_OVERSHOOT( x ) ( x - FLOOR( x ) >= ras.precision_half ) |
| 449 | 458 |
| 450 /* The most used variables are positioned at the top of the structure. */ | 459 /* The most used variables are positioned at the top of the structure. */ |
| 451 /* Thus, their offset can be coded with less opcodes, resulting in a */ | 460 /* Thus, their offset can be coded with less opcodes, resulting in a */ |
| 452 /* smaller executable. */ | 461 /* smaller executable. */ |
| 453 | 462 |
| 454 struct black_TWorker_ | 463 struct black_TWorker_ |
| 455 { | 464 { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 | 656 |
| 648 /*************************************************************************/ | 657 /*************************************************************************/ |
| 649 /* */ | 658 /* */ |
| 650 /* <Function> */ | 659 /* <Function> */ |
| 651 /* Set_High_Precision */ | 660 /* Set_High_Precision */ |
| 652 /* */ | 661 /* */ |
| 653 /* <Description> */ | 662 /* <Description> */ |
| 654 /* Set precision variables according to param flag. */ | 663 /* Set precision variables according to param flag. */ |
| 655 /* */ | 664 /* */ |
| 656 /* <Input> */ | 665 /* <Input> */ |
| 657 /* High :: Set to True for high precision (typically for ppem < 18), */ | 666 /* High :: Set to True for high precision (typically for ppem < 24), */ |
| 658 /* false otherwise. */ | 667 /* false otherwise. */ |
| 659 /* */ | 668 /* */ |
| 660 static void | 669 static void |
| 661 Set_High_Precision( RAS_ARGS Int High ) | 670 Set_High_Precision( RAS_ARGS Int High ) |
| 662 { | 671 { |
| 663 /* | 672 /* |
| 664 * `precision_step' is used in `Bezier_Up' to decide when to split a | 673 * `precision_step' is used in `Bezier_Up' to decide when to split a |
| 665 * given y-monotonous Bezier arc that crosses a scanline before | 674 * given y-monotonous Bezier arc that crosses a scanline before |
| 666 * approximating it as a straight segment. The default value of 32 (for | 675 * approximating it as a straight segment. The default value of 32 (for |
| 667 * low accuracy) corresponds to | 676 * low accuracy) corresponds to |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 { | 736 { |
| 728 if ( !ras.fProfile ) | 737 if ( !ras.fProfile ) |
| 729 { | 738 { |
| 730 ras.cProfile = (PProfile)ras.top; | 739 ras.cProfile = (PProfile)ras.top; |
| 731 ras.fProfile = ras.cProfile; | 740 ras.fProfile = ras.cProfile; |
| 732 ras.top += AlignProfileSize; | 741 ras.top += AlignProfileSize; |
| 733 } | 742 } |
| 734 | 743 |
| 735 if ( ras.top >= ras.maxBuff ) | 744 if ( ras.top >= ras.maxBuff ) |
| 736 { | 745 { |
| 737 ras.error = Raster_Err_Overflow; | 746 ras.error = FT_THROW( Overflow ); |
| 738 return FAILURE; | 747 return FAILURE; |
| 739 } | 748 } |
| 740 | 749 |
| 741 ras.cProfile->flags = 0; | 750 ras.cProfile->flags = 0; |
| 742 ras.cProfile->start = 0; | 751 ras.cProfile->start = 0; |
| 743 ras.cProfile->height = 0; | 752 ras.cProfile->height = 0; |
| 744 ras.cProfile->offset = ras.top; | 753 ras.cProfile->offset = ras.top; |
| 745 ras.cProfile->link = (PProfile)0; | 754 ras.cProfile->link = (PProfile)0; |
| 746 ras.cProfile->next = (PProfile)0; | 755 ras.cProfile->next = (PProfile)0; |
| 747 ras.cProfile->flags = ras.dropOutControl; | 756 ras.cProfile->flags = ras.dropOutControl; |
| 748 | 757 |
| 749 switch ( aState ) | 758 switch ( aState ) |
| 750 { | 759 { |
| 751 case Ascending_State: | 760 case Ascending_State: |
| 752 ras.cProfile->flags |= Flow_Up; | 761 ras.cProfile->flags |= Flow_Up; |
| 753 if ( overshoot ) | 762 if ( overshoot ) |
| 754 ras.cProfile->flags |= Overshoot_Bottom; | 763 ras.cProfile->flags |= Overshoot_Bottom; |
| 755 | 764 |
| 756 FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile )); | 765 FT_TRACE6(( "New ascending profile = %p\n", ras.cProfile )); |
| 757 break; | 766 break; |
| 758 | 767 |
| 759 case Descending_State: | 768 case Descending_State: |
| 760 if ( overshoot ) | 769 if ( overshoot ) |
| 761 ras.cProfile->flags |= Overshoot_Top; | 770 ras.cProfile->flags |= Overshoot_Top; |
| 762 FT_TRACE6(( "New descending profile = %p\n", ras.cProfile )); | 771 FT_TRACE6(( "New descending profile = %p\n", ras.cProfile )); |
| 763 break; | 772 break; |
| 764 | 773 |
| 765 default: | 774 default: |
| 766 FT_ERROR(( "New_Profile: invalid profile direction\n" )); | 775 FT_ERROR(( "New_Profile: invalid profile direction\n" )); |
| 767 ras.error = Raster_Err_Invalid; | 776 ras.error = FT_THROW( Invalid ); |
| 768 return FAILURE; | 777 return FAILURE; |
| 769 } | 778 } |
| 770 | 779 |
| 771 if ( !ras.gProfile ) | 780 if ( !ras.gProfile ) |
| 772 ras.gProfile = ras.cProfile; | 781 ras.gProfile = ras.cProfile; |
| 773 | 782 |
| 774 ras.state = aState; | 783 ras.state = aState; |
| 775 ras.fresh = TRUE; | 784 ras.fresh = TRUE; |
| 776 ras.joint = FALSE; | 785 ras.joint = FALSE; |
| 777 | 786 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 790 /* <Input> */ | 799 /* <Input> */ |
| 791 /* overshoot :: Whether the profile's unrounded end position differs */ | 800 /* overshoot :: Whether the profile's unrounded end position differs */ |
| 792 /* by at least a half pixel. */ | 801 /* by at least a half pixel. */ |
| 793 /* */ | 802 /* */ |
| 794 /* <Return> */ | 803 /* <Return> */ |
| 795 /* SUCCESS on success. FAILURE in case of overflow or incoherency. */ | 804 /* SUCCESS on success. FAILURE in case of overflow or incoherency. */ |
| 796 /* */ | 805 /* */ |
| 797 static Bool | 806 static Bool |
| 798 End_Profile( RAS_ARGS Bool overshoot ) | 807 End_Profile( RAS_ARGS Bool overshoot ) |
| 799 { | 808 { |
| 800 Long h; | 809 Long h; |
| 801 PProfile oldProfile; | |
| 802 | 810 |
| 803 | 811 |
| 804 h = (Long)( ras.top - ras.cProfile->offset ); | 812 h = (Long)( ras.top - ras.cProfile->offset ); |
| 805 | 813 |
| 806 if ( h < 0 ) | 814 if ( h < 0 ) |
| 807 { | 815 { |
| 808 FT_ERROR(( "End_Profile: negative height encountered\n" )); | 816 FT_ERROR(( "End_Profile: negative height encountered\n" )); |
| 809 ras.error = Raster_Err_Neg_Height; | 817 ras.error = FT_THROW( Neg_Height ); |
| 810 return FAILURE; | 818 return FAILURE; |
| 811 } | 819 } |
| 812 | 820 |
| 813 if ( h > 0 ) | 821 if ( h > 0 ) |
| 814 { | 822 { |
| 823 PProfile oldProfile; |
| 824 |
| 825 |
| 815 FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n", | 826 FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n", |
| 816 ras.cProfile, ras.cProfile->start, h )); | 827 ras.cProfile, ras.cProfile->start, h )); |
| 817 | 828 |
| 818 ras.cProfile->height = h; | 829 ras.cProfile->height = h; |
| 819 if ( overshoot ) | 830 if ( overshoot ) |
| 820 { | 831 { |
| 821 if ( ras.cProfile->flags & Flow_Up ) | 832 if ( ras.cProfile->flags & Flow_Up ) |
| 822 ras.cProfile->flags |= Overshoot_Top; | 833 ras.cProfile->flags |= Overshoot_Top; |
| 823 else | 834 else |
| 824 ras.cProfile->flags |= Overshoot_Bottom; | 835 ras.cProfile->flags |= Overshoot_Bottom; |
| 825 } | 836 } |
| 826 | 837 |
| 827 oldProfile = ras.cProfile; | 838 oldProfile = ras.cProfile; |
| 828 ras.cProfile = (PProfile)ras.top; | 839 ras.cProfile = (PProfile)ras.top; |
| 829 | 840 |
| 830 ras.top += AlignProfileSize; | 841 ras.top += AlignProfileSize; |
| 831 | 842 |
| 832 ras.cProfile->height = 0; | 843 ras.cProfile->height = 0; |
| 833 ras.cProfile->offset = ras.top; | 844 ras.cProfile->offset = ras.top; |
| 834 | 845 |
| 835 oldProfile->next = ras.cProfile; | 846 oldProfile->next = ras.cProfile; |
| 836 ras.num_Profs++; | 847 ras.num_Profs++; |
| 837 } | 848 } |
| 838 | 849 |
| 839 if ( ras.top >= ras.maxBuff ) | 850 if ( ras.top >= ras.maxBuff ) |
| 840 { | 851 { |
| 841 FT_TRACE1(( "overflow in End_Profile\n" )); | 852 FT_TRACE1(( "overflow in End_Profile\n" )); |
| 842 ras.error = Raster_Err_Overflow; | 853 ras.error = FT_THROW( Overflow ); |
| 843 return FAILURE; | 854 return FAILURE; |
| 844 } | 855 } |
| 845 | 856 |
| 846 ras.joint = FALSE; | 857 ras.joint = FALSE; |
| 847 | 858 |
| 848 return SUCCESS; | 859 return SUCCESS; |
| 849 } | 860 } |
| 850 | 861 |
| 851 | 862 |
| 852 /*************************************************************************/ | 863 /*************************************************************************/ |
| 853 /* */ | 864 /* */ |
| 854 /* <Function> */ | 865 /* <Function> */ |
| 855 /* Insert_Y_Turn */ | 866 /* Insert_Y_Turn */ |
| 856 /* */ | 867 /* */ |
| 857 /* <Description> */ | 868 /* <Description> */ |
| 858 /* Insert a salient into the sorted list placed on top of the render */ | 869 /* Insert a salient into the sorted list placed on top of the render */ |
| 859 /* pool. */ | 870 /* pool. */ |
| 860 /* */ | 871 /* */ |
| 861 /* <Input> */ | 872 /* <Input> */ |
| 862 /* New y scanline position. */ | 873 /* New y scanline position. */ |
| 863 /* */ | 874 /* */ |
| 864 /* <Return> */ | 875 /* <Return> */ |
| 865 /* SUCCESS on success. FAILURE in case of overflow. */ | 876 /* SUCCESS on success. FAILURE in case of overflow. */ |
| 866 /* */ | 877 /* */ |
| 867 static Bool | 878 static Bool |
| 868 Insert_Y_Turn( RAS_ARGS Int y ) | 879 Insert_Y_Turn( RAS_ARGS Int y ) |
| 869 { | 880 { |
| 870 PLong y_turns; | 881 PLong y_turns; |
| 871 Int y2, n; | 882 Int n; |
| 872 | 883 |
| 873 | 884 |
| 874 n = ras.numTurns - 1; | 885 n = ras.numTurns - 1; |
| 875 y_turns = ras.sizeBuff - ras.numTurns; | 886 y_turns = ras.sizeBuff - ras.numTurns; |
| 876 | 887 |
| 877 /* look for first y value that is <= */ | 888 /* look for first y value that is <= */ |
| 878 while ( n >= 0 && y < y_turns[n] ) | 889 while ( n >= 0 && y < y_turns[n] ) |
| 879 n--; | 890 n--; |
| 880 | 891 |
| 881 /* if it is <, simply insert it, ignore if == */ | 892 /* if it is <, simply insert it, ignore if == */ |
| 882 if ( n >= 0 && y > y_turns[n] ) | 893 if ( n >= 0 && y > y_turns[n] ) |
| 883 while ( n >= 0 ) | 894 while ( n >= 0 ) |
| 884 { | 895 { |
| 885 y2 = (Int)y_turns[n]; | 896 Int y2 = (Int)y_turns[n]; |
| 897 |
| 898 |
| 886 y_turns[n] = y; | 899 y_turns[n] = y; |
| 887 y = y2; | 900 y = y2; |
| 888 n--; | 901 n--; |
| 889 } | 902 } |
| 890 | 903 |
| 891 if ( n < 0 ) | 904 if ( n < 0 ) |
| 892 { | 905 { |
| 893 ras.maxBuff--; | 906 ras.maxBuff--; |
| 894 if ( ras.maxBuff <= ras.top ) | 907 if ( ras.maxBuff <= ras.top ) |
| 895 { | 908 { |
| 896 ras.error = Raster_Err_Overflow; | 909 ras.error = FT_THROW( Overflow ); |
| 897 return FAILURE; | 910 return FAILURE; |
| 898 } | 911 } |
| 899 ras.numTurns++; | 912 ras.numTurns++; |
| 900 ras.sizeBuff[-ras.numTurns] = y; | 913 ras.sizeBuff[-ras.numTurns] = y; |
| 901 } | 914 } |
| 902 | 915 |
| 903 return SUCCESS; | 916 return SUCCESS; |
| 904 } | 917 } |
| 905 | 918 |
| 906 | 919 |
| 907 /*************************************************************************/ | 920 /*************************************************************************/ |
| 908 /* */ | 921 /* */ |
| 909 /* <Function> */ | 922 /* <Function> */ |
| 910 /* Finalize_Profile_Table */ | 923 /* Finalize_Profile_Table */ |
| 911 /* */ | 924 /* */ |
| 912 /* <Description> */ | 925 /* <Description> */ |
| 913 /* Adjust all links in the profiles list. */ | 926 /* Adjust all links in the profiles list. */ |
| 914 /* */ | 927 /* */ |
| 915 /* <Return> */ | 928 /* <Return> */ |
| 916 /* SUCCESS on success. FAILURE in case of overflow. */ | 929 /* SUCCESS on success. FAILURE in case of overflow. */ |
| 917 /* */ | 930 /* */ |
| 918 static Bool | 931 static Bool |
| 919 Finalize_Profile_Table( RAS_ARG ) | 932 Finalize_Profile_Table( RAS_ARG ) |
| 920 { | 933 { |
| 921 Int bottom, top; | |
| 922 UShort n; | 934 UShort n; |
| 923 PProfile p; | 935 PProfile p; |
| 924 | 936 |
| 925 | 937 |
| 926 n = ras.num_Profs; | 938 n = ras.num_Profs; |
| 927 p = ras.fProfile; | 939 p = ras.fProfile; |
| 928 | 940 |
| 929 if ( n > 1 && p ) | 941 if ( n > 1 && p ) |
| 930 { | 942 { |
| 931 while ( n > 0 ) | 943 while ( n > 0 ) |
| 932 { | 944 { |
| 945 Int bottom, top; |
| 946 |
| 947 |
| 933 if ( n > 1 ) | 948 if ( n > 1 ) |
| 934 p->link = (PProfile)( p->offset + p->height ); | 949 p->link = (PProfile)( p->offset + p->height ); |
| 935 else | 950 else |
| 936 p->link = NULL; | 951 p->link = NULL; |
| 937 | 952 |
| 938 if ( p->flags & Flow_Up ) | 953 if ( p->flags & Flow_Up ) |
| 939 { | 954 { |
| 940 bottom = (Int)p->start; | 955 bottom = (Int)p->start; |
| 941 top = (Int)( p->start + p->height - 1 ); | 956 top = (Int)( p->start + p->height - 1 ); |
| 942 } | 957 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1137 | 1152 |
| 1138 if ( ras.fresh ) | 1153 if ( ras.fresh ) |
| 1139 { | 1154 { |
| 1140 ras.cProfile->start = e1; | 1155 ras.cProfile->start = e1; |
| 1141 ras.fresh = FALSE; | 1156 ras.fresh = FALSE; |
| 1142 } | 1157 } |
| 1143 | 1158 |
| 1144 size = e2 - e1 + 1; | 1159 size = e2 - e1 + 1; |
| 1145 if ( ras.top + size >= ras.maxBuff ) | 1160 if ( ras.top + size >= ras.maxBuff ) |
| 1146 { | 1161 { |
| 1147 ras.error = Raster_Err_Overflow; | 1162 ras.error = FT_THROW( Overflow ); |
| 1148 return FAILURE; | 1163 return FAILURE; |
| 1149 } | 1164 } |
| 1150 | 1165 |
| 1151 if ( Dx > 0 ) | 1166 if ( Dx > 0 ) |
| 1152 { | 1167 { |
| 1153 Ix = SMulDiv( ras.precision, Dx, Dy); | 1168 Ix = SMulDiv_No_Round( ras.precision, Dx, Dy ); |
| 1154 Rx = ( ras.precision * Dx ) % Dy; | 1169 Rx = ( ras.precision * Dx ) % Dy; |
| 1155 Dx = 1; | 1170 Dx = 1; |
| 1156 } | 1171 } |
| 1157 else | 1172 else |
| 1158 { | 1173 { |
| 1159 Ix = SMulDiv( ras.precision, -Dx, Dy) * -1; | 1174 Ix = -SMulDiv_No_Round( ras.precision, -Dx, Dy ); |
| 1160 Rx = ( ras.precision * -Dx ) % Dy; | 1175 Rx = ( ras.precision * -Dx ) % Dy; |
| 1161 Dx = -1; | 1176 Dx = -1; |
| 1162 } | 1177 } |
| 1163 | 1178 |
| 1164 Ax = -Dy; | 1179 Ax = -Dy; |
| 1165 top = ras.top; | 1180 top = ras.top; |
| 1166 | 1181 |
| 1167 while ( size > 0 ) | 1182 while ( size > 0 ) |
| 1168 { | 1183 { |
| 1169 *top++ = x1; | 1184 *top++ = x1; |
| 1170 | 1185 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1312 ras.cProfile->start = TRUNC( e0 ); | 1327 ras.cProfile->start = TRUNC( e0 ); |
| 1313 ras.fresh = FALSE; | 1328 ras.fresh = FALSE; |
| 1314 } | 1329 } |
| 1315 | 1330 |
| 1316 if ( e2 < e ) | 1331 if ( e2 < e ) |
| 1317 goto Fin; | 1332 goto Fin; |
| 1318 | 1333 |
| 1319 if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff ) | 1334 if ( ( top + TRUNC( e2 - e ) + 1 ) >= ras.maxBuff ) |
| 1320 { | 1335 { |
| 1321 ras.top = top; | 1336 ras.top = top; |
| 1322 ras.error = Raster_Err_Overflow; | 1337 ras.error = FT_THROW( Overflow ); |
| 1323 return FAILURE; | 1338 return FAILURE; |
| 1324 } | 1339 } |
| 1325 | 1340 |
| 1326 start_arc = arc; | 1341 start_arc = arc; |
| 1327 | 1342 |
| 1328 while ( arc >= start_arc && e <= e2 ) | 1343 while ( arc >= start_arc && e <= e2 ) |
| 1329 { | 1344 { |
| 1330 ras.joint = FALSE; | 1345 ras.joint = FALSE; |
| 1331 | 1346 |
| 1332 y2 = arc[0].y; | 1347 y2 = arc[0].y; |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 } | 2002 } |
| 1988 | 2003 |
| 1989 /* close the contour with a line segment */ | 2004 /* close the contour with a line segment */ |
| 1990 if ( Line_To( RAS_VARS v_start.x, v_start.y ) ) | 2005 if ( Line_To( RAS_VARS v_start.x, v_start.y ) ) |
| 1991 goto Fail; | 2006 goto Fail; |
| 1992 | 2007 |
| 1993 Close: | 2008 Close: |
| 1994 return SUCCESS; | 2009 return SUCCESS; |
| 1995 | 2010 |
| 1996 Invalid_Outline: | 2011 Invalid_Outline: |
| 1997 ras.error = Raster_Err_Invalid; | 2012 ras.error = FT_THROW( Invalid ); |
| 1998 | 2013 |
| 1999 Fail: | 2014 Fail: |
| 2000 return FAILURE; | 2015 return FAILURE; |
| 2001 } | 2016 } |
| 2002 | 2017 |
| 2003 | 2018 |
| 2004 /*************************************************************************/ | 2019 /*************************************************************************/ |
| 2005 /* */ | 2020 /* */ |
| 2006 /* <Function> */ | 2021 /* <Function> */ |
| 2007 /* Convert_Glyph */ | 2022 /* Convert_Glyph */ |
| 2008 /* */ | 2023 /* */ |
| 2009 /* <Description> */ | 2024 /* <Description> */ |
| 2010 /* Convert a glyph into a series of segments and arcs and make a */ | 2025 /* Convert a glyph into a series of segments and arcs and make a */ |
| 2011 /* profiles list with them. */ | 2026 /* profiles list with them. */ |
| 2012 /* */ | 2027 /* */ |
| 2013 /* <Input> */ | 2028 /* <Input> */ |
| 2014 /* flipped :: If set, flip the direction of curve. */ | 2029 /* flipped :: If set, flip the direction of curve. */ |
| 2015 /* */ | 2030 /* */ |
| 2016 /* <Return> */ | 2031 /* <Return> */ |
| 2017 /* SUCCESS on success, FAILURE if any error was encountered during */ | 2032 /* SUCCESS on success, FAILURE if any error was encountered during */ |
| 2018 /* rendering. */ | 2033 /* rendering. */ |
| 2019 /* */ | 2034 /* */ |
| 2020 static Bool | 2035 static Bool |
| 2021 Convert_Glyph( RAS_ARGS int flipped ) | 2036 Convert_Glyph( RAS_ARGS int flipped ) |
| 2022 { | 2037 { |
| 2023 int i; | 2038 int i; |
| 2024 unsigned start; | 2039 unsigned start; |
| 2025 | 2040 |
| 2026 PProfile lastProfile; | |
| 2027 | |
| 2028 | 2041 |
| 2029 ras.fProfile = NULL; | 2042 ras.fProfile = NULL; |
| 2030 ras.joint = FALSE; | 2043 ras.joint = FALSE; |
| 2031 ras.fresh = FALSE; | 2044 ras.fresh = FALSE; |
| 2032 | 2045 |
| 2033 ras.maxBuff = ras.sizeBuff - AlignProfileSize; | 2046 ras.maxBuff = ras.sizeBuff - AlignProfileSize; |
| 2034 | 2047 |
| 2035 ras.numTurns = 0; | 2048 ras.numTurns = 0; |
| 2036 | 2049 |
| 2037 ras.cProfile = (PProfile)ras.top; | 2050 ras.cProfile = (PProfile)ras.top; |
| 2038 ras.cProfile->offset = ras.top; | 2051 ras.cProfile->offset = ras.top; |
| 2039 ras.num_Profs = 0; | 2052 ras.num_Profs = 0; |
| 2040 | 2053 |
| 2041 start = 0; | 2054 start = 0; |
| 2042 | 2055 |
| 2043 for ( i = 0; i < ras.outline.n_contours; i++ ) | 2056 for ( i = 0; i < ras.outline.n_contours; i++ ) |
| 2044 { | 2057 { |
| 2045 Bool o; | 2058 PProfile lastProfile; |
| 2059 Bool o; |
| 2046 | 2060 |
| 2047 | 2061 |
| 2048 ras.state = Unknown_State; | 2062 ras.state = Unknown_State; |
| 2049 ras.gProfile = NULL; | 2063 ras.gProfile = NULL; |
| 2050 | 2064 |
| 2051 if ( Decompose_Curve( RAS_VARS (unsigned short)start, | 2065 if ( Decompose_Curve( RAS_VARS (unsigned short)start, |
| 2052 ras.outline.contours[i], | 2066 ras.outline.contours[i], |
| 2053 flipped ) ) | 2067 flipped ) ) |
| 2054 return FAILURE; | 2068 return FAILURE; |
| 2055 | 2069 |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2259 | 2273 |
| 2260 | 2274 |
| 2261 static void | 2275 static void |
| 2262 Vertical_Sweep_Span( RAS_ARGS Short y, | 2276 Vertical_Sweep_Span( RAS_ARGS Short y, |
| 2263 FT_F26Dot6 x1, | 2277 FT_F26Dot6 x1, |
| 2264 FT_F26Dot6 x2, | 2278 FT_F26Dot6 x2, |
| 2265 PProfile left, | 2279 PProfile left, |
| 2266 PProfile right ) | 2280 PProfile right ) |
| 2267 { | 2281 { |
| 2268 Long e1, e2; | 2282 Long e1, e2; |
| 2269 int c1, c2; | |
| 2270 Byte f1, f2; | |
| 2271 Byte* target; | 2283 Byte* target; |
| 2272 | 2284 |
| 2273 FT_UNUSED( y ); | 2285 FT_UNUSED( y ); |
| 2274 FT_UNUSED( left ); | 2286 FT_UNUSED( left ); |
| 2275 FT_UNUSED( right ); | 2287 FT_UNUSED( right ); |
| 2276 | 2288 |
| 2277 | 2289 |
| 2278 /* Drop-out control */ | 2290 /* Drop-out control */ |
| 2279 | 2291 |
| 2280 e1 = TRUNC( CEILING( x1 ) ); | 2292 e1 = TRUNC( CEILING( x1 ) ); |
| 2281 | 2293 |
| 2282 if ( x2 - x1 - ras.precision <= ras.precision_jitter ) | 2294 if ( x2 - x1 - ras.precision <= ras.precision_jitter ) |
| 2283 e2 = e1; | 2295 e2 = e1; |
| 2284 else | 2296 else |
| 2285 e2 = TRUNC( FLOOR( x2 ) ); | 2297 e2 = TRUNC( FLOOR( x2 ) ); |
| 2286 | 2298 |
| 2287 if ( e2 >= 0 && e1 < ras.bWidth ) | 2299 if ( e2 >= 0 && e1 < ras.bWidth ) |
| 2288 { | 2300 { |
| 2301 int c1, c2; |
| 2302 Byte f1, f2; |
| 2303 |
| 2304 |
| 2289 if ( e1 < 0 ) | 2305 if ( e1 < 0 ) |
| 2290 e1 = 0; | 2306 e1 = 0; |
| 2291 if ( e2 >= ras.bWidth ) | 2307 if ( e2 >= ras.bWidth ) |
| 2292 e2 = ras.bWidth - 1; | 2308 e2 = ras.bWidth - 1; |
| 2293 | 2309 |
| 2294 c1 = (Short)( e1 >> 3 ); | 2310 c1 = (Short)( e1 >> 3 ); |
| 2295 c2 = (Short)( e2 >> 3 ); | 2311 c2 = (Short)( e2 >> 3 ); |
| 2296 | 2312 |
| 2297 f1 = (Byte) ( 0xFF >> ( e1 & 7 ) ); | 2313 f1 = (Byte) ( 0xFF >> ( e1 & 7 ) ); |
| 2298 f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) ); | 2314 f2 = (Byte) ~( 0x7F >> ( e2 & 7 ) ); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2502 } | 2518 } |
| 2503 | 2519 |
| 2504 | 2520 |
| 2505 static void | 2521 static void |
| 2506 Horizontal_Sweep_Span( RAS_ARGS Short y, | 2522 Horizontal_Sweep_Span( RAS_ARGS Short y, |
| 2507 FT_F26Dot6 x1, | 2523 FT_F26Dot6 x1, |
| 2508 FT_F26Dot6 x2, | 2524 FT_F26Dot6 x2, |
| 2509 PProfile left, | 2525 PProfile left, |
| 2510 PProfile right ) | 2526 PProfile right ) |
| 2511 { | 2527 { |
| 2512 Long e1, e2; | |
| 2513 PByte bits; | |
| 2514 Byte f1; | |
| 2515 | |
| 2516 FT_UNUSED( left ); | 2528 FT_UNUSED( left ); |
| 2517 FT_UNUSED( right ); | 2529 FT_UNUSED( right ); |
| 2518 | 2530 |
| 2519 | 2531 |
| 2520 if ( x2 - x1 < ras.precision ) | 2532 if ( x2 - x1 < ras.precision ) |
| 2521 { | 2533 { |
| 2534 Long e1, e2; |
| 2535 |
| 2536 |
| 2522 e1 = CEILING( x1 ); | 2537 e1 = CEILING( x1 ); |
| 2523 e2 = FLOOR ( x2 ); | 2538 e2 = FLOOR ( x2 ); |
| 2524 | 2539 |
| 2525 if ( e1 == e2 ) | 2540 if ( e1 == e2 ) |
| 2526 { | 2541 { |
| 2542 Byte f1; |
| 2543 PByte bits; |
| 2544 |
| 2545 |
| 2527 bits = ras.bTarget + ( y >> 3 ); | 2546 bits = ras.bTarget + ( y >> 3 ); |
| 2528 f1 = (Byte)( 0x80 >> ( y & 7 ) ); | 2547 f1 = (Byte)( 0x80 >> ( y & 7 ) ); |
| 2529 | 2548 |
| 2530 e1 = TRUNC( e1 ); | 2549 e1 = TRUNC( e1 ); |
| 2531 | 2550 |
| 2532 if ( e1 >= 0 && e1 < ras.target.rows ) | 2551 if ( e1 >= 0 && e1 < ras.target.rows ) |
| 2533 { | 2552 { |
| 2534 PByte p; | 2553 PByte p; |
| 2535 | 2554 |
| 2536 | 2555 |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 } | 2732 } |
| 2714 | 2733 |
| 2715 ras.gray_min_x = (Short)byte_len; | 2734 ras.gray_min_x = (Short)byte_len; |
| 2716 ras.gray_max_x = -(Short)byte_len; | 2735 ras.gray_max_x = -(Short)byte_len; |
| 2717 } | 2736 } |
| 2718 | 2737 |
| 2719 | 2738 |
| 2720 static void | 2739 static void |
| 2721 Vertical_Gray_Sweep_Step( RAS_ARG ) | 2740 Vertical_Gray_Sweep_Step( RAS_ARG ) |
| 2722 { | 2741 { |
| 2723 Int c1, c2; | |
| 2724 PByte pix, bit, bit2; | |
| 2725 short* count = (short*)count_table; | 2742 short* count = (short*)count_table; |
| 2726 Byte* grays; | 2743 Byte* grays; |
| 2727 | 2744 |
| 2728 | 2745 |
| 2729 ras.traceOfs += ras.gray_width; | 2746 ras.traceOfs += ras.gray_width; |
| 2730 | 2747 |
| 2731 if ( ras.traceOfs > ras.gray_width ) | 2748 if ( ras.traceOfs > ras.gray_width ) |
| 2732 { | 2749 { |
| 2750 PByte pix; |
| 2751 |
| 2752 |
| 2733 pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4; | 2753 pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4; |
| 2734 grays = ras.grays; | 2754 grays = ras.grays; |
| 2735 | 2755 |
| 2736 if ( ras.gray_max_x >= 0 ) | 2756 if ( ras.gray_max_x >= 0 ) |
| 2737 { | 2757 { |
| 2738 Long last_pixel = ras.target.width - 1; | 2758 Long last_pixel = ras.target.width - 1; |
| 2739 Int last_cell = last_pixel >> 2; | 2759 Int last_cell = last_pixel >> 2; |
| 2740 Int last_bit = last_pixel & 3; | 2760 Int last_bit = last_pixel & 3; |
| 2741 Bool over = 0; | 2761 Bool over = 0; |
| 2742 | 2762 |
| 2763 Int c1, c2; |
| 2764 PByte bit, bit2; |
| 2765 |
| 2743 | 2766 |
| 2744 if ( ras.gray_max_x >= last_cell && last_bit != 3 ) | 2767 if ( ras.gray_max_x >= last_cell && last_bit != 3 ) |
| 2745 { | 2768 { |
| 2746 ras.gray_max_x = last_cell - 1; | 2769 ras.gray_max_x = last_cell - 1; |
| 2747 over = 1; | 2770 over = 1; |
| 2748 } | 2771 } |
| 2749 | 2772 |
| 2750 if ( ras.gray_min_x < 0 ) | 2773 if ( ras.gray_min_x < 0 ) |
| 2751 ras.gray_min_x = 0; | 2774 ras.gray_min_x = 0; |
| 2752 | 2775 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2825 | 2848 |
| 2826 static void | 2849 static void |
| 2827 Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y, | 2850 Horizontal_Gray_Sweep_Drop( RAS_ARGS Short y, |
| 2828 FT_F26Dot6 x1, | 2851 FT_F26Dot6 x1, |
| 2829 FT_F26Dot6 x2, | 2852 FT_F26Dot6 x2, |
| 2830 PProfile left, | 2853 PProfile left, |
| 2831 PProfile right ) | 2854 PProfile right ) |
| 2832 { | 2855 { |
| 2833 Long e1, e2; | 2856 Long e1, e2; |
| 2834 PByte pixel; | 2857 PByte pixel; |
| 2835 Byte color; | |
| 2836 | 2858 |
| 2837 | 2859 |
| 2838 /* During the horizontal sweep, we only take care of drop-outs */ | 2860 /* During the horizontal sweep, we only take care of drop-outs */ |
| 2839 | 2861 |
| 2840 e1 = CEILING( x1 ); | 2862 e1 = CEILING( x1 ); |
| 2841 e2 = FLOOR ( x2 ); | 2863 e2 = FLOOR ( x2 ); |
| 2842 | 2864 |
| 2843 if ( e1 > e2 ) | 2865 if ( e1 > e2 ) |
| 2844 { | 2866 { |
| 2845 Int dropOutControl = left->flags & 7; | 2867 Int dropOutControl = left->flags & 7; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 default: /* modes 2, 3, 6, 7 */ | 2901 default: /* modes 2, 3, 6, 7 */ |
| 2880 return; /* no drop-out control */ | 2902 return; /* no drop-out control */ |
| 2881 } | 2903 } |
| 2882 } | 2904 } |
| 2883 else | 2905 else |
| 2884 return; | 2906 return; |
| 2885 } | 2907 } |
| 2886 | 2908 |
| 2887 if ( e1 >= 0 ) | 2909 if ( e1 >= 0 ) |
| 2888 { | 2910 { |
| 2911 Byte color; |
| 2912 |
| 2913 |
| 2889 if ( x2 - x1 >= ras.precision_half ) | 2914 if ( x2 - x1 >= ras.precision_half ) |
| 2890 color = ras.grays[2]; | 2915 color = ras.grays[2]; |
| 2891 else | 2916 else |
| 2892 color = ras.grays[1]; | 2917 color = ras.grays[1]; |
| 2893 | 2918 |
| 2894 e1 = TRUNC( e1 ) / 2; | 2919 e1 = TRUNC( e1 ) / 2; |
| 2895 if ( e1 < ras.target.rows ) | 2920 if ( e1 < ras.target.rows ) |
| 2896 { | 2921 { |
| 2897 pixel = ras.gTarget - e1 * ras.target.pitch + y / 2; | 2922 pixel = ras.gTarget - e1 * ras.target.pitch + y / 2; |
| 2898 if ( ras.target.pitch > 0 ) | 2923 if ( ras.target.pitch > 0 ) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2956 | 2981 |
| 2957 P->X = 0; | 2982 P->X = 0; |
| 2958 InsNew( &waiting, P ); | 2983 InsNew( &waiting, P ); |
| 2959 | 2984 |
| 2960 P = Q; | 2985 P = Q; |
| 2961 } | 2986 } |
| 2962 | 2987 |
| 2963 /* check the Y-turns */ | 2988 /* check the Y-turns */ |
| 2964 if ( ras.numTurns == 0 ) | 2989 if ( ras.numTurns == 0 ) |
| 2965 { | 2990 { |
| 2966 ras.error = Raster_Err_Invalid; | 2991 ras.error = FT_THROW( Invalid ); |
| 2967 return FAILURE; | 2992 return FAILURE; |
| 2968 } | 2993 } |
| 2969 | 2994 |
| 2970 /* now initialize the sweep */ | 2995 /* now initialize the sweep */ |
| 2971 | 2996 |
| 2972 ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); | 2997 ras.Proc_Sweep_Init( RAS_VARS &min_Y, &max_Y ); |
| 2973 | 2998 |
| 2974 /* then compute the distance of each profile from min_Y */ | 2999 /* then compute the distance of each profile from min_Y */ |
| 2975 | 3000 |
| 2976 P = waiting; | 3001 P = waiting; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3197 #endif | 3222 #endif |
| 3198 | 3223 |
| 3199 i = ras.band_stack[ras.band_top].y_min; | 3224 i = ras.band_stack[ras.band_top].y_min; |
| 3200 j = ras.band_stack[ras.band_top].y_max; | 3225 j = ras.band_stack[ras.band_top].y_max; |
| 3201 | 3226 |
| 3202 k = (Short)( ( i + j ) / 2 ); | 3227 k = (Short)( ( i + j ) / 2 ); |
| 3203 | 3228 |
| 3204 if ( ras.band_top >= 7 || k < i ) | 3229 if ( ras.band_top >= 7 || k < i ) |
| 3205 { | 3230 { |
| 3206 ras.band_top = 0; | 3231 ras.band_top = 0; |
| 3207 ras.error = Raster_Err_Invalid; | 3232 ras.error = FT_THROW( Invalid ); |
| 3208 | 3233 |
| 3209 return ras.error; | 3234 return ras.error; |
| 3210 } | 3235 } |
| 3211 | 3236 |
| 3212 ras.band_stack[ras.band_top + 1].y_min = k; | 3237 ras.band_stack[ras.band_top + 1].y_min = k; |
| 3213 ras.band_stack[ras.band_top + 1].y_max = j; | 3238 ras.band_stack[ras.band_top + 1].y_max = j; |
| 3214 | 3239 |
| 3215 ras.band_stack[ras.band_top].y_max = (Short)( k - 1 ); | 3240 ras.band_stack[ras.band_top].y_max = (Short)( k - 1 ); |
| 3216 | 3241 |
| 3217 ras.band_top++; | 3242 ras.band_top++; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3386 return Raster_Err_None; | 3411 return Raster_Err_None; |
| 3387 } | 3412 } |
| 3388 | 3413 |
| 3389 #else /* !FT_RASTER_OPTION_ANTI_ALIASING */ | 3414 #else /* !FT_RASTER_OPTION_ANTI_ALIASING */ |
| 3390 | 3415 |
| 3391 FT_LOCAL_DEF( FT_Error ) | 3416 FT_LOCAL_DEF( FT_Error ) |
| 3392 Render_Gray_Glyph( RAS_ARG ) | 3417 Render_Gray_Glyph( RAS_ARG ) |
| 3393 { | 3418 { |
| 3394 FT_UNUSED_RASTER; | 3419 FT_UNUSED_RASTER; |
| 3395 | 3420 |
| 3396 return Raster_Err_Unsupported; | 3421 return FT_THROW( Unsupported ); |
| 3397 } | 3422 } |
| 3398 | 3423 |
| 3399 #endif /* !FT_RASTER_OPTION_ANTI_ALIASING */ | 3424 #endif /* !FT_RASTER_OPTION_ANTI_ALIASING */ |
| 3400 | 3425 |
| 3401 | 3426 |
| 3402 static void | 3427 static void |
| 3403 ft_black_init( black_PRaster raster ) | 3428 ft_black_init( black_PRaster raster ) |
| 3404 { | 3429 { |
| 3405 #ifdef FT_RASTER_OPTION_ANTI_ALIASING | 3430 #ifdef FT_RASTER_OPTION_ANTI_ALIASING |
| 3406 FT_UInt n; | 3431 FT_UInt n; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3491 long pool_size ) | 3516 long pool_size ) |
| 3492 { | 3517 { |
| 3493 if ( raster ) | 3518 if ( raster ) |
| 3494 { | 3519 { |
| 3495 if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 ) | 3520 if ( pool_base && pool_size >= (long)sizeof ( black_TWorker ) + 2048 ) |
| 3496 { | 3521 { |
| 3497 black_PWorker worker = (black_PWorker)pool_base; | 3522 black_PWorker worker = (black_PWorker)pool_base; |
| 3498 | 3523 |
| 3499 | 3524 |
| 3500 raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 ); | 3525 raster->buffer = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 ); |
| 3501 raster->buffer_size = pool_base + pool_size - (char*)raster->buffer; | 3526 raster->buffer_size = (long)( pool_base + pool_size - |
| 3527 (char*)raster->buffer ); |
| 3502 raster->worker = worker; | 3528 raster->worker = worker; |
| 3503 } | 3529 } |
| 3504 else | 3530 else |
| 3505 { | 3531 { |
| 3506 raster->buffer = NULL; | 3532 raster->buffer = NULL; |
| 3507 raster->buffer_size = 0; | 3533 raster->buffer_size = 0; |
| 3508 raster->worker = NULL; | 3534 raster->worker = NULL; |
| 3509 } | 3535 } |
| 3510 } | 3536 } |
| 3511 } | 3537 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3541 static int | 3567 static int |
| 3542 ft_black_render( black_PRaster raster, | 3568 ft_black_render( black_PRaster raster, |
| 3543 const FT_Raster_Params* params ) | 3569 const FT_Raster_Params* params ) |
| 3544 { | 3570 { |
| 3545 const FT_Outline* outline = (const FT_Outline*)params->source; | 3571 const FT_Outline* outline = (const FT_Outline*)params->source; |
| 3546 const FT_Bitmap* target_map = params->target; | 3572 const FT_Bitmap* target_map = params->target; |
| 3547 black_PWorker worker; | 3573 black_PWorker worker; |
| 3548 | 3574 |
| 3549 | 3575 |
| 3550 if ( !raster || !raster->buffer || !raster->buffer_size ) | 3576 if ( !raster || !raster->buffer || !raster->buffer_size ) |
| 3551 return Raster_Err_Not_Ini; | 3577 return FT_THROW( Not_Ini ); |
| 3552 | 3578 |
| 3553 if ( !outline ) | 3579 if ( !outline ) |
| 3554 return Raster_Err_Invalid; | 3580 return FT_THROW( Invalid ); |
| 3555 | 3581 |
| 3556 /* return immediately if the outline is empty */ | 3582 /* return immediately if the outline is empty */ |
| 3557 if ( outline->n_points == 0 || outline->n_contours <= 0 ) | 3583 if ( outline->n_points == 0 || outline->n_contours <= 0 ) |
| 3558 return Raster_Err_None; | 3584 return Raster_Err_None; |
| 3559 | 3585 |
| 3560 if ( !outline->contours || !outline->points ) | 3586 if ( !outline->contours || !outline->points ) |
| 3561 return Raster_Err_Invalid; | 3587 return FT_THROW( Invalid ); |
| 3562 | 3588 |
| 3563 if ( outline->n_points != | 3589 if ( outline->n_points != |
| 3564 outline->contours[outline->n_contours - 1] + 1 ) | 3590 outline->contours[outline->n_contours - 1] + 1 ) |
| 3565 return Raster_Err_Invalid; | 3591 return FT_THROW( Invalid ); |
| 3566 | 3592 |
| 3567 worker = raster->worker; | 3593 worker = raster->worker; |
| 3568 | 3594 |
| 3569 /* this version of the raster does not support direct rendering, sorry */ | 3595 /* this version of the raster does not support direct rendering, sorry */ |
| 3570 if ( params->flags & FT_RASTER_FLAG_DIRECT ) | 3596 if ( params->flags & FT_RASTER_FLAG_DIRECT ) |
| 3571 return Raster_Err_Unsupported; | 3597 return FT_THROW( Unsupported ); |
| 3572 | 3598 |
| 3573 if ( !target_map ) | 3599 if ( !target_map ) |
| 3574 return Raster_Err_Invalid; | 3600 return FT_THROW( Invalid ); |
| 3575 | 3601 |
| 3576 /* nothing to do */ | 3602 /* nothing to do */ |
| 3577 if ( !target_map->width || !target_map->rows ) | 3603 if ( !target_map->width || !target_map->rows ) |
| 3578 return Raster_Err_None; | 3604 return Raster_Err_None; |
| 3579 | 3605 |
| 3580 if ( !target_map->buffer ) | 3606 if ( !target_map->buffer ) |
| 3581 return Raster_Err_Invalid; | 3607 return FT_THROW( Invalid ); |
| 3582 | 3608 |
| 3583 ras.outline = *outline; | 3609 ras.outline = *outline; |
| 3584 ras.target = *target_map; | 3610 ras.target = *target_map; |
| 3585 | 3611 |
| 3586 worker->buff = (PLong) raster->buffer; | 3612 worker->buff = (PLong) raster->buffer; |
| 3587 worker->sizeBuff = worker->buff + | 3613 worker->sizeBuff = worker->buff + |
| 3588 raster->buffer_size / sizeof ( Long ); | 3614 raster->buffer_size / sizeof ( Long ); |
| 3589 #ifdef FT_RASTER_OPTION_ANTI_ALIASING | 3615 #ifdef FT_RASTER_OPTION_ANTI_ALIASING |
| 3590 worker->grays = raster->grays; | 3616 worker->grays = raster->grays; |
| 3591 worker->gray_width = raster->gray_width; | 3617 worker->gray_width = raster->gray_width; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 3603 FT_GLYPH_FORMAT_OUTLINE, | 3629 FT_GLYPH_FORMAT_OUTLINE, |
| 3604 (FT_Raster_New_Func) ft_black_new, | 3630 (FT_Raster_New_Func) ft_black_new, |
| 3605 (FT_Raster_Reset_Func) ft_black_reset, | 3631 (FT_Raster_Reset_Func) ft_black_reset, |
| 3606 (FT_Raster_Set_Mode_Func)ft_black_set_mode, | 3632 (FT_Raster_Set_Mode_Func)ft_black_set_mode, |
| 3607 (FT_Raster_Render_Func) ft_black_render, | 3633 (FT_Raster_Render_Func) ft_black_render, |
| 3608 (FT_Raster_Done_Func) ft_black_done | 3634 (FT_Raster_Done_Func) ft_black_done |
| 3609 ) | 3635 ) |
| 3610 | 3636 |
| 3611 | 3637 |
| 3612 /* END */ | 3638 /* END */ |
| OLD | NEW |