| 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-2013 by */ | 7 /* Copyright 1996-2003, 2005, 2007-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 `ftimage.h' and `ftmisc.h' into the $(incdir) */ | 22 /* put the files `ftimage.h' and `ftmisc.h' into the $(incdir) */ |
| 23 /* directory. Typically, you should do something like */ | 23 /* directory. Typically, you should do something like */ |
| 24 /* */ | 24 /* */ |
| 25 /* - copy `src/raster/ftraster.c' (this file) to your current directory */ | 25 /* - copy `src/raster/ftraster.c' (this file) to your current directory */ |
| 26 /* */ | 26 /* */ |
| 27 /* - copy `include/freetype/ftimage.h' and `src/raster/ftmisc.h' */ | 27 /* - copy `include/ftimage.h' and `src/raster/ftmisc.h' to your current */ |
| 28 /* to your current directory */ | 28 /* directory */ |
| 29 /* */ | 29 /* */ |
| 30 /* - compile `ftraster' with the _STANDALONE_ macro defined, as in */ | 30 /* - compile `ftraster' with the _STANDALONE_ macro defined, as in */ |
| 31 /* */ | 31 /* */ |
| 32 /* cc -c -D_STANDALONE_ ftraster.c */ | 32 /* cc -c -D_STANDALONE_ ftraster.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_standard_raster.raster_new'; a bitmap can be generated */ | 35 /* `ft_standard_raster.raster_new'; a bitmap can be generated */ |
| 36 /* with a call to `ft_standard_raster.raster_render'. */ | 36 /* with a call to `ft_standard_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 12 matching lines...) Expand all Loading... |
| 51 | 51 |
| 52 #define FT_CONFIG_STANDARD_LIBRARY_H <stdlib.h> | 52 #define FT_CONFIG_STANDARD_LIBRARY_H <stdlib.h> |
| 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 "../../include/ft2build.h" | 61 #include <ft2build.h> |
| 62 #include "ftraster.h" | 62 #include "ftraster.h" |
| 63 #include "../../include/freetype/internal/ftcalc.h" /* for FT_MulDiv and FT_Mu
lDiv_No_Round */ | 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 raster_new_, \ | 223 raster_new_, \ |
| 224 raster_reset_, \ | 224 raster_reset_, \ |
| 225 raster_set_mode_, \ | 225 raster_set_mode_, \ |
| 226 raster_render_, \ | 226 raster_render_, \ |
| 227 raster_done_ \ | 227 raster_done_ \ |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 #else /* !_STANDALONE_ */ | 230 #else /* !_STANDALONE_ */ |
| 231 | 231 |
| 232 | 232 |
| 233 #include "../../include/freetype/internal/ftobjs.h" | 233 #include FT_INTERNAL_OBJECTS_H |
| 234 #include "../../include/freetype/internal/ftdebug.h" /* for FT_TRACE, FT_E
RROR, and FT_THROW */ | 234 #include FT_INTERNAL_DEBUG_H /* for FT_TRACE, FT_ERROR, and FT_THROW */ |
| 235 | 235 |
| 236 #include "rasterrs.h" | 236 #include "rasterrs.h" |
| 237 | 237 |
| 238 #define Raster_Err_None FT_Err_Ok | 238 #define Raster_Err_None FT_Err_Ok |
| 239 #define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized | 239 #define Raster_Err_Not_Ini Raster_Err_Raster_Uninitialized |
| 240 #define Raster_Err_Overflow Raster_Err_Raster_Overflow | 240 #define Raster_Err_Overflow Raster_Err_Raster_Overflow |
| 241 #define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height | 241 #define Raster_Err_Neg_Height Raster_Err_Raster_Negative_Height |
| 242 #define Raster_Err_Invalid Raster_Err_Invalid_Outline | 242 #define Raster_Err_Invalid Raster_Err_Invalid_Outline |
| 243 #define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph | 243 #define Raster_Err_Unsupported Raster_Err_Cannot_Render_Glyph |
| 244 | 244 |
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 limit--; | 1867 limit--; |
| 1868 } | 1868 } |
| 1869 else | 1869 else |
| 1870 { | 1870 { |
| 1871 /* if both first and last points are conic, */ | 1871 /* if both first and last points are conic, */ |
| 1872 /* start at their middle and record its position */ | 1872 /* start at their middle and record its position */ |
| 1873 /* for closure */ | 1873 /* for closure */ |
| 1874 v_start.x = ( v_start.x + v_last.x ) / 2; | 1874 v_start.x = ( v_start.x + v_last.x ) / 2; |
| 1875 v_start.y = ( v_start.y + v_last.y ) / 2; | 1875 v_start.y = ( v_start.y + v_last.y ) / 2; |
| 1876 | 1876 |
| 1877 v_last = v_start; | 1877 /* v_last = v_start; */ |
| 1878 } | 1878 } |
| 1879 point--; | 1879 point--; |
| 1880 tags--; | 1880 tags--; |
| 1881 } | 1881 } |
| 1882 | 1882 |
| 1883 ras.lastX = v_start.x; | 1883 ras.lastX = v_start.x; |
| 1884 ras.lastY = v_start.y; | 1884 ras.lastY = v_start.y; |
| 1885 | 1885 |
| 1886 while ( point < limit ) | 1886 while ( point < limit ) |
| 1887 { | 1887 { |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2277 static void | 2277 static void |
| 2278 Vertical_Sweep_Span( RAS_ARGS Short y, | 2278 Vertical_Sweep_Span( RAS_ARGS Short y, |
| 2279 FT_F26Dot6 x1, | 2279 FT_F26Dot6 x1, |
| 2280 FT_F26Dot6 x2, | 2280 FT_F26Dot6 x2, |
| 2281 PProfile left, | 2281 PProfile left, |
| 2282 PProfile right ) | 2282 PProfile right ) |
| 2283 { | 2283 { |
| 2284 Long e1, e2; | 2284 Long e1, e2; |
| 2285 Byte* target; | 2285 Byte* target; |
| 2286 | 2286 |
| 2287 Int dropOutControl = left->flags & 7; |
| 2288 |
| 2287 FT_UNUSED( y ); | 2289 FT_UNUSED( y ); |
| 2288 FT_UNUSED( left ); | 2290 FT_UNUSED( left ); |
| 2289 FT_UNUSED( right ); | 2291 FT_UNUSED( right ); |
| 2290 | 2292 |
| 2291 | 2293 |
| 2292 /* Drop-out control */ | 2294 /* Drop-out control */ |
| 2293 | 2295 |
| 2294 e1 = TRUNC( CEILING( x1 ) ); | 2296 e1 = TRUNC( CEILING( x1 ) ); |
| 2295 | 2297 |
| 2296 if ( x2 - x1 - ras.precision <= ras.precision_jitter ) | 2298 if ( dropOutControl != 2 && |
| 2299 x2 - x1 - ras.precision <= ras.precision_jitter ) |
| 2297 e2 = e1; | 2300 e2 = e1; |
| 2298 else | 2301 else |
| 2299 e2 = TRUNC( FLOOR( x2 ) ); | 2302 e2 = TRUNC( FLOOR( x2 ) ); |
| 2300 | 2303 |
| 2301 if ( e2 >= 0 && e1 < ras.bWidth ) | 2304 if ( e2 >= 0 && e1 < ras.bWidth ) |
| 2302 { | 2305 { |
| 2303 int c1, c2; | 2306 int c1, c2; |
| 2304 Byte f1, f2; | 2307 Byte f1, f2; |
| 2305 | 2308 |
| 2306 | 2309 |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 { | 2546 { |
| 2544 Byte f1; | 2547 Byte f1; |
| 2545 PByte bits; | 2548 PByte bits; |
| 2546 | 2549 |
| 2547 | 2550 |
| 2548 bits = ras.bTarget + ( y >> 3 ); | 2551 bits = ras.bTarget + ( y >> 3 ); |
| 2549 f1 = (Byte)( 0x80 >> ( y & 7 ) ); | 2552 f1 = (Byte)( 0x80 >> ( y & 7 ) ); |
| 2550 | 2553 |
| 2551 e1 = TRUNC( e1 ); | 2554 e1 = TRUNC( e1 ); |
| 2552 | 2555 |
| 2553 if ( e1 >= 0 && e1 < ras.target.rows ) | 2556 if ( e1 >= 0 && (ULong)e1 < ras.target.rows ) |
| 2554 { | 2557 { |
| 2555 PByte p; | 2558 PByte p; |
| 2556 | 2559 |
| 2557 | 2560 |
| 2558 p = bits - e1 * ras.target.pitch; | 2561 p = bits - e1 * ras.target.pitch; |
| 2559 if ( ras.target.pitch > 0 ) | 2562 if ( ras.target.pitch > 0 ) |
| 2560 p += ( ras.target.rows - 1 ) * ras.target.pitch; | 2563 p += ( ras.target.rows - 1 ) * ras.target.pitch; |
| 2561 | 2564 |
| 2562 p[0] |= f1; | 2565 p[0] |= f1; |
| 2563 } | 2566 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2637 | 2640 |
| 2638 default: /* modes 2, 3, 6, 7 */ | 2641 default: /* modes 2, 3, 6, 7 */ |
| 2639 return; /* no drop-out control */ | 2642 return; /* no drop-out control */ |
| 2640 } | 2643 } |
| 2641 | 2644 |
| 2642 /* undocumented but confirmed: If the drop-out would result in a */ | 2645 /* undocumented but confirmed: If the drop-out would result in a */ |
| 2643 /* pixel outside of the bounding box, use the pixel inside of the */ | 2646 /* pixel outside of the bounding box, use the pixel inside of the */ |
| 2644 /* bounding box instead */ | 2647 /* bounding box instead */ |
| 2645 if ( pxl < 0 ) | 2648 if ( pxl < 0 ) |
| 2646 pxl = e1; | 2649 pxl = e1; |
| 2647 else if ( TRUNC( pxl ) >= ras.target.rows ) | 2650 else if ( (ULong)( TRUNC( pxl ) ) >= ras.target.rows ) |
| 2648 pxl = e2; | 2651 pxl = e2; |
| 2649 | 2652 |
| 2650 /* check that the other pixel isn't set */ | 2653 /* check that the other pixel isn't set */ |
| 2651 e1 = pxl == e1 ? e2 : e1; | 2654 e1 = pxl == e1 ? e2 : e1; |
| 2652 | 2655 |
| 2653 e1 = TRUNC( e1 ); | 2656 e1 = TRUNC( e1 ); |
| 2654 | 2657 |
| 2655 bits = ras.bTarget + ( y >> 3 ); | 2658 bits = ras.bTarget + ( y >> 3 ); |
| 2656 f1 = (Byte)( 0x80 >> ( y & 7 ) ); | 2659 f1 = (Byte)( 0x80 >> ( y & 7 ) ); |
| 2657 | 2660 |
| 2658 bits -= e1 * ras.target.pitch; | 2661 bits -= e1 * ras.target.pitch; |
| 2659 if ( ras.target.pitch > 0 ) | 2662 if ( ras.target.pitch > 0 ) |
| 2660 bits += ( ras.target.rows - 1 ) * ras.target.pitch; | 2663 bits += ( ras.target.rows - 1 ) * ras.target.pitch; |
| 2661 | 2664 |
| 2662 if ( e1 >= 0 && | 2665 if ( e1 >= 0 && |
| 2663 e1 < ras.target.rows && | 2666 (ULong)e1 < ras.target.rows && |
| 2664 *bits & f1 ) | 2667 *bits & f1 ) |
| 2665 return; | 2668 return; |
| 2666 } | 2669 } |
| 2667 else | 2670 else |
| 2668 return; | 2671 return; |
| 2669 } | 2672 } |
| 2670 | 2673 |
| 2671 bits = ras.bTarget + ( y >> 3 ); | 2674 bits = ras.bTarget + ( y >> 3 ); |
| 2672 f1 = (Byte)( 0x80 >> ( y & 7 ) ); | 2675 f1 = (Byte)( 0x80 >> ( y & 7 ) ); |
| 2673 | 2676 |
| 2674 e1 = TRUNC( pxl ); | 2677 e1 = TRUNC( pxl ); |
| 2675 | 2678 |
| 2676 if ( e1 >= 0 && e1 < ras.target.rows ) | 2679 if ( e1 >= 0 && (ULong)e1 < ras.target.rows ) |
| 2677 { | 2680 { |
| 2678 bits -= e1 * ras.target.pitch; | 2681 bits -= e1 * ras.target.pitch; |
| 2679 if ( ras.target.pitch > 0 ) | 2682 if ( ras.target.pitch > 0 ) |
| 2680 bits += ( ras.target.rows - 1 ) * ras.target.pitch; | 2683 bits += ( ras.target.rows - 1 ) * ras.target.pitch; |
| 2681 | 2684 |
| 2682 bits[0] |= f1; | 2685 bits[0] |= f1; |
| 2683 } | 2686 } |
| 2684 } | 2687 } |
| 2685 | 2688 |
| 2686 | 2689 |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 else | 3535 else |
| 3533 { | 3536 { |
| 3534 raster->buffer = NULL; | 3537 raster->buffer = NULL; |
| 3535 raster->buffer_size = 0; | 3538 raster->buffer_size = 0; |
| 3536 raster->worker = NULL; | 3539 raster->worker = NULL; |
| 3537 } | 3540 } |
| 3538 } | 3541 } |
| 3539 } | 3542 } |
| 3540 | 3543 |
| 3541 | 3544 |
| 3542 static void | 3545 static int |
| 3543 ft_black_set_mode( black_PRaster raster, | 3546 ft_black_set_mode( black_PRaster raster, |
| 3544 unsigned long mode, | 3547 unsigned long mode, |
| 3545 const char* palette ) | 3548 const char* palette ) |
| 3546 { | 3549 { |
| 3547 #ifdef FT_RASTER_OPTION_ANTI_ALIASING | 3550 #ifdef FT_RASTER_OPTION_ANTI_ALIASING |
| 3548 | 3551 |
| 3549 if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) ) | 3552 if ( mode == FT_MAKE_TAG( 'p', 'a', 'l', '5' ) ) |
| 3550 { | 3553 { |
| 3551 /* set 5-levels gray palette */ | 3554 /* set 5-levels gray palette */ |
| 3552 raster->grays[0] = palette[0]; | 3555 raster->grays[0] = palette[0]; |
| 3553 raster->grays[1] = palette[1]; | 3556 raster->grays[1] = palette[1]; |
| 3554 raster->grays[2] = palette[2]; | 3557 raster->grays[2] = palette[2]; |
| 3555 raster->grays[3] = palette[3]; | 3558 raster->grays[3] = palette[3]; |
| 3556 raster->grays[4] = palette[4]; | 3559 raster->grays[4] = palette[4]; |
| 3557 } | 3560 } |
| 3558 | 3561 |
| 3559 #else | 3562 #else |
| 3560 | 3563 |
| 3561 FT_UNUSED( raster ); | 3564 FT_UNUSED( raster ); |
| 3562 FT_UNUSED( mode ); | 3565 FT_UNUSED( mode ); |
| 3563 FT_UNUSED( palette ); | 3566 FT_UNUSED( palette ); |
| 3564 | 3567 |
| 3565 #endif | 3568 #endif |
| 3569 |
| 3570 return 0; |
| 3566 } | 3571 } |
| 3567 | 3572 |
| 3568 | 3573 |
| 3569 static int | 3574 static int |
| 3570 ft_black_render( black_PRaster raster, | 3575 ft_black_render( black_PRaster raster, |
| 3571 const FT_Raster_Params* params ) | 3576 const FT_Raster_Params* params ) |
| 3572 { | 3577 { |
| 3573 const FT_Outline* outline = (const FT_Outline*)params->source; | 3578 const FT_Outline* outline = (const FT_Outline*)params->source; |
| 3574 const FT_Bitmap* target_map = params->target; | 3579 const FT_Bitmap* target_map = params->target; |
| 3575 black_PWorker worker; | 3580 black_PWorker worker; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3631 FT_GLYPH_FORMAT_OUTLINE, | 3636 FT_GLYPH_FORMAT_OUTLINE, |
| 3632 (FT_Raster_New_Func) ft_black_new, | 3637 (FT_Raster_New_Func) ft_black_new, |
| 3633 (FT_Raster_Reset_Func) ft_black_reset, | 3638 (FT_Raster_Reset_Func) ft_black_reset, |
| 3634 (FT_Raster_Set_Mode_Func)ft_black_set_mode, | 3639 (FT_Raster_Set_Mode_Func)ft_black_set_mode, |
| 3635 (FT_Raster_Render_Func) ft_black_render, | 3640 (FT_Raster_Render_Func) ft_black_render, |
| 3636 (FT_Raster_Done_Func) ft_black_done | 3641 (FT_Raster_Done_Func) ft_black_done |
| 3637 ) | 3642 ) |
| 3638 | 3643 |
| 3639 | 3644 |
| 3640 /* END */ | 3645 /* END */ |
| OLD | NEW |