[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
diff --git a/ChangeLog b/ChangeLog
index cfb9ae5..04e9873 100644
--- a/ChangeLog
+++ b/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>
[truetype] Fix `MPS' instruction.
diff --git a/include/freetype/ftimage.h b/include/freetype/ftimage.h
index 28b2704..4f86c56 100644
--- a/include/freetype/ftimage.h
+++ b/include/freetype/ftimage.h
@@ -860,16 +860,6 @@ FT_BEGIN_HEADER
/* 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,
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index f23dbe2..6f438ab 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -404,9 +404,6 @@ typedef ptrdiff_t FT_PtrDist;
} 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 @@ typedef ptrdiff_t FT_PtrDist;
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 @@ typedef ptrdiff_t FT_PtrDist;
coverage = 255;
}
- y += ras.min_ey;
- x += ras.min_ex;
-
if ( coverage )
{
- FT_Span* span;
- int count;
-
-
- /* 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;
- }
-
- 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" ));
- }
+ FT_Span span;
-#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;
+ span.x = (short)( x + ras.min_ex );
+ 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 @@ typedef ptrdiff_t FT_PtrDist;
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 @@ typedef ptrdiff_t FT_PtrDist;
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 */
-
}