ref: cb4388783cecc893d0542541f3326f3614ca209d
parent: a4c2a31138221165db524ca02f28f0b54698b305
author: Alexei Podtelezhnikov <[email protected]>
date: Mon Aug 22 19:06:45 EDT 2016
[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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2016-08-22 Alexei Podtelezhnikov <[email protected]>
+
+ [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 <[email protected]>
[truetype] Fix `MPS' instruction.
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -860,16 +860,6 @@
/* This can be used to write anti-aliased outlines directly to a */
/* 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
(*FT_SpanFunc)( int y,
int count,
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -404,9 +404,6 @@
} 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 */
#if FT_RENDER_POOL_SIZE > 2048
#define FT_MAX_GRAY_POOL ( FT_RENDER_POOL_SIZE / sizeof ( TCell ) )
@@ -445,12 +442,8 @@
FT_Outline outline;
FT_Bitmap target;
- FT_Span gray_spans[FT_MAX_GRAY_SPANS];
- int num_gray_spans;
-
FT_Raster_Span_Func render_span;
void* render_span_data;
- int span_y;
PCell* ycells;
@@ -1353,64 +1346,16 @@
coverage = 255;
}
- y += ras.min_ey;
- x += ras.min_ex;
-
if ( coverage )
{
- FT_Span* span;
- int count;
+ FT_Span span;
- /* see whether we can add this span to the current list */
- count = ras.num_gray_spans;
- span = ras.gray_spans + count - 1;
- if ( count > 0 &&
- span->coverage == coverage &&
- span->x + span->len == x &&
- ras.span_y == y )
- {
- span->len = (unsigned short)( span->len + acount );
- return;
- }
+ span.x = (short)( x + ras.min_ex );
+ span.len = (unsigned short)acount;
+ span.coverage = (unsigned char)coverage;
- if ( ras.span_y != y || count >= FT_MAX_GRAY_SPANS )
- {
- 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++;
+ ras.render_span( y + ras.min_ey, 1, &span, ras.render_span_data );
}
}
@@ -1424,9 +1369,6 @@
if ( ras.num_cells == 0 )
return;
- ras.num_gray_spans = 0;
- ras.span_y = 0;
-
FT_TRACE7(( "gray_sweep: start\n" ));
for ( yindex = 0; yindex < ras.count_ey; yindex++ )
@@ -1459,30 +1401,7 @@
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" ));
-
-#endif /* FT_DEBUG_LEVEL_TRACE */
-
}