📄 ftraster.c
字号:
#define ErrRaster_Bad_Palette_Count 9#define Flow_Up 1#define Flow_Down -1#define SET_High_Precision( p ) Set_High_Precision( RAS_VAR_ p ) /*************************************************************************/ /* */ /* Fast MulDiv, as `b' is always < 64. Don't use intermediate */ /* precision. */ /* */#define FMulDiv( a, b, c ) ( (a) * (b) / (c) ) /*************************************************************************/ /* */ /* Define DEBUG_RASTER if you want to generate a debug version of the */ /* rasterizer. This will progressively draw the glyphs while all the */ /* computation are done directly on the graphics screen (the glyphs will */ /* will be shown inverted). */ /* */ /* Note that DEBUG_RASTER should only be used for debugging with b/w */ /* rendering, not with gray levels. */ /* */ /* The definition of DEBUG_RASTER should appear in the file */ /* `ftconfig.h'. */ /* */#ifdef DEBUG_RASTER extern char* vio; /* A pointer to VRAM or display buffer */#endif /*************************************************************************/ /* */ /* The maximum number of stacked Bezier curves. Setting this constant */ /* to more than 32 is a pure waste of space. */ /* */#define MaxBezier 32 /*************************************************************************/ /* */ /* The number fractional bits of *input* coordinates. We always use the */ /* 26.6 format (i.e, 6 bits for the fractional part), but hackers are */ /* free to experiment with different values. */ /* */#define INPUT_BITS 6 /*************************************************************************/ /* */ /* An unsigned type that is exactly 32 bits on your platform. This */ /* means `unsigned long' on 16-bit machines, and `unsigned int' on */ /* others. */ /* */#ifdef _STANDALONE_#if defined( FT_RASTER_INT_IS_32 ) typedef unsigned int FT_Word32;#elif defined( FT_RASTER_LONG_IS_32 ) typedef unsigned long FT_Word32;#else#error "no 32bit type found - please check your configuration"#endif#endif /*************************************************************************/ /* */ /* A pointer to an unsigned char. */ /* */ typedef unsigned char Byte, *PByte; typedef int TResult; /*************************************************************************/ /* */ /* The type of the pixel coordinates used within the render pool during */ /* scan-line conversion. We use longs to store either 26.6 or 22.10 */ /* fixed float values, depending on the `precision' we want to use */ /* (i.e., low resp. high precision). These are ideals in order to */ /* subdivise Bezier arcs in halves by simple additions and shifts. */ /* */ /* Note that this is an 8-bytes integer on 64 bits systems. */ /* */ typedef long TPos, *PPos; /*************************************************************************/ /* */ /* The type of a scanline position/coordinate within a map. */ /* */ typedef int TScan, *PScan; /*************************************************************************/ /* */ /* States and directions of each line, arc, and profile. */ /* */ typedef enum _TDirection { Unknown, Ascending, Descending, Flat } TDirection; struct _TProfile; typedef struct _TProfile TProfile; typedef TProfile* PProfile; /*************************************************************************/ /* */ /* The `master' structure used for decomposing outlines. */ /* */ struct _TProfile { TPos X; /* current coordinate during sweep */ PProfile link; /* link to next profile - various purpose */ PPos offset; /* start of profile's data in render pool */ int flow; /* Profile orientation: Asc/Descending */ TScan height; /* profile's height in scanlines */ TScan start; /* profile's starting scanline */ TScan countL; /* number of lines to step before this */ /* profile becomes drawable */ PProfile next; /* next profile in same contour, used */ /* during drop-out control */ }; typedef PProfile TProfileList; typedef PProfile* PProfileList; /*************************************************************************/ /* */ /* A simple record used to implement a stack of bands, required by the */ /* sub-banding mechanism. */ /* */ typedef struct _TBand { TScan y_min; /* band's minimum */ TScan y_max; /* band's maximum */ } TBand; /*************************************************************************/ /* */ /* The size in _TPos_ of a profile record in the render pool. */ /* */#define AlignProfileSize \ ( (sizeof ( TProfile ) + sizeof ( TPos ) - 1) / sizeof ( TPos ) ) /*************************************************************************/ /* */ /* Prototypes used for sweep function dispatch. */ /* */ typedef void (*Function_Sweep_Init)( RAS_ARG_ int* min, int* max ); typedef void (*Function_Sweep_Span)( RAS_ARG_ TScan y, TPos x1, TPos x2 ); typedef int (*Function_Test_Pixel)( RAS_ARG_ TScan y, int x ); typedef void (*Function_Set_Pixel)( RAS_ARG_ TScan y, int x, int color ); typedef void (*Function_Sweep_Step)( RAS_ARG ); typedef struct Raster_Render_ { Function_Sweep_Init init; Function_Sweep_Span span; Function_Sweep_Step step; Function_Test_Pixel test_pixel; Function_Set_Pixel set_pixel; } Raster_Render;#ifdef FT_RASTER_CONSTANT_PRECISION #define PRECISION_BITS FT_PRECISION_BITS #define PRECISION (1 << PRECISION_BITS) #define PRECISION_MASK (-1L << PRECISION_BITS) #define PRECISION_HALF (PRECISION >> 1) #define PRECISION_JITTER (PRECISION >> 5) #define PRECISION_STEP PRECISION_HALF#else #define PRECISION_BITS ras.precision_bits #define PRECISION ras.precision #define PRECISION_MASK ras.precision_mask #define PRECISION_HALF ras.precision_half #define PRECISION_JITTER ras.precision_jitter #define PRECISION_STEP ras.precision_step#endif /*************************************************************************/ /* */ /* Compute lowest integer coordinate below a given value. */ /* */#define FLOOR( x ) ( (x) & PRECISION_MASK ) /*************************************************************************/ /* */ /* Compute highest integer coordinate above a given value. */ /* */#define CEILING( x ) ( ((x) + PRECISION - 1) & PRECISION_MASK ) /*************************************************************************/ /* */ /* Get integer coordinate of a given 26.6 or 22.10 `x' coordinate -- no */ /* rounding. */ /* */#define TRUNC( x ) ( (signed long)(x) >> PRECISION_BITS ) /*************************************************************************/ /* */ /* Get the fractional part of a given coordinate. */ /* */#define FRAC( x ) ( (x) & (PRECISION-1) ) /*************************************************************************/ /* */ /* Scale an `input coordinate' (as found in FT_Outline structures) into */ /* a `work coordinate' which depends on current resolution and render */ /* mode. */ /* */#define SCALED( x ) ( ((x) << ras.scale_shift) - ras.scale_delta ) /*************************************************************************/ /* */ /* DEBUG_PSET is used to plot a single pixel in VRam during debug mode. */ /* */#ifdef DEBUG_RASTER#define DEBUG_PSET Pset()#else#define DEBUG_PSET#endif /*************************************************************************/ /* */ /* This structure defines a point in a plane. */ /* */ typedef struct _TPoint { TPos x, y; } TPoint; /*************************************************************************/ /* */ /* The most used variables are at the beginning of the structure. Thus, */ /* their offset can be coded with less opcodes which results in a */ /* smaller executable. */ /* */ struct FT_RasterRec_ { PPos cursor; /* Current cursor in render pool */ PPos pool; /* The render pool base address */ PPos pool_size; /* The render pool's size */ PPos pool_limit; /* Limit of profiles zone in pool */ int bit_width; /* target bitmap width */ PByte bit_buffer; /* target bitmap buffer */ PByte pix_buffer; /* target pixmap buffer */ TPoint last; long minY, maxY; int error;#ifndef FT_RASTER_CONSTANT_PRECISION int precision_bits; /* precision related variables */ int precision; int precision_half; long precision_mask; int precision_shift; int precision_step; int precision_jitter;#endif FT_Outline* outline; int n_points; /* number of points in current glyph */ int n_contours; /* number of contours in current glyph */ int n_extrema; /* number of `extrema' scanlines */ TPoint* arc; /* current Bezier arc pointer */ int num_profs; /* current number of profiles */ char fresh; /* signals a fresh new profile which */ /* `start' field must be completed */ char joint; /* signals that the last arc ended */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -