[smooth] Operate in absolute bitmap coordinates.
Simpler bitmap addressing improves performance by 1.5%. * src/smooth/ftgrays.c (gray_TWorker): Remove count fields. (gray_dump_cells, gray_find_cell, gray_set_cell, gray_hline, gray_sweep, gray_convert_glyph, gray_raster_render): Updated.
This commit is contained in:
parent
44b172e883
commit
9d0a3bd848
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2016-09-06 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||||
|
|
||||||
|
[smooth] Operate in absolute bitmap coordinates.
|
||||||
|
|
||||||
|
Simpler bitmap addressing improves performance by 1.5%.
|
||||||
|
|
||||||
|
* src/smooth/ftgrays.c (gray_TWorker): Remove count fields.
|
||||||
|
(gray_dump_cells, gray_find_cell, gray_set_cell, gray_hline,
|
||||||
|
gray_sweep, gray_convert_glyph, gray_raster_render): Updated.
|
||||||
|
|
||||||
2016-09-06 Alexei Podtelezhnikov <apodtele@gmail.com>
|
2016-09-06 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||||
|
|
||||||
[smooth] Improve contour start (take 2).
|
[smooth] Improve contour start (take 2).
|
||||||
|
|
|
@ -433,7 +433,6 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
TCoord ex, ey;
|
TCoord ex, ey;
|
||||||
TCoord min_ex, max_ex;
|
TCoord min_ex, max_ex;
|
||||||
TCoord min_ey, max_ey;
|
TCoord min_ey, max_ey;
|
||||||
TCoord count_ex, count_ey;
|
|
||||||
|
|
||||||
TArea area;
|
TArea area;
|
||||||
TCoord cover;
|
TCoord cover;
|
||||||
|
@ -481,17 +480,17 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
static void
|
static void
|
||||||
gray_dump_cells( RAS_ARG )
|
gray_dump_cells( RAS_ARG )
|
||||||
{
|
{
|
||||||
int yindex;
|
int y;
|
||||||
|
|
||||||
|
|
||||||
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
|
for ( y = ras.min_ey; y < ras.max_ey; y++ )
|
||||||
{
|
{
|
||||||
PCell cell;
|
PCell cell = ras.ycells[y - ras.min_ey];
|
||||||
|
|
||||||
|
|
||||||
printf( "%3d:", yindex );
|
printf( "%3d:", y );
|
||||||
|
|
||||||
for ( cell = ras.ycells[yindex]; cell != NULL; cell = cell->next )
|
for ( ; cell != NULL; cell = cell->next )
|
||||||
printf( " (%3d, c:%4d, a:%6d)",
|
printf( " (%3d, c:%4d, a:%6d)",
|
||||||
cell->x, cell->cover, cell->area );
|
cell->x, cell->cover, cell->area );
|
||||||
printf( "\n" );
|
printf( "\n" );
|
||||||
|
@ -512,10 +511,10 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
TCoord x = ras.ex;
|
TCoord x = ras.ex;
|
||||||
|
|
||||||
|
|
||||||
if ( x > ras.count_ex )
|
if ( x > ras.max_ex )
|
||||||
x = ras.count_ex;
|
x = ras.max_ex;
|
||||||
|
|
||||||
pcell = &ras.ycells[ras.ey];
|
pcell = &ras.ycells[ras.ey - ras.min_ey];
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
cell = *pcell;
|
cell = *pcell;
|
||||||
|
@ -578,14 +577,11 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
/* All cells that are on the left of the clipping region go to the */
|
/* All cells that are on the left of the clipping region go to the */
|
||||||
/* min_ex - 1 horizontal position. */
|
/* min_ex - 1 horizontal position. */
|
||||||
ey -= ras.min_ey;
|
|
||||||
|
|
||||||
if ( ex > ras.max_ex )
|
if ( ex > ras.max_ex )
|
||||||
ex = ras.max_ex;
|
ex = ras.max_ex;
|
||||||
|
|
||||||
ex -= ras.min_ex;
|
if ( ex < ras.min_ex )
|
||||||
if ( ex < 0 )
|
ex = ras.min_ex - 1;
|
||||||
ex = -1;
|
|
||||||
|
|
||||||
/* are we moving to a different cell ? */
|
/* are we moving to a different cell ? */
|
||||||
if ( ex != ras.ex || ey != ras.ey )
|
if ( ex != ras.ex || ey != ras.ey )
|
||||||
|
@ -600,8 +596,8 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
ras.ey = ey;
|
ras.ey = ey;
|
||||||
}
|
}
|
||||||
|
|
||||||
ras.invalid = ( (unsigned int)ey >= (unsigned int)ras.count_ey ||
|
ras.invalid = ( ey >= ras.max_ey || ey < ras.min_ey ||
|
||||||
ex >= ras.count_ex );
|
ex >= ras.max_ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1281,17 +1277,15 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
|
if ( ras.render_span ) /* for FT_RASTER_FLAG_DIRECT only */
|
||||||
{
|
{
|
||||||
span.x = (short)( x + ras.min_ex );
|
span.x = (short)x;
|
||||||
span.len = (unsigned short)acount;
|
span.len = (unsigned short)acount;
|
||||||
span.coverage = (unsigned char)coverage;
|
span.coverage = (unsigned char)coverage;
|
||||||
|
|
||||||
ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
|
ras.render_span( y, 1, &span, ras.render_span_data );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned char* q = ras.target.origin -
|
unsigned char* q = ras.target.origin - ras.target.pitch * y + x;
|
||||||
ras.target.pitch * ( y + ras.min_ey ) +
|
|
||||||
x + ras.min_ex;
|
|
||||||
unsigned char c = (unsigned char)coverage;
|
unsigned char c = (unsigned char)coverage;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1319,7 +1313,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
static void
|
static void
|
||||||
gray_sweep( RAS_ARG )
|
gray_sweep( RAS_ARG )
|
||||||
{
|
{
|
||||||
int yindex;
|
int y;
|
||||||
|
|
||||||
|
|
||||||
if ( ras.num_cells == 0 )
|
if ( ras.num_cells == 0 )
|
||||||
|
@ -1327,11 +1321,11 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
FT_TRACE7(( "gray_sweep: start\n" ));
|
FT_TRACE7(( "gray_sweep: start\n" ));
|
||||||
|
|
||||||
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
|
for ( y = ras.min_ey; y < ras.max_ey; y++ )
|
||||||
{
|
{
|
||||||
PCell cell = ras.ycells[yindex];
|
PCell cell = ras.ycells[y - ras.min_ey];
|
||||||
TCoord cover = 0;
|
TCoord cover = 0;
|
||||||
TCoord x = 0;
|
TCoord x = ras.min_ex;
|
||||||
|
|
||||||
|
|
||||||
for ( ; cell != NULL; cell = cell->next )
|
for ( ; cell != NULL; cell = cell->next )
|
||||||
|
@ -1340,21 +1334,21 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
|
|
||||||
if ( cell->x > x && cover != 0 )
|
if ( cell->x > x && cover != 0 )
|
||||||
gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ),
|
gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ),
|
||||||
cell->x - x );
|
cell->x - x );
|
||||||
|
|
||||||
cover += cell->cover;
|
cover += cell->cover;
|
||||||
area = (TArea)cover * ( ONE_PIXEL * 2 ) - cell->area;
|
area = (TArea)cover * ( ONE_PIXEL * 2 ) - cell->area;
|
||||||
|
|
||||||
if ( area != 0 && cell->x >= 0 )
|
if ( area != 0 && cell->x >= ras.min_ex )
|
||||||
gray_hline( RAS_VAR_ cell->x, yindex, area, 1 );
|
gray_hline( RAS_VAR_ cell->x, y, area, 1 );
|
||||||
|
|
||||||
x = cell->x + 1;
|
x = cell->x + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cover != 0 )
|
if ( cover != 0 )
|
||||||
gray_hline( RAS_VAR_ x, yindex, (TArea)cover * ( ONE_PIXEL * 2 ),
|
gray_hline( RAS_VAR_ x, y, (TArea)cover * ( ONE_PIXEL * 2 ),
|
||||||
ras.count_ex - x );
|
ras.max_ex - x );
|
||||||
}
|
}
|
||||||
|
|
||||||
FT_TRACE7(( "gray_sweep: end\n" ));
|
FT_TRACE7(( "gray_sweep: end\n" ));
|
||||||
|
@ -1769,6 +1763,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
{
|
{
|
||||||
TCell buffer[FT_MAX_GRAY_POOL];
|
TCell buffer[FT_MAX_GRAY_POOL];
|
||||||
TCoord band_size = FT_MAX_GRAY_POOL / 8;
|
TCoord band_size = FT_MAX_GRAY_POOL / 8;
|
||||||
|
TCoord count = ras.max_ey - ras.min_ey;
|
||||||
int num_bands;
|
int num_bands;
|
||||||
TCoord min, max, max_y;
|
TCoord min, max, max_y;
|
||||||
TCoord bands[32]; /* enough to accommodate bisections */
|
TCoord bands[32]; /* enough to accommodate bisections */
|
||||||
|
@ -1776,11 +1771,11 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
|
|
||||||
|
|
||||||
/* set up vertical bands */
|
/* set up vertical bands */
|
||||||
if ( ras.count_ey > band_size )
|
if ( count > band_size )
|
||||||
{
|
{
|
||||||
/* two divisions rounded up */
|
/* two divisions rounded up */
|
||||||
num_bands = (int)( ( ras.count_ey + band_size - 1) / band_size );
|
num_bands = (int)( ( count + band_size - 1) / band_size );
|
||||||
band_size = ( ras.count_ey + num_bands - 1 ) / num_bands;
|
band_size = ( count + num_bands - 1 ) / num_bands;
|
||||||
}
|
}
|
||||||
|
|
||||||
min = ras.min_ey;
|
min = ras.min_ey;
|
||||||
|
@ -1826,7 +1821,6 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
ras.invalid = 1;
|
ras.invalid = 1;
|
||||||
ras.min_ey = band[1];
|
ras.min_ey = band[1];
|
||||||
ras.max_ey = ras.ey = band[0];
|
ras.max_ey = ras.ey = band[0];
|
||||||
ras.count_ey = width;
|
|
||||||
|
|
||||||
error = gray_convert_glyph_inner( RAS_VAR );
|
error = gray_convert_glyph_inner( RAS_VAR );
|
||||||
|
|
||||||
|
@ -1971,9 +1965,6 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
|
if ( ras.max_ex <= ras.min_ex || ras.max_ey <= ras.min_ey )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ras.count_ex = ras.max_ex - ras.min_ex;
|
|
||||||
ras.count_ey = ras.max_ey - ras.min_ey;
|
|
||||||
|
|
||||||
return gray_convert_glyph( RAS_VAR );
|
return gray_convert_glyph( RAS_VAR );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue