summaryrefslogtreecommitdiff
path: root/docs/aggpas/scanlines.agdoc.html
blob: d85308fe35bb283af43b571dc2e04bb7a1e35620 (plain)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
<html><head><title>Anti-Grain Geometry - Scanlines and Scanline 
Renderers</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" 
href="scanlines.agdoc_files/agg.css">
</head><body><a name="PAGE_SCANLINES"><b></b></a>


<table style="margin: 0px;" height="1px" width="640px" border="0" 
cellpadding="0" cellspacing="0">
<tbody><tr>
<td bgcolor="#583927"></td>
</tr>
</tbody></table>
<table style="margin: 0px;" width="640px" border="0" cellpadding="0" 
cellspacing="0">
<tbody><tr>
<td>
<table style="margin: 0px;" width="170px" border="0" cellpadding="0" 
cellspacing="0">
<tbody><tr><td><a href="http://www.antigrain.com/index.html" 
class="mpmenu">Home/</a></td></tr>
<tr><td><a href="http://www.antigrain.com/doc/index.html" class="mpmenu">Table
 of Content/</a></td></tr>
<tr><td><a href="" class="mpmenu"></a></td></tr>
<tr><td><a href="" class="mpmenu"></a></td></tr>
<tr><td><a href="" class="mpmenu"></a></td></tr>
<tr><td><a href="" class="mpmenu"></a></td></tr>
</tbody></table>
</td>
<td width="1px" bgcolor="#583927"></td>
<td style="text-align: right;" valign="top" width="450px">
<table style="margin: 0px;" border="0" cellpadding="0" cellspacing="0">
<tbody><tr>
<td><img src="scanlines.agdoc_files/agg_logo.gif" border="0"></td>
</tr>
<tr>
<td>
<table style="margin: 0px;" border="0" cellpadding="0" cellspacing="0">
<tbody><tr height="15px">
<td>&nbsp;&nbsp;<a class="topmenu" 
href="http://www.antigrain.com/news/index.html">News</a>&nbsp;&nbsp;</td>
<td width="1px" bgcolor="#8e521d"></td>
<td>&nbsp;&nbsp;<a class="topmenu" 
href="http://www.antigrain.com/doc/index.html">Docs</a>&nbsp;&nbsp;</td>
<td width="1px" bgcolor="#8e521d"></td>
<td>&nbsp;&nbsp;<a class="topmenu" 
href="http://www.antigrain.com/download/index.html">Download</a>&nbsp;&nbsp;</td>
<td width="1px" bgcolor="#8e521d"></td>
<td>&nbsp;&nbsp;<a class="topmenu" 
href="http://www.antigrain.com/maillist/index.html">Mailing List</a>&nbsp;&nbsp;</td>
<td width="1px" bgcolor="#8e521d"></td>
<td>&nbsp;&nbsp;<a class="topmenu" 
href="http://www.antigrain.com/cvs/index.html">CVS</a>&nbsp;&nbsp;</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
<table style="margin: 0px;" height="1px" width="640px" bgcolor="#583927"
 border="0" cellpadding="0" cellspacing="0"><tbody><tr><td></td></tr></tbody></table>


<table width="640px"><tbody><tr><td style="text-align: justify;"><p>
</p></td></tr></tbody></table>

<table width="640px"><tbody><tr><td><h1>Scanlines and Scanline Renderers</h1></td></tr></tbody></table>

<table class="toc" width="640px"><tbody><tr><td>
    <div style="margin-left: 2em; padding: 3px; font-size: 14px;"><a 
href="#toc0001"><b>Scanline Containers</b></a>
        <div style="margin-left: 2em; font-size: 12px;"><a 
href="#toc0002">Introduction</a></div>
        <div style="margin-left: 2em; font-size: 12px;"><a 
href="#toc0003">Interfaces</a>
            <div style="margin-left: 2em; font-size: 12px;"><a 
href="#toc0004">Filling Interface (put)</a></div>
            <div style="margin-left: 2em; font-size: 12px;"><a 
href="#toc0005">Iterating Interface (get)</a></div></div></div>
    <div style="margin-left: 2em; padding: 3px; font-size: 14px;"><a 
href="#toc0006"><b>Scanline Renderers</b></a></div>

</td></tr></tbody></table>


<h2>Scanline Containers<a name="toc0001"></a></h2>

<h3>Introduction<a name="toc0002"></a></h3>

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>The 
low level renderers operate with
simplest data and they are very simple too. In fact, the pixel format
renderers are not the obligatory part of the library and can be 
replaced or rewritten. For example, if you have an API with similar
functionality, but hardware accelerated, it will be better to use it
instead of pure software blending (the low level renderers are 
essentially alpha-blenders). It's also possible to use Intel SSE/SSE2
to write optimized renderers. All other rendering functionality in 
AGG is based on these simple classes.</p></td></tr></tbody></table>

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>To 
draw Anti-Aliased primitives one shoud <b>rasterize</b> them first.
The primary rasterization technique in AGG is scanline based. That is, 
a polygon is converted into a number of horizontal scanlines and then
the scanlines are being rendered one by one. Again, the scanline
rasterizer is not the only class that can produce scanlines. It can 
be some container or even your own super-ultra-mega rasterizer.</p></td></tr></tbody></table>

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>To 
transfer information from a rasterizer to the scanline renderer 
there scanline containers are used.
A scanline consists of a number of horizontal, non-intersecting spans.
All spans must be ordered by X. It means that there is no sorting 
operation provided, the order must be perserved when adding spans
to the scanline. If the order is not guaranteed it can result in 
undefined behaviour.</p></td></tr></tbody></table> 

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>In <b>AGG</b>
 there are three types of scanline containers:
</p><ul type="disc">
<li><code>scanline_u</code> - unpacked scaline container</li>
<li><code>scanline_p</code> - packed scanline container</li>
<li><code><a 
href="http://www.antigrain.com/__code/include/agg_scanline_bin.h.html#scanline_bin">scanline_bin</a></code>
 - container for binary, &#8220;aliased&#8221; scanlines</li></ul><p></p></td></tr></tbody></table>

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>First
 two containers can keep <b><nobr>Anti-Aliasing</nobr></b> information, 
the third one cannot.</p></td></tr></tbody></table>

<table class="warning" width="640px"><tbody><tr><td><b>IMPORTANT!</b><br>
All the scanline containers are optimized for speed, not for 
memory usage. In fact, it allocates memory for the worst case, 
so there is some overhead. It's not critical when you use only
few scanline containers, but it's not a good idea to use an 
array of scanlines to store the whole shape because it will take
more memory than the resulting image.
</td></tr></tbody></table>


<table width="640px"><tbody><tr><td style="text-align: justify;"><p>The 
difference between <b>packed</b> and <b>unpacked</b> scanline 
containers is that the <b>unpacked</b> scaline always keeps the 
coverage values for all pixels including the ones that are 
fully covered by a polygon. In the <b>packed</b> scanline 
all pixels with the same coverage value are merged into <b>solid</b>
spans.
</p></td></tr></tbody></table><table width="640px"><tbody><tr><td><center><img
 src="scanlines.agdoc_files/scanline_u.gif" title="" border="0"><br><i></i></center></td></tr></tbody></table>
<table width="640px"><tbody><tr><td><center><img 
src="scanlines.agdoc_files/scanline_p.gif" title="" border="0"><br><i></i></center></td></tr></tbody></table>

<table width="640px"><tbody><tr><td style="text-align: justify;"><p>It 
can seem it's always better to use the packed version, but in 
practice it's not so. The scanline_p works faster when rendering 
large solid polygons, that is when the area of the polygon is 
much larger than the perimeter in the meaning of the number
of pixels. But when renering text it's definitely better to use
the scanline_u because of much less number of processed spans
The difference is about three times and the number of spans 
is also important for the overall performance. Besides, in most
of the span generators, such as gradients, Gouraud shader, or 
image transformers, the number of spans becomes even more critical, 
and so, the scanline_p is not used there.</p></td></tr></tbody></table>


<h3>Interfaces<a name="toc0003"></a></h3>

<h4>Filling Interface (put)<a name="toc0004"></a></h4>

<h4>Iterating Interface (get)<a name="toc0005"></a></h4>


<br><h2>Scanline Renderers<a name="toc0006"></a></h2>

<br><table style="margin: 0px;" height="1px" width="640px" 
bgcolor="#583927" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td></td></tr></tbody></table>
<table width="640px" border="0" cellpadding="0" cellspacing="0">
<tbody><tr><td><center><span class="authors">
Copyright <span class="larger">©</span> 2002-2006
<a href="http://www.antigrain.com/mcseem/index.html"><b>Maxim Shemanarev</b></a>
</span></center></td></tr>
<tr><td><center><span class="authors">
Web Design and Programming
<a href="http://www.antigrain.com/mcseem/index.html"><b>Maxim Shemanarev</b></a>
</span></center></td></tr>
</tbody></table>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body></html>