[smooth] Simplify span rendering.
This removes unnecessary complexity of span merging and buffering. Instead, the spans are rendered as they come, speeding up the rendering by about 5% percents as a result. * src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed. (gray_TWorker): Remove span buffer and related fields. (gray_sweep, gray_hline): Updated. * include/freetype/ftimage.h: Remove documentation note about `FT_MAX_GRAY_SPANS', which was never in `ftoption.h' and is now gone.
This commit is contained in:
parent
a4c2a31138
commit
cb4388783c
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2016-08-22 Alexei Podtelezhnikov <apodtele@gmail.com>
|
||||||
|
|
||||||
|
[smooth] Simplify span rendering.
|
||||||
|
|
||||||
|
This removes unnecessary complexity of span merging and buffering.
|
||||||
|
Instead, the spans are rendered as they come, speeding up the
|
||||||
|
rendering by about 5% percents as a result.
|
||||||
|
|
||||||
|
* src/smooth/ftgrays.c [FT_MAX_GRAY_SPANS]: Macro removed.
|
||||||
|
(gray_TWorker): Remove span buffer and related fields.
|
||||||
|
(gray_sweep, gray_hline): Updated.
|
||||||
|
|
||||||
|
* include/freetype/ftimage.h: Remove documentation note about
|
||||||
|
`FT_MAX_GRAY_SPANS', which was never in `ftoption.h' and is now gone.
|
||||||
|
|
||||||
2016-08-16 Werner Lemberg <wl@gnu.org>
|
2016-08-16 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
[truetype] Fix `MPS' instruction.
|
[truetype] Fix `MPS' instruction.
|
||||||
|
|
|
@ -860,16 +860,6 @@ FT_BEGIN_HEADER
|
||||||
/* This can be used to write anti-aliased outlines directly to a */
|
/* This can be used to write anti-aliased outlines directly to a */
|
||||||
/* given background bitmap, and even perform translucency. */
|
/* given background bitmap, and even perform translucency. */
|
||||||
/* */
|
/* */
|
||||||
/* Note that the `count' field cannot be greater than a fixed value */
|
|
||||||
/* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */
|
|
||||||
/* `ftoption.h'. By default, this value is set to~32, which means */
|
|
||||||
/* that if there are more than 32~spans on a given scanline, the */
|
|
||||||
/* callback is called several times with the same `y' parameter in */
|
|
||||||
/* order to draw all callbacks. */
|
|
||||||
/* */
|
|
||||||
/* Otherwise, the callback is only called once per scan-line, and */
|
|
||||||
/* only for those scanlines that do have `gray' pixels on them. */
|
|
||||||
/* */
|
|
||||||
typedef void
|
typedef void
|
||||||
(*FT_SpanFunc)( int y,
|
(*FT_SpanFunc)( int y,
|
||||||
int count,
|
int count,
|
||||||
|
|
|
@ -404,9 +404,6 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
} TCell;
|
} TCell;
|
||||||
|
|
||||||
|
|
||||||
/* maximum number of gray spans in a call to the span callback */
|
|
||||||
#define FT_MAX_GRAY_SPANS 32
|
|
||||||
|
|
||||||
/* maximum number of gray cells in the buffer */
|
/* maximum number of gray cells in the buffer */
|
||||||
#if FT_RENDER_POOL_SIZE > 2048
|
#if FT_RENDER_POOL_SIZE > 2048
|
||||||
#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
|
#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
|
||||||
|
@ -445,12 +442,8 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
FT_Outline outline;
|
FT_Outline outline;
|
||||||
FT_Bitmap target;
|
FT_Bitmap target;
|
||||||
|
|
||||||
FT_Span gray_spans[FT_MAX_GRAY_SPANS];
|
|
||||||
int num_gray_spans;
|
|
||||||
|
|
||||||
FT_Raster_Span_Func render_span;
|
FT_Raster_Span_Func render_span;
|
||||||
void* render_span_data;
|
void* render_span_data;
|
||||||
int span_y;
|
|
||||||
|
|
||||||
PCell* ycells;
|
PCell* ycells;
|
||||||
|
|
||||||
|
@ -1353,64 +1346,16 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
coverage = 255;
|
coverage = 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
y += ras.min_ey;
|
|
||||||
x += ras.min_ex;
|
|
||||||
|
|
||||||
if ( coverage )
|
if ( coverage )
|
||||||
{
|
{
|
||||||
FT_Span* span;
|
FT_Span span;
|
||||||
int count;
|
|
||||||
|
|
||||||
|
|
||||||
/* see whether we can add this span to the current list */
|
span.x = (short)( x + ras.min_ex );
|
||||||
count = ras.num_gray_spans;
|
span.len = (unsigned short)acount;
|
||||||
span = ras.gray_spans + count - 1;
|
span.coverage = (unsigned char)coverage;
|
||||||
if ( count > 0 &&
|
|
||||||
span->coverage == coverage &&
|
|
||||||
span->x + span->len == x &&
|
|
||||||
ras.span_y == y )
|
|
||||||
{
|
|
||||||
span->len = (unsigned short)( span->len + acount );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
|
ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
|
||||||
{
|
|
||||||
if ( ras.render_span && count > 0 )
|
|
||||||
ras.render_span( ras.span_y, count, ras.gray_spans,
|
|
||||||
ras.render_span_data );
|
|
||||||
|
|
||||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
||||||
|
|
||||||
if ( count > 0 )
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
|
|
||||||
|
|
||||||
FT_TRACE7(( "y = %3d ", ras.span_y ));
|
|
||||||
span = ras.gray_spans;
|
|
||||||
for ( n = 0; n < count; n++, span++ )
|
|
||||||
FT_TRACE7(( "[%d..%d]:%02x ",
|
|
||||||
span->x, span->x + span->len - 1, span->coverage ));
|
|
||||||
FT_TRACE7(( "\n" ));
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* FT_DEBUG_LEVEL_TRACE */
|
|
||||||
|
|
||||||
ras.num_gray_spans = 0;
|
|
||||||
ras.span_y = (int)y;
|
|
||||||
|
|
||||||
span = ras.gray_spans;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
span++;
|
|
||||||
|
|
||||||
/* add a gray span to the current list */
|
|
||||||
span->x = (short)x;
|
|
||||||
span->len = (unsigned short)acount;
|
|
||||||
span->coverage = (unsigned char)coverage;
|
|
||||||
|
|
||||||
ras.num_gray_spans++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1424,9 +1369,6 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
if ( ras.num_cells == 0 )
|
if ( ras.num_cells == 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ras.num_gray_spans = 0;
|
|
||||||
ras.span_y = 0;
|
|
||||||
|
|
||||||
FT_TRACE7(( "gray_sweep: start\n" ));
|
FT_TRACE7(( "gray_sweep: start\n" ));
|
||||||
|
|
||||||
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
|
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
|
||||||
|
@ -1459,30 +1401,7 @@ typedef ptrdiff_t FT_PtrDist;
|
||||||
ras.count_ex - x );
|
ras.count_ex - x );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ras.render_span && ras.num_gray_spans > 0 )
|
|
||||||
ras.render_span( ras.span_y, ras.num_gray_spans,
|
|
||||||
ras.gray_spans, ras.render_span_data );
|
|
||||||
|
|
||||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
|
||||||
|
|
||||||
if ( ras.num_gray_spans > 0 )
|
|
||||||
{
|
|
||||||
FT_Span* span;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
|
|
||||||
FT_TRACE7(( "y = %3d ", ras.span_y ));
|
|
||||||
span = ras.gray_spans;
|
|
||||||
for ( n = 0; n < ras.num_gray_spans; n++, span++ )
|
|
||||||
FT_TRACE7(( "[%d..%d]:%02x ",
|
|
||||||
span->x, span->x + span->len - 1, span->coverage ));
|
|
||||||
FT_TRACE7(( "\n" ));
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_TRACE7(( "gray_sweep: end\n" ));
|
FT_TRACE7(( "gray_sweep: end\n" ));
|
||||||
|
|
||||||
#endif /* FT_DEBUG_LEVEL_TRACE */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue