xref: /haiku/headers/libs/agg/agg_span_converter.h (revision 95bac3fda53a4cb21880712d7b43f8c21db32a2e)
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.2
3 // Copyright (C) 2002-2004 Maxim Shemanarev (http://www.antigrain.com)
4 //
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.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: mcseem@antigrain.com
12 //          mcseemagg@yahoo.com
13 //          http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 
16 #ifndef AGG_SPAN_CONVERTER_INCLUDED
17 #define AGG_SPAN_CONVERTER_INCLUDED
18 
19 #include "agg_basics.h"
20 
21 namespace agg
22 {
23     //----------------------------------------------------------span_converter
24     template<class SpanGenerator, class Conv> class span_converter
25     {
26     public:
27         typedef typename SpanGenerator::color_type color_type;
28 
29         span_converter(SpanGenerator& span_gen, Conv& conv) :
30             m_span_gen(&span_gen), m_conv(&conv) {}
31 
32         //--------------------------------------------------------------------
33         void prepare(unsigned max_span_len)
34         {
35             m_span_gen->prepare(max_span_len);
36         }
37 
38         //--------------------------------------------------------------------
39         color_type* generate(int x, int y, unsigned len)
40         {
41             color_type* span = m_span_gen->generate(x, y, len);
42             m_conv->convert(span, x, y, len);
43             return span;
44         }
45 
46     private:
47         SpanGenerator* m_span_gen;
48         Conv*          m_conv;
49     };
50 
51 }
52 
53 #endif
54