update dev300-m58
[ooovba.git] / agg / inc / agg_span_pattern_rgba.h
blobecc0435eb298ef71ee564a41b1a125e6178649ab
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.3
3 // Copyright (C) 2002-2005 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 //----------------------------------------------------------------------------
16 // Adaptation for high precision colors has been sponsored by
17 // Liberty Technology Systems, Inc., visit http://lib-sys.com
19 // Liberty Technology Systems, Inc. is the provider of
20 // PostScript and PDF technology for software developers.
21 //
22 //----------------------------------------------------------------------------
25 #ifndef AGG_SPAN_PATTERN_RGBA_INCLUDED
26 #define AGG_SPAN_PATTERN_RGBA_INCLUDED
28 #include "agg_basics.h"
29 #include "agg_pixfmt_rgba.h"
30 #include "agg_span_pattern.h"
32 namespace agg
35 //======================================================span_pattern_rgba
36 template<class ColorT,
37 class Order,
38 class WrapModeX,
39 class WrapModeY,
40 class Allocator = span_allocator<ColorT> >
41 class span_pattern_rgba : public span_pattern_base<ColorT, Allocator>
43 public:
44 typedef ColorT color_type;
45 typedef Order order_type;
46 typedef Allocator alloc_type;
47 typedef span_pattern_base<color_type, alloc_type> base_type;
48 typedef typename color_type::value_type value_type;
49 typedef typename color_type::calc_type calc_type;
50 enum
52 base_shift = color_type::base_shift,
53 base_mask = color_type::base_mask
56 //--------------------------------------------------------------------
57 span_pattern_rgba(alloc_type& alloc) :
58 base_type(alloc),
59 m_wrap_mode_x(1),
60 m_wrap_mode_y(1)
63 //----------------------------------------------------------------
64 span_pattern_rgba(alloc_type& alloc,
65 const rendering_buffer& src,
66 unsigned offset_x, unsigned offset_y) :
67 base_type(alloc, src, offset_x, offset_y, 0),
68 m_wrap_mode_x(src.width()),
69 m_wrap_mode_y(src.height())
72 //-------------------------------------------------------------------
73 void source_image(const rendering_buffer& src)
75 base_type::source_image(src);
76 m_wrap_mode_x = WrapModeX(src.width());
77 m_wrap_mode_y = WrapModeY(src.height());
80 //--------------------------------------------------------------------
81 color_type* generate(int x, int y, unsigned len)
83 color_type* span = base_type::allocator().span();
84 unsigned sx = m_wrap_mode_x(base_type::offset_x() + x);
85 const value_type* row_ptr =
86 (const value_type*)base_type::source_image().row(
87 m_wrap_mode_y(
88 base_type::offset_y() + y));
91 const value_type* p = row_ptr + (sx << 2);
92 span->r = p[order_type::R];
93 span->g = p[order_type::G];
94 span->b = p[order_type::B];
95 span->a = p[order_type::A];
96 sx = ++m_wrap_mode_x;
97 ++span;
99 while(--len);
100 return base_type::allocator().span();
103 private:
104 WrapModeX m_wrap_mode_x;
105 WrapModeY m_wrap_mode_y;
110 #endif