139241fe2SDarkWyrm //---------------------------------------------------------------------------- 2*e39da397SStephan Aßmus // Anti-Grain Geometry - Version 2.4 3*e39da397SStephan Aßmus // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) 439241fe2SDarkWyrm // 539241fe2SDarkWyrm // Permission to copy, use, modify, sell and distribute this software 639241fe2SDarkWyrm // is granted provided this copyright notice appears in all copies. 739241fe2SDarkWyrm // This software is provided "as is" without express or implied 839241fe2SDarkWyrm // warranty, and with no claim as to its suitability for any purpose. 939241fe2SDarkWyrm // 1039241fe2SDarkWyrm //---------------------------------------------------------------------------- 1139241fe2SDarkWyrm // Contact: mcseem@antigrain.com 1239241fe2SDarkWyrm // mcseemagg@yahoo.com 1339241fe2SDarkWyrm // http://www.antigrain.com 1439241fe2SDarkWyrm //---------------------------------------------------------------------------- 1539241fe2SDarkWyrm 1639241fe2SDarkWyrm #ifndef AGG_SPAN_ALLOCATOR_INCLUDED 1739241fe2SDarkWyrm #define AGG_SPAN_ALLOCATOR_INCLUDED 1839241fe2SDarkWyrm 19*e39da397SStephan Aßmus #include "agg_array.h" 2039241fe2SDarkWyrm 2139241fe2SDarkWyrm namespace agg 2239241fe2SDarkWyrm { 2339241fe2SDarkWyrm //----------------------------------------------------------span_allocator 2439241fe2SDarkWyrm template<class ColorT> class span_allocator 2539241fe2SDarkWyrm { 2639241fe2SDarkWyrm public: 2739241fe2SDarkWyrm typedef ColorT color_type; 2839241fe2SDarkWyrm 2939241fe2SDarkWyrm //-------------------------------------------------------------------- allocate(unsigned span_len)30*e39da397SStephan Aßmus AGG_INLINE color_type* allocate(unsigned span_len) 3139241fe2SDarkWyrm { 32*e39da397SStephan Aßmus if(span_len > m_span.size()) 33*e39da397SStephan Aßmus { 34*e39da397SStephan Aßmus // To reduce the number of reallocs we align the 35*e39da397SStephan Aßmus // span_len to 256 color elements. 36*e39da397SStephan Aßmus // Well, I just like this number and it looks reasonable. 37*e39da397SStephan Aßmus //----------------------- 38*e39da397SStephan Aßmus m_span.resize(((span_len + 255) >> 8) << 8); 39*e39da397SStephan Aßmus } 40*e39da397SStephan Aßmus return &m_span[0]; 4139241fe2SDarkWyrm } 4239241fe2SDarkWyrm span()43*e39da397SStephan Aßmus AGG_INLINE color_type* span() { return &m_span[0]; } max_span_len()44*e39da397SStephan Aßmus AGG_INLINE unsigned max_span_len() const { return m_span.size(); } 4539241fe2SDarkWyrm 4639241fe2SDarkWyrm private: 47*e39da397SStephan Aßmus pod_array<color_type> m_span; 4839241fe2SDarkWyrm }; 4939241fe2SDarkWyrm } 5039241fe2SDarkWyrm 5139241fe2SDarkWyrm 5239241fe2SDarkWyrm #endif 5339241fe2SDarkWyrm 5439241fe2SDarkWyrm 55