xref: /haiku/headers/libs/agg/agg_span_solid.h (revision 39241fe22890fb958b6ba32d6ab9526da98be187)
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 // span_solid_rgba8
17 //
18 //----------------------------------------------------------------------------
19 
20 #ifndef AGG_SPAN_SOLID_INCLUDED
21 #define AGG_SPAN_SOLID_INCLUDED
22 
23 #include "agg_basics.h"
24 #include "agg_span_generator.h"
25 
26 namespace agg
27 {
28     //--------------------------------------------------------------span_solid
29     template<class ColorT, class Allocator = span_allocator<ColorT> >
30     class span_solid : public span_generator<ColorT, Allocator>
31     {
32     public:
33         typedef Allocator alloc_type;
34         typedef ColorT color_type;
35         typedef span_generator<color_type, alloc_type> base_type;
36 
37         //--------------------------------------------------------------------
38         span_solid(alloc_type& alloc) : base_type(alloc) {}
39 
40         //--------------------------------------------------------------------
41         void color(const color_type& c) { m_color = c; }
42         const color_type& color() const { return m_color; }
43 
44         //--------------------------------------------------------------------
45         color_type* generate(int x, int y, unsigned len)
46         {
47             color_type* span = base_type::allocator().span();
48             do
49             {
50                 *span++ = m_color;
51             }
52             while(--len);
53             return base_type::allocator().span();
54         }
55 
56     private:
57         color_type m_color;
58     };
59 
60 
61 }
62 
63 #endif
64