1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry (AGG) - Version 2.5
3 // A high quality rendering engine for C++
4 // Copyright (C) 2002-2006 Maxim Shemanarev
5 // Contact: mcseem@antigrain.com
6 //          mcseemagg@yahoo.com
7 //          http://antigrain.com
8 //
9 // AGG is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU General Public License
11 // as published by the Free Software Foundation; either version 2
12 // of the License, or (at your option) any later version.
13 //
14 // AGG is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with AGG; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 // MA 02110-1301, USA.
23 //----------------------------------------------------------------------------
24 //
25 // Adaptation for high precision colors has been sponsored by
26 // Liberty Technology Systems, Inc., visit http://lib-sys.com
27 //
28 // Liberty Technology Systems, Inc. is the provider of
29 // PostScript and PDF technology for software developers.
30 //
31 //----------------------------------------------------------------------------
32 
33 
34 #ifndef AGG_SPAN_PATTERN_RGB_INCLUDED
35 #define AGG_SPAN_PATTERN_RGB_INCLUDED
36 
37 #include "agg_basics.h"
38 
39 namespace agg
40 {
41 
42     //========================================================span_pattern_rgb
43     template<class Source> class span_pattern_rgb
44     {
45     public:
46         typedef Source source_type;
47         typedef typename source_type::color_type color_type;
48         typedef typename source_type::order_type order_type;
49         typedef typename color_type::value_type value_type;
50         typedef typename color_type::calc_type calc_type;
51 
52         //--------------------------------------------------------------------
span_pattern_rgb()53         span_pattern_rgb() {}
span_pattern_rgb(source_type & src,unsigned offset_x,unsigned offset_y)54         span_pattern_rgb(source_type& src,
55                          unsigned offset_x, unsigned offset_y) :
56             m_src(&src),
57             m_offset_x(offset_x),
58             m_offset_y(offset_y),
59             m_alpha(color_type::base_mask)
60         {}
61 
62         //--------------------------------------------------------------------
attach(source_type & v)63         void   attach(source_type& v)      { m_src = &v; }
source()64                source_type& source()       { return *m_src; }
source()65         const  source_type& source() const { return *m_src; }
66 
67         //--------------------------------------------------------------------
offset_x(unsigned v)68         void       offset_x(unsigned v) { m_offset_x = v; }
offset_y(unsigned v)69         void       offset_y(unsigned v) { m_offset_y = v; }
offset_x()70         unsigned   offset_x() const { return m_offset_x; }
offset_y()71         unsigned   offset_y() const { return m_offset_y; }
alpha(value_type v)72         void       alpha(value_type v) { m_alpha = v; }
alpha()73         value_type alpha() const { return m_alpha; }
74 
75         //--------------------------------------------------------------------
prepare()76         void prepare() {}
generate(color_type * span,int x,int y,unsigned len)77         void generate(color_type* span, int x, int y, unsigned len)
78         {
79             x += m_offset_x;
80             y += m_offset_y;
81             const value_type* p = (const value_type*)m_src->span(x, y, len);
82             do
83             {
84                 span->r = p[order_type::R];
85                 span->g = p[order_type::G];
86                 span->b = p[order_type::B];
87                 span->a = m_alpha;
88                 p = m_src->next_x();
89                 ++span;
90             }
91             while(--len);
92         }
93 
94     private:
95         source_type* m_src;
96         unsigned     m_offset_x;
97         unsigned     m_offset_y;
98         value_type   m_alpha;
99 
100     };
101 
102 }
103 
104 #endif
105 
106