91#define FT_COMPONENT trace_smooth
99#define FT_RENDER_POOL_SIZE 16384L
103#define FT_ERR_XCAT( x, y ) x ## y
104#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y )
106#define FT_BEGIN_STMNT do {
107#define FT_END_STMNT } while ( 0 )
109#define FT_MIN( a, b ) ( (a) < (b) ? (a) : (b) )
110#define FT_MAX( a, b ) ( (a) > (b) ? (a) : (b) )
111#define FT_ABS( a ) ( (a) < 0 ? -(a) : (a) )
119#define FT_HYPOT( x, y ) \
122 x > y ? x + ( 3 * y >> 3 ) \
123 : y + ( 3 * x >> 3 ) )
130#ifdef FT_DEBUG_LEVEL_TRACE
139#define FT_CHAR_BIT CHAR_BIT
140#define FT_UINT_MAX UINT_MAX
141#define FT_INT_MAX INT_MAX
142#define FT_ULONG_MAX ULONG_MAX
144#define ADD_LONG( a, b ) \
145 (long)( (unsigned long)(a) + (unsigned long)(b) )
146#define SUB_LONG( a, b ) \
147 (long)( (unsigned long)(a) - (unsigned long)(b) )
148#define MUL_LONG( a, b ) \
149 (long)( (unsigned long)(a) * (unsigned long)(b) )
150#define NEG_LONG( a ) \
151 (long)( -(unsigned long)(a) )
154#define ft_memset memset
156#define ft_setjmp setjmp
157#define ft_longjmp longjmp
158#define ft_jmp_buf jmp_buf
163#define ErrRaster_Invalid_Mode -2
164#define ErrRaster_Invalid_Outline -1
165#define ErrRaster_Invalid_Argument -3
166#define ErrRaster_Memory_Overflow -4
168#define FT_BEGIN_HEADER
179#define FT_UNUSED( x ) (x) = (x)
184#ifdef FT_DEBUG_LEVEL_TRACE
187 FT_Message(
const char*
fmt,
215#define FT_TRACE5( varformat ) FT_Message varformat
218#define FT_TRACE7( varformat ) FT_Message varformat
221#define FT_ERROR( varformat ) FT_Message varformat
224#define FT_THROW( e ) \
225 ( FT_Throw( FT_ERR_CAT( ErrRaster, e ), \
228 FT_ERR_CAT( ErrRaster, e ) )
232#define FT_TRACE5( x ) do { } while ( 0 )
233#define FT_TRACE7( x ) do { } while ( 0 )
234#define FT_ERROR( x ) do { } while ( 0 )
235#define FT_THROW( e ) FT_ERR_CAT( ErrRaster_, e )
241#define FT_DEFINE_OUTLINE_FUNCS( class_, \
242 move_to_, line_to_, \
243 conic_to_, cubic_to_, \
245 static const FT_Outline_Funcs class_ = \
255#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, \
256 raster_new_, raster_reset_, \
257 raster_set_mode_, raster_render_, \
259 const FT_Raster_Funcs class_ = \
275#include FT_INTERNAL_OBJECTS_H
276#include FT_INTERNAL_DEBUG_H
277#include FT_INTERNAL_CALC_H
284#define Smooth_Err_Invalid_Mode Smooth_Err_Cannot_Render_Glyph
285#define Smooth_Err_Memory_Overflow Smooth_Err_Out_Of_Memory
286#define ErrRaster_Memory_Overflow Smooth_Err_Out_Of_Memory
293#define FT_MEM_SET( d, s, c ) ft_memset( d, s, c )
297#define FT_MEM_ZERO( dest, count ) FT_MEM_SET( dest, 0, count )
301#define FT_ZERO( p ) FT_MEM_ZERO( p, sizeof ( *(p) ) )
311#ifndef FT_STATIC_RASTER
313#define RAS_ARG gray_PWorker worker
314#define RAS_ARG_ gray_PWorker worker,
316#define RAS_VAR worker
317#define RAS_VAR_ worker,
337#define ONE_PIXEL ( 1 << PIXEL_BITS )
338#define TRUNC( x ) ( (TCoord)( (x) >> PIXEL_BITS ) )
339#define SUBPIXELS( x ) ( (TPos)(x) * ONE_PIXEL )
340#define FLOOR( x ) ( (x) & -ONE_PIXEL )
341#define CEILING( x ) ( ( (x) + ONE_PIXEL - 1 ) & -ONE_PIXEL )
342#define ROUND( x ) ( ( (x) + ONE_PIXEL / 2 ) & -ONE_PIXEL )
345#define UPSCALE( x ) ( (x) * ( ONE_PIXEL >> 6 ) )
346#define DOWNSCALE( x ) ( (x) >> ( PIXEL_BITS - 6 ) )
348#define UPSCALE( x ) ( (x) >> ( 6 - PIXEL_BITS ) )
349#define DOWNSCALE( x ) ( (x) * ( 64 >> PIXEL_BITS ) )
357#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
359 (quotient) = (type)( (dividend) / (divisor) ); \
360 (remainder) = (type)( (dividend) % (divisor) ); \
361 if ( (remainder) < 0 ) \
364 (remainder) += (type)(divisor); \
375#define FT_DIV_MOD( type, dividend, divisor, quotient, remainder ) \
377 (quotient) = (type)( (dividend) / (divisor) ); \
378 (remainder) = (type)( (dividend) - (quotient) * (divisor) ); \
379 if ( (remainder) < 0 ) \
382 (remainder) += (type)(divisor); \
390#define FT_UDIVPREP( c, b ) \
391 long b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \
393#define FT_UDIV( a, b ) \
394 ( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \
395 ( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) )
431#if FT_RENDER_POOL_SIZE > 2048
432#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
434#define FT_MAX_GRAY_POOL ( 2048 / sizeof ( TCell ) )
438#if defined( _MSC_VER )
442#pragma warning( push )
443#pragma warning( disable : 4324 )
473#if defined( _MSC_VER )
474#pragma warning( pop )
478#ifndef FT_STATIC_RASTER
492#ifdef FT_DEBUG_LEVEL_TRACE
502 for (
y =
ras.min_ey;
y <
ras.max_ey;
y++ )
509 for ( ; cell !=
NULL; cell = cell->
next )
510 printf(
" (%3d, c:%4d, a:%6d)",
530 pcell = &
ras.ycells[
ras.ey -
ras.min_ey];
534 if ( !cell || cell->
x >
x )
543 if (
ras.num_cells >=
ras.max_cells )
547 cell =
ras.cells +
ras.num_cells++;
582 if (
ex <
ras.min_ex )
586 if ( !
ras.invalid && (
ras.area ||
ras.cover ) )
594 ras.invalid = ( ey >=
ras.max_ey || ey <
ras.min_ey ||
686 }
while ( ex1 != ex2 );
716 if ( ( ey1 >=
ras.max_ey && ey2 >=
ras.max_ey ) ||
717 ( ey1 <
ras.min_ey && ey2 <
ras.min_ey ) )
826 }
while ( ey1 != ey2 );
849 TCoord ex1, ex2, ey1, ey2;
856 if ( ( ey1 >=
ras.max_ey && ey2 >=
ras.max_ey ) ||
857 ( ey1 <
ras.min_ey && ey2 <
ras.min_ey ) )
869 if ( ex1 == ex2 && ey1 == ey2 )
882 ras.cover += ( fy2 - fy1 );
883 ras.area += ( fy2 - fy1 ) * fx1 * 2;
887 }
while ( ey1 != ey2 );
892 ras.cover += ( fy2 - fy1 );
893 ras.area += ( fy2 - fy1 ) * fx1 * 2;
897 }
while ( ey1 != ey2 );
917 ras.cover += ( fy2 - fy1 );
918 ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
929 ras.cover += ( fy2 - fy1 );
930 ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
941 ras.cover += ( fy2 - fy1 );
942 ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
953 ras.cover += ( fy2 - fy1 );
954 ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
961 }
while ( ex1 != ex2 || ey1 != ey2 );
967 ras.cover += ( fy2 - fy1 );
968 ras.area += ( fy2 - fy1 ) * ( fx1 + fx2 );
987 base[2].x = (
a +
b ) / 2;
993 base[2].y = (
a +
b ) / 2;
1015 if ( (
TRUNC( arc[0].
y ) >=
ras.max_ey &&
1027 dx =
FT_ABS( arc[2].
x + arc[0].
x - 2 * arc[1].
x );
1028 dy =
FT_ABS( arc[2].
y + arc[0].
y - 2 * arc[1].
y );
1048 while ( ( draw &
split ) == 0 )
1074 base[2].x =
a = (
a +
c ) / 2;
1075 base[4].x =
b = (
b +
c ) / 2;
1076 base[3].x = (
a +
b ) / 2;
1084 base[2].y =
a = (
a +
c ) / 2;
1085 base[4].y =
b = (
b +
c ) / 2;
1086 base[3].y = (
a +
b ) / 2;
1098 TPos dx1, dy1, dx2, dy2;
1112 if ( (
TRUNC( arc[0].
y ) >=
ras.max_ey &&
1134 dx = dx_ = arc[3].
x - arc[0].
x;
1135 dy = dy_ = arc[3].
y - arc[0].
y;
1147 dx1 = arc[1].
x - arc[0].
x;
1148 dy1 = arc[1].
y - arc[0].
y;
1155 dx2 = arc[2].
x - arc[0].
x;
1156 dy2 = arc[2].
y - arc[0].
y;
1165 if ( dx1 * ( dx1 -
dx ) + dy1 * ( dy1 -
dy ) > 0 ||
1166 dx2 * ( dx2 -
dx ) + dy2 * ( dy2 -
dy ) > 0 )
1171 if ( arc == bez_stack )
1242 coverage = -coverage - 1;
1249 if ( coverage >= 256 )
1250 coverage = 511 - coverage;
1255 if ( coverage >= 256 )
1259 if (
ras.render_span )
1266 span.coverage = (
unsigned char)coverage;
1268 ras.render_span(
y, 1, &
span,
ras.render_span_data );
1272 unsigned char*
q =
ras.target.origin -
ras.target.pitch *
y +
x;
1273 unsigned char c = (
unsigned char)coverage;
1303 for (
y =
ras.min_ey;
y <
ras.max_ey;
y++ )
1311 for ( ; cell !=
NULL; cell = cell->
next )
1313 if ( cover != 0 && cell->
x >
x )
1319 if (
area != 0 && cell->
x >=
ras.min_ex )
1373#define SCALED( x ) ( ( (x) << shift ) - delta )
1394 return FT_THROW( Invalid_Outline );
1396 if ( !func_interface )
1397 return FT_THROW( Invalid_Argument );
1400 delta = func_interface->
delta;
1408 FT_TRACE5((
"FT_Outline_Decompose: Outline %d\n",
n ));
1412 goto Invalid_Outline;
1423 v_control = v_start;
1431 goto Invalid_Outline;
1448 v_start.
x = ( v_start.
x + v_last.
x ) / 2;
1449 v_start.
y = ( v_start.
y + v_last.
y ) / 2;
1458 v_start.
x / 64.0, v_start.
y / 64.0 ));
1508 " with control (%.2f, %.2f)\n",
1510 v_control.
x / 64.0, v_control.
y / 64.0 ));
1518 goto Invalid_Outline;
1520 v_middle.
x = ( v_control.
x +
vec.
x ) / 2;
1521 v_middle.
y = ( v_control.
y +
vec.
y ) / 2;
1524 " with control (%.2f, %.2f)\n",
1525 v_middle.
x / 64.0, v_middle.
y / 64.0,
1526 v_control.
x / 64.0, v_control.
y / 64.0 ));
1536 " with control (%.2f, %.2f)\n",
1537 v_start.
x / 64.0, v_start.
y / 64.0,
1538 v_control.
x / 64.0, v_control.
y / 64.0 ));
1549 goto Invalid_Outline;
1569 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
1571 vec1.
x / 64.0, vec1.
y / 64.0,
1572 vec2.
x / 64.0, vec2.
y / 64.0 ));
1580 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
1581 v_start.
x / 64.0, v_start.
y / 64.0,
1582 vec1.
x / 64.0, vec1.
y / 64.0,
1583 vec2.
x / 64.0, vec2.
y / 64.0 ));
1592 v_start.
x / 64.0, v_start.
y / 64.0 ));
1602 FT_TRACE5((
"FT_Outline_Decompose: Done\n",
n ));
1610 return FT_THROW( Invalid_Outline );
1645 TPos xMin, yMin, xMax, yMax;
1663 xMin = xMax =
vec->
x;
1664 yMin = yMax =
vec->
y;
1673 if (
x < xMin ) xMin =
x;
1674 if (
x > xMax ) xMax =
x;
1677 if (
y < yMin ) yMin =
y;
1678 if (
y > yMax ) yMax =
y;
1705 gray_convert_glyph_inner(
RAS_ARG )
1708 volatile int error = 0;
1710#ifdef FT_CONFIG_OPTION_PIC
1712 Init_Class_func_interface(&func_interface);
1721 FT_TRACE7((
"band [%d..%d]: %d cell%s\n",
1725 ras.num_cells == 1 ?
"" :
"s" ));
1731 FT_TRACE7((
"band [%d..%d]: to be bisected\n",
1732 ras.min_ey,
ras.max_ey ));
1781 for (
y = yMin;
y < yMax; )
1801 ras.min_ex = band[1];
1802 ras.max_ex = band[0];
1826 FT_TRACE7((
"gray_convert_glyph: rotten glyph\n" ));
1836 }
while ( band >= bands );
1855#ifndef FT_STATIC_RASTER
1861 return FT_THROW( Invalid_Argument );
1868 return FT_THROW( Invalid_Outline );
1875 return FT_THROW( Invalid_Outline );
1879 return FT_THROW( Invalid_Outline );
1885 if ( !
params->gray_spans )
1895 return FT_THROW( Invalid_Argument );
1898 if ( !target_map->width || !target_map->rows )
1901 if ( !target_map->buffer )
1902 return FT_THROW( Invalid_Argument );
1904 if ( target_map->pitch < 0 )
1905 ras.target.origin = target_map->buffer;
1907 ras.target.origin = target_map->buffer
1908 + ( target_map->rows - 1 ) * (
unsigned int)target_map->pitch;
1910 ras.target.pitch = target_map->pitch;
1919 if ( cbox.
xMin < -0x1000000L || cbox.
xMax > 0x1000000L ||
1920 cbox.
yMin < -0x1000000L || cbox.
yMax > 0x1000000L )
1921 return FT_THROW( Invalid_Outline );
1926 cbox.
xMax = ( cbox.
xMax + 63 ) >> 6;
1927 cbox.
yMax = ( cbox.
yMax + 63 ) >> 6;
1935 clip.xMax = (
FT_Pos)target_map->width;
1936 clip.yMax = (
FT_Pos)target_map->rows;
1942 clip.xMin = -32768L;
1943 clip.yMin = -32768L;
1954 if (
ras.max_ex <=
ras.min_ex ||
ras.max_ey <=
ras.min_ey )
2024 unsigned char* pool_base,
2025 unsigned long pool_size )
std::map< E_MODULE, HMODULE > mod
void user(int argc, const char *argv[])
static LPSTR * split(LPSTR s, LPINT args)
#define FT_RENDER_POOL_SIZE
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
__kernel_ptrdiff_t ptrdiff_t
#define FT_TRACE5(varformat)
#define FT_TRACE7(varformat)
static void gray_render_conic(RAS_ARG_ const FT_Vector *control, const FT_Vector *to)
static void gray_record_cell(RAS_ARG)
static int gray_conic_to(const FT_Vector *control, const FT_Vector *to, gray_PWorker worker)
#define ErrRaster_Memory_Overflow
static int gray_line_to(const FT_Vector *to, gray_PWorker worker)
static void gray_hline(RAS_ARG_ TCoord x, TCoord y, TArea coverage, TCoord acount)
static void gray_render_line(RAS_ARG_ TPos to_x, TPos to_y)
#define FT_UDIVPREP(c, b)
struct gray_TRaster_ gray_TRaster
static int gray_raster_new(FT_Memory memory, FT_Raster *araster)
static int gray_move_to(const FT_Vector *to, gray_PWorker worker)
#define FT_MEM_SET(d, s, c)
static void gray_sweep(RAS_ARG)
static int gray_convert_glyph(RAS_ARG)
static void gray_render_cubic(RAS_ARG_ const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to)
struct gray_TRaster_ * gray_PRaster
static void gray_raster_done(FT_Raster raster)
struct gray_TWorker_ gray_TWorker
static void gray_set_cell(RAS_ARG_ TCoord ex, TCoord ey)
static void gray_split_cubic(FT_Vector *base)
static int gray_raster_set_mode(FT_Raster raster, unsigned long mode, void *args)
static int gray_cubic_to(const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, gray_PWorker worker)
#define FT_MEM_ZERO(dest, count)
struct gray_TWorker_ * gray_PWorker
static void gray_render_scanline(RAS_ARG_ TCoord ey, TPos x1, TCoord y1, TPos x2, TCoord y2)
#define FT_DIV_MOD(type, dividend, divisor, quotient, remainder)
static void gray_split_conic(FT_Vector *base)
static void gray_raster_reset(FT_Raster raster, unsigned char *pool_base, unsigned long pool_size)
static int gray_raster_render(FT_Raster raster, const FT_Raster_Params *params)
#define FT_CURVE_TAG_CUBIC
#define FT_RASTER_FLAG_AA
#define FT_Raster_Span_Func
#define FT_CURVE_TAG_CONIC
#define FT_Raster_Render_Func
#define FT_OUTLINE_EVEN_ODD_FILL
#define FT_Outline_CubicTo_Func
struct FT_RasterRec_ * FT_Raster
#define FT_RASTER_FLAG_CLIP
#define FT_Outline_LineTo_Func
#define FT_Raster_Reset_Func
#define FT_RASTER_FLAG_DIRECT
#define FT_CURVE_TAG(flag)
#define FT_Outline_ConicTo_Func
#define FT_Raster_New_Func
#define FT_Raster_Set_Mode_Func
#define FT_Outline_MoveTo_Func
#define FT_Raster_Done_Func
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_ALLOC(ptr, size)
#define FT_DEFINE_OUTLINE_FUNCS( class_, move_to_, line_to_, conic_to_, cubic_to_, shift_, delta_)
#define FT_DEFINE_RASTER_FUNCS( class_, glyph_format_, raster_new_, raster_reset_, raster_set_mode_, raster_render_, raster_done_)
FT_BEGIN_HEADER FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
smooth FT_Module_Constructor FT_Module_Destructor FT_Module_Requester FT_GLYPH_FORMAT_OUTLINE
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei GLsizei height
GLint GLint GLsizei width
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLvoid GLvoid GLvoid * span
GLboolean GLboolean GLboolean b
GLenum const GLfloat * params
GLboolean GLboolean GLboolean GLboolean a
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static char memory[1024 *256]
static Real area(Real A[2], Real B[2], Real C[2])
FT_Outline_ConicToFunc conic_to
FT_Outline_LineToFunc line_to
FT_Outline_CubicToFunc cubic_to
FT_Outline_MoveToFunc move_to
FT_Raster_Span_Func render_span
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
void int int ULONGLONG int va_list * ap
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList