1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
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_SPAN_ALLOCATOR_INCLUDED
17 #define AGG_SPAN_ALLOCATOR_INCLUDED
19 #include "agg_array.h"
23 //----------------------------------------------------------span_allocator
24 template<class ColorT
> class span_allocator
27 typedef ColorT color_type
;
29 //--------------------------------------------------------------------
30 AGG_INLINE color_type
* allocate(unsigned span_len
)
32 if(span_len
> m_span
.size())
34 // To reduce the number of reallocs we align the
35 // span_len to 256 color elements.
36 // Well, I just like this number and it looks reasonable.
37 //-----------------------
38 m_span
.resize(((span_len
+ 255) >> 8) << 8);
43 AGG_INLINE color_type
* span() { return &m_span
[0]; }
44 AGG_INLINE
unsigned max_span_len() const { return m_span
.size(); }
47 pod_array
<color_type
> m_span
;