1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
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 //----------------------------------------------------------------------------
19 #ifndef AGG_SCANLINE_BIN_INCLUDED
20 #define AGG_SCANLINE_BIN_INCLUDED
22 #include "agg_basics.h"
27 //=============================================================scanline_bin
29 // This is binary scaline container which supports the interface
30 // used in the rasterizer::render(). See description of agg_scanline_u8
34 //-------------------------------------------------------------------------
38 // ************************************
39 // ...Perform vertical clipping here...
40 // ************************************
42 // unsigned num_spans = sl.num_spans();
43 // const agg::scanline_bin::span* cur_span = sl.spans();
48 // len = cur_span->len;
50 // **************************************
51 // ...Perform horizontal clipping here...
52 // **************************************
54 // hor_line(x, y, len)
57 // while(--num_spans);
59 //------------------------------------------------------------------------
69 typedef const span
* const_iterator
;
84 void reset(int min_x
, int max_x
);
85 void add_cell(int x
, unsigned);
86 void add_cells(int x
, unsigned len
, const void*);
87 void add_span(int x
, unsigned len
, unsigned);
88 void finalize(int y
) { m_y
= y
; }
91 int y() const { return m_y
; }
92 unsigned num_spans() const { return unsigned(m_cur_span
- m_spans
); }
93 const_iterator
begin() const { return m_spans
+ 1; }
96 scanline_bin(const scanline_bin
&);
97 const scanline_bin
operator = (const scanline_bin
&);
107 //------------------------------------------------------------------------
108 inline void scanline_bin::reset(int min_x
, int max_x
)
110 unsigned max_len
= max_x
- min_x
+ 3;
111 if(max_len
> m_max_len
)
114 m_spans
= new span
[max_len
];
118 m_cur_span
= m_spans
;
122 //------------------------------------------------------------------------
123 inline void scanline_bin::reset_spans()
126 m_cur_span
= m_spans
;
130 //------------------------------------------------------------------------
131 inline void scanline_bin::add_cell(int x
, unsigned)
140 m_cur_span
->x
= (int16
)x
;
147 //------------------------------------------------------------------------
148 inline void scanline_bin::add_span(int x
, unsigned len
, unsigned)
152 m_cur_span
->len
= (int16
)(m_cur_span
->len
+ len
);
157 m_cur_span
->x
= (int16
)x
;
158 m_cur_span
->len
= (int16
)len
;
160 m_last_x
= x
+ len
- 1;
163 //------------------------------------------------------------------------
164 inline void scanline_bin::add_cells(int x
, unsigned len
, const void*)