ReactOS 0.4.16-dev-2357-g35d0dfe
ftgrays.c File Reference
Include dependency graph for ftgrays.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TCell_
 
struct  TPixmap_
 
struct  gray_TWorker_
 
struct  gray_TRaster_
 

Macros

#define FT_COMPONENT   smooth
 
#define Smooth_Err_Invalid_Mode   Smooth_Err_Cannot_Render_Glyph
 
#define Smooth_Err_Memory_Overflow   Smooth_Err_Out_Of_Memory
 
#define ErrRaster_Memory_Overflow   Smooth_Err_Out_Of_Memory
 
#define FT_MEM_SET(d, s, c)   ft_memset( d, s, c )
 
#define FT_MEM_ZERO(dest, count)   FT_MEM_SET( dest, 0, count )
 
#define FT_ZERO(p)   FT_MEM_ZERO( p, sizeof ( *(p) ) )
 
#define RAS_ARG   gray_PWorker worker
 
#define RAS_ARG_   gray_PWorker worker,
 
#define RAS_VAR   worker
 
#define RAS_VAR_   worker,
 
#define PIXEL_BITS   8
 
#define ONE_PIXEL   ( 1 << PIXEL_BITS )
 
#define TRUNC(x)   (TCoord)( (x) >> PIXEL_BITS )
 
#define FRACT(x)   (TCoord)( (x) & ( ONE_PIXEL - 1 ) )
 
#define UPSCALE(x)   ( (x) * ( ONE_PIXEL >> 6 ) )
 
#define DOWNSCALE(x)   ( (x) >> ( PIXEL_BITS - 6 ) )
 
#define FT_DIV_MOD(type, dividend, divisor, quotient, remainder)
 
#define FT_UDIVPREP(c, b)
 
#define FT_UDIV(a, b)
 
#define FT_MAX_GRAY_POOL   ( 2048 / sizeof ( TCell ) )
 
#define FT_MAX_GRAY_SPANS   10
 
#define ras   (*worker)
 

Typedefs

typedef long TPos
 
typedef int TCoord
 
typedef int TArea
 
typedef struct TCell_PCell
 
typedef struct TCell_ TCell
 
typedef struct TPixmap_ TPixmap
 
typedef struct gray_TWorker_ gray_TWorker
 
typedef struct gray_TWorker_gray_PWorker
 
typedef struct gray_TRaster_ gray_TRaster
 
typedef struct gray_TRaster_gray_PRaster
 

Functions

static void gray_record_cell (RAS_ARG)
 
static void gray_set_cell (RAS_ARG_ TCoord ex, TCoord ey)
 
static void gray_render_scanline (RAS_ARG_ TCoord ey, TPos x1, TCoord y1, TPos x2, TCoord y2)
 
static void gray_render_line (RAS_ARG_ TPos to_x, TPos to_y)
 
static void gray_split_conic (FT_Vector *base)
 
static void gray_render_conic (RAS_ARG_ const FT_Vector *control, const FT_Vector *to)
 
static void gray_split_cubic (FT_Vector *base)
 
static void gray_render_cubic (RAS_ARG_ const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to)
 
static int gray_move_to (const FT_Vector *to, gray_PWorker worker)
 
static int gray_line_to (const FT_Vector *to, gray_PWorker worker)
 
static int gray_conic_to (const FT_Vector *control, const FT_Vector *to, gray_PWorker worker)
 
static int gray_cubic_to (const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to, gray_PWorker worker)
 
static void gray_hline (RAS_ARG_ TCoord x, TCoord y, TArea coverage, TCoord acount)
 
static void gray_sweep (RAS_ARG)
 
 FT_DEFINE_OUTLINE_FUNCS (func_interface,(FT_Outline_MoveTo_Func) gray_move_to,(FT_Outline_LineTo_Func) gray_line_to,(FT_Outline_ConicTo_Func) gray_conic_to,(FT_Outline_CubicTo_Func) gray_cubic_to, 0, 0) static int gray_convert_glyph_inner(RAS_ARG
 
 if (ft_setjmp(ras.jump_buffer)==0)
 
 FT_TRACE7 (("band [%d..%d]: to be bisected\n", ras.min_ey, ras.max_ey))
 
static int gray_convert_glyph (RAS_ARG)
 
static int gray_raster_render (FT_Raster raster, const FT_Raster_Params *params)
 
static int gray_raster_new (FT_Memory memory, FT_Raster *araster)
 
static void gray_raster_done (FT_Raster raster)
 
static void gray_raster_reset (FT_Raster raster, unsigned char *pool_base, unsigned long pool_size)
 
static int gray_raster_set_mode (FT_Raster raster, unsigned long mode, void *args)
 

Variables

int continued
 
 else
 
return error
 

Macro Definition Documentation

◆ DOWNSCALE

#define DOWNSCALE (   x)    ( (x) >> ( PIXEL_BITS - 6 ) )

Definition at line 345 of file ftgrays.c.

◆ ErrRaster_Memory_Overflow

#define ErrRaster_Memory_Overflow   Smooth_Err_Out_Of_Memory

Definition at line 293 of file ftgrays.c.

◆ FRACT

#define FRACT (   x)    (TCoord)( (x) & ( ONE_PIXEL - 1 ) )

Definition at line 341 of file ftgrays.c.

◆ FT_COMPONENT

#define FT_COMPONENT   smooth

Definition at line 99 of file ftgrays.c.

◆ FT_DIV_MOD

#define FT_DIV_MOD (   type,
  dividend,
  divisor,
  quotient,
  remainder 
)
Value:
(quotient) = (type)( (dividend) / (divisor) ); \
(remainder) = (type)( (dividend) % (divisor) ); \
if ( (remainder) < 0 ) \
{ \
(quotient)--; \
(remainder) += (type)(divisor); \
} \
#define FT_END_STMNT
#define FT_BEGIN_STMNT
_ACRTIMP double __cdecl remainder(double, double)
Definition: remainder.c:75
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint divisor
Definition: glext.h:6313

Definition at line 356 of file ftgrays.c.

◆ FT_MAX_GRAY_POOL

#define FT_MAX_GRAY_POOL   ( 2048 / sizeof ( TCell ) )

Definition at line 433 of file ftgrays.c.

◆ FT_MAX_GRAY_SPANS

#define FT_MAX_GRAY_SPANS   10

Definition at line 437 of file ftgrays.c.

◆ FT_MEM_SET

#define FT_MEM_SET (   d,
  s,
  c 
)    ft_memset( d, s, c )

Definition at line 300 of file ftgrays.c.

◆ FT_MEM_ZERO

#define FT_MEM_ZERO (   dest,
  count 
)    FT_MEM_SET( dest, 0, count )

Definition at line 304 of file ftgrays.c.

◆ FT_UDIV

#define FT_UDIV (   a,
  b 
)
Value:
(TCoord)( ( (unsigned long)( a ) * (unsigned long)( b ## _r ) ) >> \
( sizeof( long ) * FT_CHAR_BIT - PIXEL_BITS ) )
int TCoord
Definition: ftgrays.c:407
#define PIXEL_BITS
Definition: ftgrays.c:337
#define FT_CHAR_BIT
Definition: ftstdlib.h:61
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define long
Definition: qsort.c:33

Definition at line 392 of file ftgrays.c.

◆ FT_UDIVPREP

#define FT_UDIVPREP (   c,
  b 
)
Value:
long b ## _r = c ? (long)( FT_ULONG_MAX >> PIXEL_BITS ) / ( b ) \
: 0
#define FT_ULONG_MAX
Definition: ftstdlib.h:68
const GLubyte * c
Definition: glext.h:8905
#define b
Definition: ke_i.h:79

Definition at line 389 of file ftgrays.c.

◆ FT_ZERO

#define FT_ZERO (   p)    FT_MEM_ZERO( p, sizeof ( *(p) ) )

Definition at line 308 of file ftgrays.c.

◆ ONE_PIXEL

#define ONE_PIXEL   ( 1 << PIXEL_BITS )

Definition at line 339 of file ftgrays.c.

◆ PIXEL_BITS

#define PIXEL_BITS   8

Definition at line 337 of file ftgrays.c.

◆ ras

#define ras   (*worker)

Definition at line 483 of file ftgrays.c.

◆ RAS_ARG

#define RAS_ARG   gray_PWorker worker

Definition at line 320 of file ftgrays.c.

◆ RAS_ARG_

#define RAS_ARG_   gray_PWorker worker,

Definition at line 321 of file ftgrays.c.

◆ RAS_VAR

#define RAS_VAR   worker

Definition at line 323 of file ftgrays.c.

◆ RAS_VAR_

#define RAS_VAR_   worker,

Definition at line 324 of file ftgrays.c.

◆ Smooth_Err_Invalid_Mode

#define Smooth_Err_Invalid_Mode   Smooth_Err_Cannot_Render_Glyph

Definition at line 291 of file ftgrays.c.

◆ Smooth_Err_Memory_Overflow

#define Smooth_Err_Memory_Overflow   Smooth_Err_Out_Of_Memory

Definition at line 292 of file ftgrays.c.

◆ TRUNC

#define TRUNC (   x)    (TCoord)( (x) >> PIXEL_BITS )

Definition at line 340 of file ftgrays.c.

◆ UPSCALE

#define UPSCALE (   x)    ( (x) * ( ONE_PIXEL >> 6 ) )

Definition at line 344 of file ftgrays.c.

Typedef Documentation

◆ gray_PRaster

◆ gray_PWorker

◆ gray_TRaster

◆ gray_TWorker

◆ PCell

typedef struct TCell_* PCell

Definition at line 411 of file ftgrays.c.

◆ TArea

typedef int TArea

Definition at line 408 of file ftgrays.c.

◆ TCell

typedef struct TCell_ TCell

◆ TCoord

typedef int TCoord

Definition at line 407 of file ftgrays.c.

◆ TPixmap

◆ TPos

typedef long TPos

Definition at line 406 of file ftgrays.c.

Function Documentation

◆ FT_DEFINE_OUTLINE_FUNCS()

FT_DEFINE_OUTLINE_FUNCS ( func_interface  ,
(FT_Outline_MoveTo_Func gray_move_to,
(FT_Outline_LineTo_Func gray_line_to,
(FT_Outline_ConicTo_Func gray_conic_to,
(FT_Outline_CubicTo_Func gray_cubic_to,
,
 
)

◆ FT_TRACE7()

FT_TRACE7 ( ("band [%d..%d]: to be bisected\n", ras.min_ey, ras.max_ey)  )

◆ gray_conic_to()

static int gray_conic_to ( const FT_Vector control,
const FT_Vector to,
gray_PWorker  worker 
)
static

Definition at line 1189 of file ftgrays.c.

1192 {
1194 return 0;
1195 }
static void gray_render_conic(RAS_ARG_ const FT_Vector *control, const FT_Vector *to)
Definition: ftgrays.c:1006
#define RAS_VAR_
Definition: ftgrays.c:324
Definition: dialog.c:52

◆ gray_convert_glyph()

static int gray_convert_glyph ( RAS_ARG  )
static

Definition at line 1672 of file ftgrays.c.

1673 {
1674 const TCoord yMin = ras.min_ey;
1675 const TCoord yMax = ras.max_ey;
1676
1677#ifdef __REACTOS__
1679 if (!buffer)
1680 return 1;
1681 {
1682#else
1684#endif
1685 size_t height = (size_t)( yMax - yMin );
1686 size_t n = FT_MAX_GRAY_POOL / 8;
1687 TCoord y;
1688 TCoord bands[32]; /* enough to accommodate bisections */
1689 TCoord* band;
1690
1691 int continued = 0;
1692
1693
1694 /* set up vertical bands */
1695 if ( height > n )
1696 {
1697 /* two divisions rounded up */
1698 n = ( height + n - 1 ) / n;
1699 height = ( height + n - 1 ) / n;
1700 }
1701
1702 /* memory management */
1703 n = ( height * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / sizeof ( TCell );
1704
1705 ras.cells = buffer + n;
1706 ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - n );
1707 ras.ycells = (PCell*)buffer;
1708
1709 for ( y = yMin; y < yMax; )
1710 {
1711 ras.min_ey = y;
1712 y += height;
1713 ras.max_ey = FT_MIN( y, yMax );
1714
1715 band = bands;
1716 band[1] = ras.min_ey;
1717 band[0] = ras.max_ey;
1718
1719 do
1720 {
1721 TCoord width = band[0] - band[1];
1722 int error;
1723
1724
1725 FT_MEM_ZERO( ras.ycells, height * sizeof ( PCell ) );
1726
1727 ras.num_cells = 0;
1728 ras.invalid = 1;
1729 ras.min_ey = band[1];
1730 ras.max_ey = band[0];
1731
1732 error = gray_convert_glyph_inner( RAS_VAR, continued );
1733 continued = 1;
1734
1735 if ( !error )
1736 {
1738 band--;
1739 continue;
1740 }
1741 else if ( error != ErrRaster_Memory_Overflow )
1742#ifdef __REACTOS__
1743 {
1744 free(buffer);
1745 return 1;
1746 }
1747#else
1748 return 1;
1749#endif
1750
1751 /* render pool overflow; we will reduce the render band by half */
1752 width >>= 1;
1753
1754 /* this should never happen even with tiny rendering pool */
1755 if ( width == 0 )
1756 {
1757 FT_TRACE7(( "gray_convert_glyph: rotten glyph\n" ));
1758#ifdef __REACTOS__
1759 free(buffer);
1760#endif
1761 return 1;
1762 }
1763
1764 band++;
1765 band[1] = band[0];
1766 band[0] += width;
1767 } while ( band >= bands );
1768 }
1769
1770#ifdef __REACTOS__
1771 free(buffer);
1772 }
1773#endif
1774 return 0;
1775 }
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
unsigned int size_t
Definition: corecrt.h:203
#define FT_TRACE7(varformat)
Definition: ftdebug.h:194
#define ErrRaster_Memory_Overflow
Definition: ftgrays.c:293
static void gray_sweep(RAS_ARG)
Definition: ftgrays.c:1294
#define RAS_VAR
Definition: ftgrays.c:323
#define ras
Definition: ftgrays.c:483
struct TCell_ * PCell
Definition: ftgrays.c:411
return error
Definition: ftgrays.c:1667
#define FT_MAX_GRAY_POOL
Definition: ftgrays.c:433
#define FT_MEM_ZERO(dest, count)
Definition: ftgrays.c:304
int continued
Definition: ftgrays.c:1638
#define FT_MIN(a, b)
Definition: ftobjs.h:70
ft_ptrdiff_t FT_PtrDist
Definition: fttypes.h:336
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList

Referenced by gray_raster_render().

◆ gray_cubic_to()

static int gray_cubic_to ( const FT_Vector control1,
const FT_Vector control2,
const FT_Vector to,
gray_PWorker  worker 
)
static

Definition at line 1199 of file ftgrays.c.

1203 {
1204 gray_render_cubic( RAS_VAR_ control1, control2, to );
1205 return 0;
1206 }
static void gray_render_cubic(RAS_ARG_ const FT_Vector *control1, const FT_Vector *control2, const FT_Vector *to)
Definition: ftgrays.c:1102

◆ gray_hline()

static void gray_hline ( RAS_ARG_ TCoord  x,
TCoord  y,
TArea  coverage,
TCoord  acount 
)
static

Definition at line 1210 of file ftgrays.c.

1214 {
1215 /* scale the coverage from 0..(ONE_PIXEL*ONE_PIXEL*2) to 0..256 */
1216 coverage >>= PIXEL_BITS * 2 + 1 - 8;
1217
1218 /* compute the line's coverage depending on the outline fill rule */
1219 if ( ras.outline.flags & FT_OUTLINE_EVEN_ODD_FILL )
1220 {
1221 coverage &= 511;
1222
1223 if ( coverage >= 256 )
1224 coverage = 511 - coverage;
1225 }
1226 else /* default non-zero winding rule */
1227 {
1228 if ( coverage < 0 )
1229 coverage = ~coverage; /* the same as -coverage - 1 */
1230
1231 if ( coverage >= 256 )
1232 coverage = 255;
1233 }
1234
1235 if ( ras.num_spans >= 0 ) /* for FT_RASTER_FLAG_DIRECT only */
1236 {
1237 FT_Span* span = ras.spans + ras.num_spans++;
1238
1239
1240 span->x = (short)x;
1241 span->len = (unsigned short)acount;
1242 span->coverage = (unsigned char)coverage;
1243
1244 if ( ras.num_spans == FT_MAX_GRAY_SPANS )
1245 {
1246 /* flush the span buffer and reset the count */
1247 ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data );
1248 ras.num_spans = 0;
1249 }
1250 }
1251 else
1252 {
1253 unsigned char* q = ras.target.origin - ras.target.pitch * y + x;
1254 unsigned char c = (unsigned char)coverage;
1255
1256
1257 /* For small-spans it is faster to do it by ourselves than
1258 * calling `memset'. This is mainly due to the cost of the
1259 * function call.
1260 */
1261 switch ( acount )
1262 {
1263 case 7:
1264 *q++ = c;
1265 /* fall through */
1266 case 6:
1267 *q++ = c;
1268 /* fall through */
1269 case 5:
1270 *q++ = c;
1271 /* fall through */
1272 case 4:
1273 *q++ = c;
1274 /* fall through */
1275 case 3:
1276 *q++ = c;
1277 /* fall through */
1278 case 2:
1279 *q++ = c;
1280 /* fall through */
1281 case 1:
1282 *q = c;
1283 /* fall through */
1284 case 0:
1285 break;
1286 default:
1287 FT_MEM_SET( q, c, acount );
1288 }
1289 }
1290 }
unsigned char
Definition: typeof.h:29
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define FT_MEM_SET(d, s, c)
Definition: ftgrays.c:300
#define FT_MAX_GRAY_SPANS
Definition: ftgrays.c:437
#define FT_OUTLINE_EVEN_ODD_FILL
Definition: ftimage.h:436
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
GLenum GLenum GLvoid GLvoid GLvoid * span
Definition: glext.h:5664
#define c
Definition: ke_i.h:80

Referenced by gray_sweep().

◆ gray_line_to()

static int gray_line_to ( const FT_Vector to,
gray_PWorker  worker 
)
static

Definition at line 1180 of file ftgrays.c.

1182 {
1183 gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
1184 return 0;
1185 }
#define UPSCALE(x)
Definition: ftgrays.c:344
static void gray_render_line(RAS_ARG_ TPos to_x, TPos to_y)
Definition: ftgrays.c:707
FT_Pos x
Definition: ftimage.h:77
FT_Pos y
Definition: ftimage.h:78

◆ gray_move_to()

static int gray_move_to ( const FT_Vector to,
gray_PWorker  worker 
)
static

Definition at line 1161 of file ftgrays.c.

1163 {
1164 TPos x, y;
1165
1166
1167 /* start to a new position */
1168 x = UPSCALE( to->x );
1169 y = UPSCALE( to->y );
1170
1171 gray_set_cell( RAS_VAR_ TRUNC( x ), TRUNC( y ) );
1172
1173 ras.x = x;
1174 ras.y = y;
1175 return 0;
1176 }
long TPos
Definition: ftgrays.c:406
#define TRUNC(x)
Definition: ftgrays.c:340
static void gray_set_cell(RAS_ARG_ TCoord ex, TCoord ey)
Definition: ftgrays.c:572

◆ gray_raster_done()

static void gray_raster_done ( FT_Raster  raster)
static

Definition at line 1969 of file ftgrays.c.

1970 {
1972
1973
1974 FT_FREE( raster );
1975 }
#define FT_FREE(ptr)
Definition: ftmemory.h:337
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
static char memory[1024 *256]
Definition: process.c:122

◆ gray_raster_new()

static int gray_raster_new ( FT_Memory  memory,
FT_Raster araster 
)
static

Definition at line 1950 of file ftgrays.c.

1952 {
1954 gray_PRaster raster = NULL;
1955
1956
1957 *araster = 0;
1958 if ( !FT_ALLOC( raster, sizeof ( gray_TRaster ) ) )
1959 {
1960 raster->memory = memory;
1961 *araster = (FT_Raster)raster;
1962 }
1963
1964 return error;
1965 }
#define NULL
Definition: types.h:112
struct FT_RasterRec_ * FT_Raster
Definition: ftimage.h:828
#define FT_ALLOC(ptr, size)
Definition: ftmemory.h:311
int FT_Error
Definition: fttypes.h:299
void * memory
Definition: ftgrays.c:491

◆ gray_raster_render()

static int gray_raster_render ( FT_Raster  raster,
const FT_Raster_Params params 
)
static

Definition at line 1779 of file ftgrays.c.

1781 {
1782 const FT_Outline* outline = (const FT_Outline*)params->source;
1783 const FT_Bitmap* target_map = params->target;
1784
1785#ifndef FT_STATIC_RASTER
1786#ifdef __REACTOS__
1787 gray_TWorker *worker;
1788#else
1789 gray_TWorker worker[1];
1790#endif
1791#endif
1792
1793
1794 if ( !raster )
1795 return FT_THROW( Invalid_Argument );
1796
1797 /* this version does not support monochrome rendering */
1798 if ( !( params->flags & FT_RASTER_FLAG_AA ) )
1799 return FT_THROW( Invalid_Mode );
1800
1801 if ( !outline )
1802 return FT_THROW( Invalid_Outline );
1803
1804 /* return immediately if the outline is empty */
1805 if ( outline->n_points == 0 || outline->n_contours <= 0 )
1806 return 0;
1807
1808 if ( !outline->contours || !outline->points )
1809 return FT_THROW( Invalid_Outline );
1810
1811 if ( outline->n_points !=
1812 outline->contours[outline->n_contours - 1] + 1 )
1813 return FT_THROW( Invalid_Outline );
1814
1815#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1816 worker = malloc(sizeof(*worker));
1817 if (!worker)
1818 return FT_THROW(Out_Of_Memory);
1819#endif /* !defined(FT_STATIC_RASTER) && defined(__REACTOS__) */
1820
1821 ras.outline = *outline;
1822
1823 if ( params->flags & FT_RASTER_FLAG_DIRECT )
1824 {
1825 if ( !params->gray_spans )
1826#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1827 {
1828 free(worker);
1829 return 0;
1830 }
1831#else
1832 return 0;
1833#endif
1834
1835 ras.render_span = (FT_Raster_Span_Func)params->gray_spans;
1836 ras.render_span_data = params->user;
1837 ras.num_spans = 0;
1838
1839 ras.min_ex = params->clip_box.xMin;
1840 ras.min_ey = params->clip_box.yMin;
1841 ras.max_ex = params->clip_box.xMax;
1842 ras.max_ey = params->clip_box.yMax;
1843 }
1844 else
1845 {
1846 /* if direct mode is not set, we must have a target bitmap */
1847 if ( !target_map )
1848#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1849 {
1850 free(worker);
1851 return FT_THROW( Invalid_Argument );
1852 }
1853#else
1854 return FT_THROW( Invalid_Argument );
1855#endif
1856
1857 /* nothing to do */
1858 if ( !target_map->width || !target_map->rows )
1859#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1860 {
1861 free(worker);
1862 return 0;
1863 }
1864#else
1865 return 0;
1866#endif
1867
1868 if ( !target_map->buffer )
1869#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1870 {
1871 free(worker);
1872 return FT_THROW( Invalid_Argument );
1873 }
1874#else
1875 return FT_THROW( Invalid_Argument );
1876#endif
1877
1878 if ( target_map->pitch < 0 )
1879 ras.target.origin = target_map->buffer;
1880 else
1881 ras.target.origin = target_map->buffer
1882 + ( target_map->rows - 1 ) * (unsigned int)target_map->pitch;
1883
1884 ras.target.pitch = target_map->pitch;
1885
1886 ras.render_span = (FT_Raster_Span_Func)NULL;
1887 ras.render_span_data = NULL;
1888 ras.num_spans = -1; /* invalid */
1889
1890 ras.min_ex = 0;
1891 ras.min_ey = 0;
1892 ras.max_ex = (FT_Pos)target_map->width;
1893 ras.max_ey = (FT_Pos)target_map->rows;
1894 }
1895
1896 /* exit if nothing to do */
1897 if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
1898#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1899 {
1900 free(worker);
1901 return 0;
1902 }
1903#else
1904 return 0;
1905#endif
1906
1907#if !defined(FT_STATIC_RASTER) && defined(__REACTOS__)
1908 {
1910 free(worker);
1911 return error;
1912 }
1913#else
1914 return gray_convert_glyph( RAS_VAR );
1915#endif
1916 }
#define FT_THROW(e)
Definition: ftdebug.h:243
static int gray_convert_glyph(RAS_ARG)
Definition: ftgrays.c:1672
#define FT_RASTER_FLAG_AA
Definition: ftimage.h:967
#define FT_Raster_Span_Func
Definition: ftimage.h:903
#define FT_RASTER_FLAG_DIRECT
Definition: ftimage.h:968
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:57
GLenum const GLfloat * params
Definition: glext.h:5645
if(dx< 0)
Definition: linetemp.h:194
Definition: mesh.c:5330

◆ gray_raster_reset()

static void gray_raster_reset ( FT_Raster  raster,
unsigned char pool_base,
unsigned long  pool_size 
)
static

Definition at line 1981 of file ftgrays.c.

1984 {
1985 FT_UNUSED( raster );
1986 FT_UNUSED( pool_base );
1987 FT_UNUSED( pool_size );
1988 }
#define FT_UNUSED(arg)

◆ gray_raster_set_mode()

static int gray_raster_set_mode ( FT_Raster  raster,
unsigned long  mode,
void args 
)
static

Definition at line 1992 of file ftgrays.c.

1995 {
1996 FT_UNUSED( raster );
1997 FT_UNUSED( mode );
1998 FT_UNUSED( args );
1999
2000
2001 return 0; /* nothing to do */
2002 }
GLenum mode
Definition: glext.h:6217
Definition: match.c:390

◆ gray_record_cell()

static void gray_record_cell ( RAS_ARG  )
static

Definition at line 528 of file ftgrays.c.

529 {
530 PCell *pcell, cell;
531 TCoord x = ras.ex;
532
533
534 pcell = &ras.ycells[ras.ey - ras.min_ey];
535 while ( ( cell = *pcell ) )
536 {
537 if ( cell->x > x )
538 break;
539
540 if ( cell->x == x )
541 goto Found;
542
543 pcell = &cell->next;
544 }
545
546 if ( ras.num_cells >= ras.max_cells )
547 ft_longjmp( ras.jump_buffer, 1 );
548
549 /* insert new cell */
550 cell = ras.cells + ras.num_cells++;
551 cell->x = x;
552 cell->area = ras.area;
553 cell->cover = ras.cover;
554
555 cell->next = *pcell;
556 *pcell = cell;
557
558 return;
559
560 Found:
561 /* update old cell */
562 cell->area += ras.area;
563 cell->cover += ras.cover;
564 }
return Found
Definition: dirsup.c:1270
#define ft_longjmp
Definition: ftstdlib.h:162
TCoord cover
Definition: ftgrays.c:416
PCell next
Definition: ftgrays.c:418
TCoord x
Definition: ftgrays.c:415
TArea area
Definition: ftgrays.c:417

Referenced by gray_set_cell(), and if().

◆ gray_render_conic()

static void gray_render_conic ( RAS_ARG_ const FT_Vector control,
const FT_Vector to 
)
static

Definition at line 1006 of file ftgrays.c.

1008 {
1009 FT_Vector bez_stack[16 * 2 + 1]; /* enough to accommodate bisections */
1010 FT_Vector* arc = bez_stack;
1011 TPos dx, dy;
1012 int draw, split;
1013
1014
1015 arc[0].x = UPSCALE( to->x );
1016 arc[0].y = UPSCALE( to->y );
1017 arc[1].x = UPSCALE( control->x );
1018 arc[1].y = UPSCALE( control->y );
1019 arc[2].x = ras.x;
1020 arc[2].y = ras.y;
1021
1022 /* short-cut the arc that crosses the current band */
1023 if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
1024 TRUNC( arc[1].y ) >= ras.max_ey &&
1025 TRUNC( arc[2].y ) >= ras.max_ey ) ||
1026 ( TRUNC( arc[0].y ) < ras.min_ey &&
1027 TRUNC( arc[1].y ) < ras.min_ey &&
1028 TRUNC( arc[2].y ) < ras.min_ey ) )
1029 {
1030 ras.x = arc[0].x;
1031 ras.y = arc[0].y;
1032 return;
1033 }
1034
1035 dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
1036 dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
1037 if ( dx < dy )
1038 dx = dy;
1039
1040 /* We can calculate the number of necessary bisections because */
1041 /* each bisection predictably reduces deviation exactly 4-fold. */
1042 /* Even 32-bit deviation would vanish after 16 bisections. */
1043 draw = 1;
1044 while ( dx > ONE_PIXEL / 4 )
1045 {
1046 dx >>= 2;
1047 draw <<= 1;
1048 }
1049
1050 /* We use decrement counter to count the total number of segments */
1051 /* to draw starting from 2^level. Before each draw we split as */
1052 /* many times as there are trailing zeros in the counter. */
1053 do
1054 {
1055 split = draw & ( -draw ); /* isolate the rightmost 1-bit */
1056 while ( ( split >>= 1 ) )
1057 {
1058 gray_split_conic( arc );
1059 arc += 2;
1060 }
1061
1062 gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
1063 arc -= 2;
1064
1065 } while ( --draw );
1066 }
static LPSTR * split(LPSTR s, LPINT args)
Definition: cmdcons.c:163
static void gray_split_conic(FT_Vector *base)
Definition: ftgrays.c:984
#define ONE_PIXEL
Definition: ftgrays.c:339
#define FT_ABS(a)
Definition: ftobjs.h:73
GLint dy
Definition: linetemp.h:97
GLint dx
Definition: linetemp.h:97

Referenced by gray_conic_to().

◆ gray_render_cubic()

static void gray_render_cubic ( RAS_ARG_ const FT_Vector control1,
const FT_Vector control2,
const FT_Vector to 
)
static

Definition at line 1102 of file ftgrays.c.

1105 {
1106 FT_Vector bez_stack[16 * 3 + 1]; /* enough to accommodate bisections */
1107 FT_Vector* arc = bez_stack;
1108
1109
1110 arc[0].x = UPSCALE( to->x );
1111 arc[0].y = UPSCALE( to->y );
1112 arc[1].x = UPSCALE( control2->x );
1113 arc[1].y = UPSCALE( control2->y );
1114 arc[2].x = UPSCALE( control1->x );
1115 arc[2].y = UPSCALE( control1->y );
1116 arc[3].x = ras.x;
1117 arc[3].y = ras.y;
1118
1119 /* short-cut the arc that crosses the current band */
1120 if ( ( TRUNC( arc[0].y ) >= ras.max_ey &&
1121 TRUNC( arc[1].y ) >= ras.max_ey &&
1122 TRUNC( arc[2].y ) >= ras.max_ey &&
1123 TRUNC( arc[3].y ) >= ras.max_ey ) ||
1124 ( TRUNC( arc[0].y ) < ras.min_ey &&
1125 TRUNC( arc[1].y ) < ras.min_ey &&
1126 TRUNC( arc[2].y ) < ras.min_ey &&
1127 TRUNC( arc[3].y ) < ras.min_ey ) )
1128 {
1129 ras.x = arc[0].x;
1130 ras.y = arc[0].y;
1131 return;
1132 }
1133
1134 for (;;)
1135 {
1136 /* with each split, control points quickly converge towards */
1137 /* chord trisection points and the vanishing distances below */
1138 /* indicate when the segment is flat enough to draw */
1139 if ( FT_ABS( 2 * arc[0].x - 3 * arc[1].x + arc[3].x ) > ONE_PIXEL / 2 ||
1140 FT_ABS( 2 * arc[0].y - 3 * arc[1].y + arc[3].y ) > ONE_PIXEL / 2 ||
1141 FT_ABS( arc[0].x - 3 * arc[2].x + 2 * arc[3].x ) > ONE_PIXEL / 2 ||
1142 FT_ABS( arc[0].y - 3 * arc[2].y + 2 * arc[3].y ) > ONE_PIXEL / 2 )
1143 goto Split;
1144
1145 gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
1146
1147 if ( arc == bez_stack )
1148 return;
1149
1150 arc -= 3;
1151 continue;
1152
1153 Split:
1154 gray_split_cubic( arc );
1155 arc += 3;
1156 }
1157 }
static void gray_split_cubic(FT_Vector *base)
Definition: ftgrays.c:1070

Referenced by gray_cubic_to().

◆ gray_render_line()

static void gray_render_line ( RAS_ARG_ TPos  to_x,
TPos  to_y 
)
static

Definition at line 707 of file ftgrays.c.

709 {
710 TCoord ey1, ey2, fy1, fy2, first, delta, mod;
711 TPos p, dx, dy, x, x2;
712 int incr;
713
714
715 ey1 = TRUNC( ras.y );
716 ey2 = TRUNC( to_y ); /* if (ey2 >= ras.max_ey) ey2 = ras.max_ey-1; */
717
718 /* perform vertical clipping */
719 if ( ( ey1 >= ras.max_ey && ey2 >= ras.max_ey ) ||
720 ( ey1 < ras.min_ey && ey2 < ras.min_ey ) )
721 goto End;
722
723 fy1 = FRACT( ras.y );
724 fy2 = FRACT( to_y );
725
726 /* everything is on a single scanline */
727 if ( ey1 == ey2 )
728 {
729 gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, to_x, fy2 );
730 goto End;
731 }
732
733 dx = to_x - ras.x;
734 dy = to_y - ras.y;
735
736 /* vertical line - avoid calling gray_render_scanline */
737 if ( dx == 0 )
738 {
739 TCoord ex = TRUNC( ras.x );
740 TCoord two_fx = FRACT( ras.x ) << 1;
741 TArea area;
742
743
744 if ( dy > 0)
745 {
747 incr = 1;
748 }
749 else
750 {
751 first = 0;
752 incr = -1;
753 }
754
755 delta = first - fy1;
756 ras.area += (TArea)two_fx * delta;
757 ras.cover += delta;
758 ey1 += incr;
759
760 gray_set_cell( RAS_VAR_ ex, ey1 );
761
762 delta = first + first - ONE_PIXEL;
763 area = (TArea)two_fx * delta;
764 while ( ey1 != ey2 )
765 {
766 ras.area += area;
767 ras.cover += delta;
768 ey1 += incr;
769
770 gray_set_cell( RAS_VAR_ ex, ey1 );
771 }
772
773 delta = fy2 - ONE_PIXEL + first;
774 ras.area += (TArea)two_fx * delta;
775 ras.cover += delta;
776
777 goto End;
778 }
779
780 /* ok, we have to render several scanlines */
781 if ( dy > 0)
782 {
783 p = ( ONE_PIXEL - fy1 ) * dx;
785 incr = 1;
786 }
787 else
788 {
789 p = fy1 * dx;
790 first = 0;
791 incr = -1;
792 dy = -dy;
793 }
794
795 /* the fractional part of x-delta is mod/dy. It is essential to */
796 /* keep track of its accumulation for accurate rendering. */
797 FT_DIV_MOD( TCoord, p, dy, delta, mod );
798
799 x = ras.x + delta;
800 gray_render_scanline( RAS_VAR_ ey1, ras.x, fy1, x, first );
801
802 ey1 += incr;
803 gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
804
805 if ( ey1 != ey2 )
806 {
807 TCoord lift, rem;
808
809
810 p = ONE_PIXEL * dx;
811 FT_DIV_MOD( TCoord, p, dy, lift, rem );
812
813 do
814 {
815 delta = lift;
816 mod += rem;
817 if ( mod >= (TCoord)dy )
818 {
819 mod -= (TCoord)dy;
820 delta++;
821 }
822
823 x2 = x + delta;
825 x, ONE_PIXEL - first,
826 x2, first );
827 x = x2;
828
829 ey1 += incr;
830 gray_set_cell( RAS_VAR_ TRUNC( x ), ey1 );
831 } while ( ey1 != ey2 );
832 }
833
835 x, ONE_PIXEL - first,
836 to_x, fy2 );
837
838 End:
839 ras.x = to_x;
840 ras.y = to_y;
841 }
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:66
int TArea
Definition: ftgrays.c:408
#define FRACT(x)
Definition: ftgrays.c:341
static void gray_render_scanline(RAS_ARG_ TCoord ey, TPos x1, TCoord y1, TPos x2, TCoord y2)
Definition: ftgrays.c:606
#define FT_DIV_MOD(type, dividend, divisor, quotient, remainder)
Definition: ftgrays.c:356
const GLint * first
Definition: glext.h:5794
GLfloat GLfloat p
Definition: glext.h:8902
static Real area(Real A[2], Real B[2], Real C[2])
Definition: polyDBG.cc:50
Definition: comerr.c:44
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG x2
Definition: winddi.h:3710

Referenced by gray_line_to(), gray_render_conic(), and gray_render_cubic().

◆ gray_render_scanline()

static void gray_render_scanline ( RAS_ARG_ TCoord  ey,
TPos  x1,
TCoord  y1,
TPos  x2,
TCoord  y2 
)
static

Definition at line 606 of file ftgrays.c.

611 {
612 TCoord ex1, ex2, fx1, fx2, first, dy, delta, mod;
613 TPos p, dx;
614 int incr;
615
616
617 ex1 = TRUNC( x1 );
618 ex2 = TRUNC( x2 );
619
620 /* trivial case. Happens often */
621 if ( y1 == y2 )
622 {
623 gray_set_cell( RAS_VAR_ ex2, ey );
624 return;
625 }
626
627 fx1 = FRACT( x1 );
628 fx2 = FRACT( x2 );
629
630 /* everything is located in a single cell. That is easy! */
631 /* */
632 if ( ex1 == ex2 )
633 goto End;
634
635 /* ok, we'll have to render a run of adjacent cells on the same */
636 /* scanline... */
637 /* */
638 dx = x2 - x1;
639 dy = y2 - y1;
640
641 if ( dx > 0 )
642 {
643 p = ( ONE_PIXEL - fx1 ) * dy;
645 incr = 1;
646 }
647 else
648 {
649 p = fx1 * dy;
650 first = 0;
651 incr = -1;
652 dx = -dx;
653 }
654
655 /* the fractional part of y-delta is mod/dx. It is essential to */
656 /* keep track of its accumulation for accurate rendering. */
657 /* XXX: y-delta and x-delta below should be related. */
658 FT_DIV_MOD( TCoord, p, dx, delta, mod );
659
660 ras.area += (TArea)( ( fx1 + first ) * delta );
661 ras.cover += delta;
662 y1 += delta;
663 ex1 += incr;
664 gray_set_cell( RAS_VAR_ ex1, ey );
665
666 if ( ex1 != ex2 )
667 {
668 TCoord lift, rem;
669
670
671 p = ONE_PIXEL * dy;
672 FT_DIV_MOD( TCoord, p, dx, lift, rem );
673
674 do
675 {
676 delta = lift;
677 mod += rem;
678 if ( mod >= (TCoord)dx )
679 {
680 mod -= (TCoord)dx;
681 delta++;
682 }
683
684 ras.area += (TArea)( ONE_PIXEL * delta );
685 ras.cover += delta;
686 y1 += delta;
687 ex1 += incr;
688 gray_set_cell( RAS_VAR_ ex1, ey );
689 } while ( ex1 != ex2 );
690 }
691
692 fx1 = ONE_PIXEL - first;
693
694 End:
695 dy = y2 - y1;
696
697 ras.area += (TArea)( ( fx1 + fx2 ) * dy );
698 ras.cover += dy;
699 }
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
Definition: winddi.h:3708
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3709
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG _In_ LONG _In_ LONG y2
Definition: winddi.h:3711

Referenced by gray_render_line().

◆ gray_set_cell()

static void gray_set_cell ( RAS_ARG_ TCoord  ex,
TCoord  ey 
)
static

Definition at line 572 of file ftgrays.c.

574 {
575 /* Move the cell pointer to a new position. We set the `invalid' */
576 /* flag to indicate that the cell isn't part of those we're interested */
577 /* in during the render phase. This means that: */
578 /* */
579 /* . the new vertical position must be within min_ey..max_ey-1. */
580 /* . the new horizontal position must be strictly less than max_ex */
581 /* */
582 /* Note that if a cell is to the left of the clipping region, it is */
583 /* actually set to the (min_ex-1) horizontal position. */
584
585 /* record the current one if it is valid and substantial */
586 if ( !ras.invalid && ( ras.area || ras.cover ) )
588
589 ras.area = 0;
590 ras.cover = 0;
591 ras.ex = FT_MAX( ex, ras.min_ex - 1 );
592 ras.ey = ey;
593
594 ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey ||
595 ex >= ras.max_ex );
596 }
static void gray_record_cell(RAS_ARG)
Definition: ftgrays.c:528
#define FT_MAX(a, b)
Definition: ftobjs.h:71

Referenced by gray_move_to(), gray_render_line(), and gray_render_scanline().

◆ gray_split_conic()

static void gray_split_conic ( FT_Vector base)
static

Definition at line 984 of file ftgrays.c.

985 {
986 TPos a, b;
987
988
989 base[4].x = base[2].x;
990 a = base[0].x + base[1].x;
991 b = base[1].x + base[2].x;
992 base[3].x = b >> 1;
993 base[2].x = ( a + b ) >> 2;
994 base[1].x = a >> 1;
995
996 base[4].y = base[2].y;
997 a = base[0].y + base[1].y;
998 b = base[1].y + base[2].y;
999 base[3].y = b >> 1;
1000 base[2].y = ( a + b ) >> 2;
1001 base[1].y = a >> 1;
1002 }
#define a
Definition: ke_i.h:78

Referenced by gray_render_conic().

◆ gray_split_cubic()

static void gray_split_cubic ( FT_Vector base)
static

Definition at line 1070 of file ftgrays.c.

1071 {
1072 TPos a, b, c;
1073
1074
1075 base[6].x = base[3].x;
1076 a = base[0].x + base[1].x;
1077 b = base[1].x + base[2].x;
1078 c = base[2].x + base[3].x;
1079 base[5].x = c >> 1;
1080 c += b;
1081 base[4].x = c >> 2;
1082 base[1].x = a >> 1;
1083 a += b;
1084 base[2].x = a >> 2;
1085 base[3].x = ( a + c ) >> 3;
1086
1087 base[6].y = base[3].y;
1088 a = base[0].y + base[1].y;
1089 b = base[1].y + base[2].y;
1090 c = base[2].y + base[3].y;
1091 base[5].y = c >> 1;
1092 c += b;
1093 base[4].y = c >> 2;
1094 base[1].y = a >> 1;
1095 a += b;
1096 base[2].y = a >> 2;
1097 base[3].y = ( a + c ) >> 3;
1098 }

Referenced by gray_render_cubic().

◆ gray_sweep()

static void gray_sweep ( RAS_ARG  )
static

Definition at line 1294 of file ftgrays.c.

1295 {
1296 int y;
1297
1298
1299 for ( y = ras.min_ey; y < ras.max_ey; y++ )
1300 {
1301 PCell cell = ras.ycells[y - ras.min_ey];
1302 TCoord x = ras.min_ex;
1303 TArea cover = 0;
1304 TArea area;
1305
1306
1307 for ( ; cell != NULL; cell = cell->next )
1308 {
1309 if ( cover != 0 && cell->x > x )
1310 gray_hline( RAS_VAR_ x, y, cover, cell->x - x );
1311
1312 cover += (TArea)cell->cover * ( ONE_PIXEL * 2 );
1313 area = cover - cell->area;
1314
1315 if ( area != 0 && cell->x >= ras.min_ex )
1316 gray_hline( RAS_VAR_ cell->x, y, area, 1 );
1317
1318 x = cell->x + 1;
1319 }
1320
1321 if ( cover != 0 )
1322 gray_hline( RAS_VAR_ x, y, cover, ras.max_ex - x );
1323
1324 if ( ras.num_spans > 0 ) /* for FT_RASTER_FLAG_DIRECT only */
1325 {
1326 /* flush the span buffer and reset the count */
1327 ras.render_span( y, ras.num_spans, ras.spans, ras.render_span_data );
1328 ras.num_spans = 0;
1329 }
1330 }
1331 }
static void gray_hline(RAS_ARG_ TCoord x, TCoord y, TArea coverage, TCoord acount)
Definition: ftgrays.c:1210

Referenced by gray_convert_glyph().

◆ if()

if ( ft_setjmp(ras.jump_buffer)  = = 0)

Definition at line 1642 of file ftgrays.c.

1643 {
1644 if ( continued )
1646 error = FT_Outline_Decompose( &ras.outline, &func_interface, &ras );
1647 if ( continued )
1649
1650 if ( !ras.invalid )
1652
1653 FT_TRACE7(( "band [%d..%d]: %ld cell%s\n",
1654 ras.min_ey,
1655 ras.max_ey,
1656 ras.num_cells,
1657 ras.num_cells == 1 ? "" : "s" ));
1658 }
FT_Trace_Disable(void)
Definition: ftdebug.c:315
FT_Trace_Enable(void)
Definition: ftdebug.c:324
FT_BEGIN_HEADER FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
Definition: ftoutln.c:43

Variable Documentation

◆ continued

int continued
Initial value:
{
int error

Definition at line 1637 of file ftgrays.c.

Referenced by gray_convert_glyph(), and if().

◆ else

else
Initial value:
{
error = FT_THROW( Memory_Overflow )

Definition at line 1659 of file ftgrays.c.

◆ error

return error

Definition at line 1667 of file ftgrays.c.

Referenced by gray_convert_glyph(), gray_raster_new(), gray_raster_render(), and if().