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 #ifndef AGG_RENDERER_SCANLINE_INCLUDED
17 #define AGG_RENDERER_SCANLINE_INCLUDED
19 #include "agg_basics.h"
20 #include "agg_renderer_base.h"
21 #include "agg_render_scanlines.h"
26 //====================================================renderer_scanline_aa
27 template<class BaseRenderer
, class SpanGenerator
> class renderer_scanline_aa
30 typedef BaseRenderer base_ren_type
;
32 //--------------------------------------------------------------------
33 renderer_scanline_aa(base_ren_type
& ren
, SpanGenerator
& span_gen
) :
39 //--------------------------------------------------------------------
40 void prepare(unsigned max_span_len
)
42 m_span_gen
->prepare(max_span_len
);
45 //--------------------------------------------------------------------
46 template<class Scanline
> void render(const Scanline
& sl
)
49 m_ren
->first_clip_box();
52 int xmin
= m_ren
->xmin();
53 int xmax
= m_ren
->xmax();
55 if(y
>= m_ren
->ymin() && y
<= m_ren
->ymax())
57 unsigned num_spans
= sl
.num_spans();
58 typename
Scanline::const_iterator span
= sl
.begin();
64 const typename
Scanline::cover_type
* covers
= span
->covers
;
90 m_ren
->blend_color_hspan_no_clip(
92 m_span_gen
->generate(x
, y
, len
),
102 while(m_ren
->next_clip_box());
106 base_ren_type
* m_ren
;
107 SpanGenerator
* m_span_gen
;
113 //==============================================renderer_scanline_aa_opaque
114 template<class BaseRenderer
, class SpanGenerator
> class renderer_scanline_aa_opaque
117 typedef BaseRenderer base_ren_type
;
119 //--------------------------------------------------------------------
120 renderer_scanline_aa_opaque(base_ren_type
& ren
, SpanGenerator
& span_gen
) :
122 m_span_gen(&span_gen
)
126 //--------------------------------------------------------------------
127 void prepare(unsigned max_span_len
)
129 m_span_gen
->prepare(max_span_len
);
132 //--------------------------------------------------------------------
133 template<class Scanline
> void render(const Scanline
& sl
)
136 m_ren
->first_clip_box();
139 int xmin
= m_ren
->xmin();
140 int xmax
= m_ren
->xmax();
142 if(y
>= m_ren
->ymin() && y
<= m_ren
->ymax())
144 unsigned num_spans
= sl
.num_spans();
145 typename
Scanline::const_iterator span
= sl
.begin();
151 const typename
Scanline::cover_type
* covers
= span
->covers
;
177 m_ren
->blend_opaque_color_hspan_no_clip(
179 m_span_gen
->generate(x
, y
, len
),
189 while(m_ren
->next_clip_box());
193 base_ren_type
* m_ren
;
194 SpanGenerator
* m_span_gen
;
199 //==============================================renderer_scanline_aa_solid
200 template<class BaseRenderer
> class renderer_scanline_aa_solid
203 typedef BaseRenderer base_ren_type
;
204 typedef typename
base_ren_type::color_type color_type
;
206 //--------------------------------------------------------------------
207 renderer_scanline_aa_solid(base_ren_type
& ren
) :
212 //--------------------------------------------------------------------
213 void color(const color_type
& c
) { m_color
= c
; }
214 const color_type
& color() const { return m_color
; }
216 //--------------------------------------------------------------------
217 void prepare(unsigned) {}
219 //--------------------------------------------------------------------
220 template<class Scanline
> void render(const Scanline
& sl
)
223 unsigned num_spans
= sl
.num_spans();
224 typename
Scanline::const_iterator span
= sl
.begin();
231 m_ren
->blend_solid_hspan(x
, y
, (unsigned)span
->len
,
237 m_ren
->blend_hline(x
, y
, (unsigned)(x
- span
->len
- 1),
247 base_ren_type
* m_ren
;
257 //===================================================renderer_scanline_bin
258 template<class BaseRenderer
, class SpanGenerator
> class renderer_scanline_bin
261 typedef BaseRenderer base_ren_type
;
263 //--------------------------------------------------------------------
264 renderer_scanline_bin(base_ren_type
& ren
, SpanGenerator
& span_gen
) :
266 m_span_gen(&span_gen
)
270 //--------------------------------------------------------------------
271 void prepare(unsigned max_span_len
)
273 m_span_gen
->prepare(max_span_len
);
276 //--------------------------------------------------------------------
277 template<class Scanline
> void render(const Scanline
& sl
)
280 m_ren
->first_clip_box();
283 int xmin
= m_ren
->xmin();
284 int xmax
= m_ren
->xmax();
286 if(y
>= m_ren
->ymin() && y
<= m_ren
->ymax())
288 unsigned num_spans
= sl
.num_spans();
289 typename
Scanline::const_iterator span
= sl
.begin();
295 if(len
< 0) len
= -len
;
309 m_ren
->blend_color_hspan_no_clip(
311 m_span_gen
->generate(x
, y
, len
),
320 while(m_ren
->next_clip_box());
324 base_ren_type
* m_ren
;
325 SpanGenerator
* m_span_gen
;
330 //===============================================renderer_scanline_bin_opaque
331 template<class BaseRenderer
, class SpanGenerator
> class renderer_scanline_bin_opaque
334 typedef BaseRenderer base_ren_type
;
336 //--------------------------------------------------------------------
337 renderer_scanline_bin_opaque(base_ren_type
& ren
, SpanGenerator
& span_gen
) :
339 m_span_gen(&span_gen
)
343 //--------------------------------------------------------------------
344 void prepare(unsigned max_span_len
)
346 m_span_gen
->prepare(max_span_len
);
349 //--------------------------------------------------------------------
350 template<class Scanline
> void render(const Scanline
& sl
)
353 m_ren
->first_clip_box();
356 int xmin
= m_ren
->xmin();
357 int xmax
= m_ren
->xmax();
359 if(y
>= m_ren
->ymin() && y
<= m_ren
->ymax())
361 unsigned num_spans
= sl
.num_spans();
362 typename
Scanline::const_iterator span
= sl
.begin();
368 if(len
< 0) len
= -len
;
382 m_ren
->blend_opaque_color_hspan_no_clip(
384 m_span_gen
->generate(x
, y
, len
),
393 while(m_ren
->next_clip_box());
397 base_ren_type
* m_ren
;
398 SpanGenerator
* m_span_gen
;
404 //=============================================renderer_scanline_bin_solid
405 template<class BaseRenderer
> class renderer_scanline_bin_solid
408 typedef BaseRenderer base_ren_type
;
409 typedef typename
base_ren_type::color_type color_type
;
411 //--------------------------------------------------------------------
412 renderer_scanline_bin_solid(base_ren_type
& ren
) :
417 //--------------------------------------------------------------------
418 void color(const color_type
& c
) { m_color
= c
; }
419 const color_type
& color() const { return m_color
; }
421 //--------------------------------------------------------------------
422 void prepare(unsigned) {}
424 //--------------------------------------------------------------------
425 template<class Scanline
> void render(const Scanline
& sl
)
427 unsigned num_spans
= sl
.num_spans();
428 typename
Scanline::const_iterator span
= sl
.begin();
431 m_ren
->blend_hline(span
->x
,
433 span
->x
- 1 + ((span
->len
< 0) ?
444 base_ren_type
* m_ren
;