... |
... |
@@ -479,14 +479,11 @@ typedef ptrdiff_t FT_PtrDist; |
479
|
479
|
|
480
|
480
|
PCell cell; /* current cell */
|
481
|
481
|
PCell cell_free; /* call allocation next free slot */
|
482
|
|
- PCell cell_limit; /* cell allocation limit */
|
|
482
|
+ PCell cell_null; /* last cell, used as dumpster and limit */
|
483
|
483
|
|
484
|
484
|
PCell* ycells; /* array of cell linked-lists; one per */
|
485
|
485
|
/* vertical coordinate in the current band */
|
486
|
486
|
|
487
|
|
- PCell cells; /* cell storage area */
|
488
|
|
- FT_PtrDist max_cells; /* cell storage capacity */
|
489
|
|
-
|
490
|
487
|
TPos x, y; /* last point position */
|
491
|
488
|
|
492
|
489
|
FT_Outline outline; /* input outline */
|
... |
... |
@@ -507,22 +504,10 @@ typedef ptrdiff_t FT_PtrDist; |
507
|
504
|
static gray_TWorker ras;
|
508
|
505
|
#endif
|
509
|
506
|
|
510
|
|
- /*
|
511
|
|
- * Return a pointer to the 'null cell', used as a sentinel at the end of
|
512
|
|
- * all `ycells` linked lists. Its x coordinate should be maximal to
|
513
|
|
- * ensure no NULL checks are necessary when looking for an insertion point
|
514
|
|
- * in `gray_set_cell`. Other loops should check the cell pointer with
|
515
|
|
- * CELL_IS_NULL() to detect the end of the list.
|
516
|
|
- */
|
517
|
|
-#define NULL_CELL_PTR( ras ) (ras).cells
|
518
|
|
-
|
519
|
507
|
/* The |x| value of the null cell. Must be the largest possible */
|
520
|
508
|
/* integer value stored in a `TCell.x` field. */
|
521
|
509
|
#define CELL_MAX_X_VALUE INT_MAX
|
522
|
510
|
|
523
|
|
- /* Return true iff |cell| points to the null cell. */
|
524
|
|
-#define CELL_IS_NULL( cell ) ( (cell)->x == CELL_MAX_X_VALUE )
|
525
|
|
-
|
526
|
511
|
|
527
|
512
|
#define FT_INTEGRATE( ras, a, b ) \
|
528
|
513
|
ras.cell->cover = ADD_INT( ras.cell->cover, a ), \
|
... |
... |
@@ -553,7 +538,7 @@ typedef ptrdiff_t FT_PtrDist; |
553
|
538
|
|
554
|
539
|
printf( "%3d:", y );
|
555
|
540
|
|
556
|
|
- for ( ; !CELL_IS_NULL( cell ); cell = cell->next )
|
|
541
|
+ for ( ; cell != ras.cell_null; cell = cell->next )
|
557
|
542
|
printf( " (%3d, c:%4d, a:%6d)",
|
558
|
543
|
cell->x, cell->cover, cell->area );
|
559
|
544
|
printf( "\n" );
|
... |
... |
@@ -572,7 +557,7 @@ typedef ptrdiff_t FT_PtrDist; |
572
|
557
|
TCoord ey )
|
573
|
558
|
{
|
574
|
559
|
/* Move the cell pointer to a new position in the linked list. We use */
|
575
|
|
- /* NULL to indicate that the cell is outside of the clipping region */
|
|
560
|
+ /* a dumpster null cell for everything outside of the clipping region */
|
576
|
561
|
/* during the render phase. This means that: */
|
577
|
562
|
/* */
|
578
|
563
|
/* . the new vertical position must be within min_ey..max_ey-1. */
|
... |
... |
@@ -585,7 +570,7 @@ typedef ptrdiff_t FT_PtrDist; |
585
|
570
|
|
586
|
571
|
|
587
|
572
|
if ( ey_index < 0 || ey_index >= ras.count_ey || ex >= ras.max_ex )
|
588
|
|
- ras.cell = NULL_CELL_PTR( ras );
|
|
573
|
+ ras.cell = ras.cell_null;
|
589
|
574
|
else
|
590
|
575
|
{
|
591
|
576
|
PCell* pcell = ras.ycells + ey_index;
|
... |
... |
@@ -609,7 +594,7 @@ typedef ptrdiff_t FT_PtrDist; |
609
|
594
|
|
610
|
595
|
/* insert new cell */
|
611
|
596
|
cell = ras.cell_free++;
|
612
|
|
- if ( cell >= ras.cell_limit )
|
|
597
|
+ if ( cell >= ras.cell_null )
|
613
|
598
|
ft_longjmp( ras.jump_buffer, 1 );
|
614
|
599
|
|
615
|
600
|
cell->x = ex;
|
... |
... |
@@ -1483,7 +1468,7 @@ typedef ptrdiff_t FT_PtrDist; |
1483
|
1468
|
unsigned char* line = ras.target.origin - ras.target.pitch * y;
|
1484
|
1469
|
|
1485
|
1470
|
|
1486
|
|
- for ( ; !CELL_IS_NULL( cell ); cell = cell->next )
|
|
1471
|
+ for ( ; cell != ras.cell_null; cell = cell->next )
|
1487
|
1472
|
{
|
1488
|
1473
|
TArea area;
|
1489
|
1474
|
|
... |
... |
@@ -1534,7 +1519,7 @@ typedef ptrdiff_t FT_PtrDist; |
1534
|
1519
|
TArea cover = 0;
|
1535
|
1520
|
|
1536
|
1521
|
|
1537
|
|
- for ( ; !CELL_IS_NULL( cell ); cell = cell->next )
|
|
1522
|
+ for ( ; cell != ras.cell_null; cell = cell->next )
|
1538
|
1523
|
{
|
1539
|
1524
|
TArea area;
|
1540
|
1525
|
|
... |
... |
@@ -1914,11 +1899,11 @@ typedef ptrdiff_t FT_PtrDist; |
1914
|
1899
|
if ( continued )
|
1915
|
1900
|
FT_Trace_Enable();
|
1916
|
1901
|
|
1917
|
|
- FT_TRACE7(( "band [%d..%d]: %ld cell%s\n",
|
|
1902
|
+ FT_TRACE7(( "band [%d..%d]: %ld cell%s remaining/\n",
|
1918
|
1903
|
ras.min_ey,
|
1919
|
1904
|
ras.max_ey,
|
1920
|
|
- ras.cell_free - ras.cells,
|
1921
|
|
- ras.cell_free - ras.cells == 1 ? "" : "s" ));
|
|
1905
|
+ ras.cell_null - ras.cell_free,
|
|
1906
|
+ ras.cell_null - ras.cell_free == 1 ? "" : "s" ));
|
1922
|
1907
|
}
|
1923
|
1908
|
else
|
1924
|
1909
|
{
|
... |
... |
@@ -1948,7 +1933,16 @@ typedef ptrdiff_t FT_PtrDist; |
1948
|
1933
|
int continued = 0;
|
1949
|
1934
|
|
1950
|
1935
|
|
|
1936
|
+ /* Initialize the null cell at the end of the poll. */
|
|
1937
|
+ ras.cell_null = buffer + FT_MAX_GRAY_POOL - 1;
|
|
1938
|
+ ras.cell_null->x = CELL_MAX_X_VALUE;
|
|
1939
|
+ ras.cell_null->area = 0;
|
|
1940
|
+ ras.cell_null->cover = 0;
|
|
1941
|
+ ras.cell_null->next = NULL;;
|
|
1942
|
+
|
1951
|
1943
|
/* set up vertical bands */
|
|
1944
|
+ ras.ycells = (PCell*)buffer;
|
|
1945
|
+
|
1952
|
1946
|
if ( height > n )
|
1953
|
1947
|
{
|
1954
|
1948
|
/* two divisions rounded up */
|
... |
... |
@@ -1956,23 +1950,6 @@ typedef ptrdiff_t FT_PtrDist; |
1956
|
1950
|
height = ( height + n - 1 ) / n;
|
1957
|
1951
|
}
|
1958
|
1952
|
|
1959
|
|
- /* memory management */
|
1960
|
|
- n = ( height * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) / sizeof ( TCell );
|
1961
|
|
-
|
1962
|
|
- ras.cells = buffer + n;
|
1963
|
|
- ras.max_cells = (FT_PtrDist)( FT_MAX_GRAY_POOL - n );
|
1964
|
|
- ras.cell_limit = ras.cells + ras.max_cells;
|
1965
|
|
- ras.ycells = (PCell*)buffer;
|
1966
|
|
-
|
1967
|
|
- /* Initialize the null cell at the start of the `cells` array. */
|
1968
|
|
- /* Note that this requires `ras.cell_free` initialization to skip */
|
1969
|
|
- /* over the first entry in the array. */
|
1970
|
|
- PCell null_cell = NULL_CELL_PTR( ras );
|
1971
|
|
- null_cell->x = CELL_MAX_X_VALUE;
|
1972
|
|
- null_cell->area = 0;
|
1973
|
|
- null_cell->cover = 0;
|
1974
|
|
- null_cell->next = NULL;;
|
1975
|
|
-
|
1976
|
1953
|
for ( y = yMin; y < yMax; )
|
1977
|
1954
|
{
|
1978
|
1955
|
ras.min_ey = y;
|
... |
... |
@@ -1991,10 +1968,14 @@ typedef ptrdiff_t FT_PtrDist; |
1991
|
1968
|
|
1992
|
1969
|
|
1993
|
1970
|
for ( w = 0; w < width; ++w )
|
1994
|
|
- ras.ycells[w] = null_cell;
|
|
1971
|
+ ras.ycells[w] = ras.cell_null;
|
|
1972
|
+
|
|
1973
|
+ /* memory management: skip ycells */
|
|
1974
|
+ n = ( width * sizeof ( PCell ) + sizeof ( TCell ) - 1 ) /
|
|
1975
|
+ sizeof ( TCell );
|
1995
|
1976
|
|
1996
|
|
- ras.cell_free = ras.cells + 1; /* NOTE: Skip over the null cell. */
|
1997
|
|
- ras.cell = null_cell;
|
|
1977
|
+ ras.cell_free = buffer + n;
|
|
1978
|
+ ras.cell = ras.cell_null;
|
1998
|
1979
|
ras.min_ey = band[1];
|
1999
|
1980
|
ras.max_ey = band[0];
|
2000
|
1981
|
ras.count_ey = width;
|