1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 // mcseemagg@yahoo.com
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
16 // Class scanline_bin - binary scanline.
18 //----------------------------------------------------------------------------
20 // Adaptation for 32-bit screen coordinates (scanline32_bin) has been sponsored by
21 // Liberty Technology Systems, Inc., visit http://lib-sys.com
23 // Liberty Technology Systems, Inc. is the provider of
24 // PostScript and PDF technology for software developers.
26 //----------------------------------------------------------------------------
28 #ifndef AGG_SCANLINE_BIN_INCLUDED
29 #define AGG_SCANLINE_BIN_INCLUDED
31 #include "agg_array.h"
36 //=============================================================scanline_bin
38 // This is binary scaline container which supports the interface
39 // used in the rasterizer::render(). See description of agg_scanline_u8
42 //------------------------------------------------------------------------
46 typedef int32 coord_type
;
54 typedef const span
* const_iterator
;
56 //--------------------------------------------------------------------
64 //--------------------------------------------------------------------
65 void reset(int min_x
, int max_x
)
67 unsigned max_len
= max_x
- min_x
+ 3;
68 if(max_len
> m_spans
.size())
70 m_spans
.resize(max_len
);
72 m_last_x
= 0x7FFFFFF0;
73 m_cur_span
= &m_spans
[0];
76 //--------------------------------------------------------------------
77 void add_cell(int x
, unsigned)
86 m_cur_span
->x
= (int16
)x
;
92 //--------------------------------------------------------------------
93 void add_span(int x
, unsigned len
, unsigned)
97 m_cur_span
->len
= (int16
)(m_cur_span
->len
+ len
);
102 m_cur_span
->x
= (int16
)x
;
103 m_cur_span
->len
= (int16
)len
;
105 m_last_x
= x
+ len
- 1;
108 //--------------------------------------------------------------------
109 void add_cells(int x
, unsigned len
, const void*)
114 //--------------------------------------------------------------------
120 //--------------------------------------------------------------------
123 m_last_x
= 0x7FFFFFF0;
124 m_cur_span
= &m_spans
[0];
127 //--------------------------------------------------------------------
128 int y() const { return m_y
; }
129 unsigned num_spans() const { return unsigned(m_cur_span
- &m_spans
[0]); }
130 const_iterator
begin() const { return &m_spans
[1]; }
133 scanline_bin(const scanline_bin
&);
134 const scanline_bin
operator = (const scanline_bin
&);
138 pod_array
<span
> m_spans
;
147 //===========================================================scanline32_bin
151 typedef int32 coord_type
;
153 //--------------------------------------------------------------------
157 span(coord_type x_
, coord_type len_
) : x(x_
), len(len_
) {}
162 typedef pod_bvector
<span
, 4> span_array_type
;
165 //--------------------------------------------------------------------
169 const_iterator(const span_array_type
& spans
) :
174 const span
& operator*() const { return m_spans
[m_span_idx
]; }
175 const span
* operator->() const { return &m_spans
[m_span_idx
]; }
177 void operator ++ () { ++m_span_idx
; }
180 const span_array_type
& m_spans
;
185 //--------------------------------------------------------------------
186 scanline32_bin() : m_max_len(0), m_last_x(0x7FFFFFF0) {}
188 //--------------------------------------------------------------------
189 void reset(int min_x
, int max_x
)
191 m_last_x
= 0x7FFFFFF0;
192 m_spans
.remove_all();
195 //--------------------------------------------------------------------
196 void add_cell(int x
, unsigned)
200 m_spans
.last().len
++;
204 m_spans
.add(span(coord_type(x
), 1));
209 //--------------------------------------------------------------------
210 void add_span(int x
, unsigned len
, unsigned)
214 m_spans
.last().len
+= coord_type(len
);
218 m_spans
.add(span(coord_type(x
), coord_type(len
)));
220 m_last_x
= x
+ len
- 1;
223 //--------------------------------------------------------------------
224 void add_cells(int x
, unsigned len
, const void*)
229 //--------------------------------------------------------------------
235 //--------------------------------------------------------------------
238 m_last_x
= 0x7FFFFFF0;
239 m_spans
.remove_all();
242 //--------------------------------------------------------------------
243 int y() const { return m_y
; }
244 unsigned num_spans() const { return m_spans
.size(); }
245 const_iterator
begin() const { return const_iterator(m_spans
); }
248 scanline32_bin(const scanline32_bin
&);
249 const scanline32_bin
operator = (const scanline32_bin
&);
254 span_array_type m_spans
;