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 #ifndef AGG_SPAN_ALLOCATOR_INCLUDED 17 #define AGG_SPAN_ALLOCATOR_INCLUDED 18 19 #include "agg_basics.h" 20 21 namespace agg 22 { 23 //----------------------------------------------------------span_allocator 24 template<class ColorT> class span_allocator 25 { 26 public: 27 typedef ColorT color_type; 28 29 //-------------------------------------------------------------------- 30 ~span_allocator() 31 { 32 delete [] m_span; 33 } 34 35 //-------------------------------------------------------------------- 36 span_allocator() : 37 m_max_span_len(0), 38 m_span(0) 39 { 40 } 41 42 //-------------------------------------------------------------------- 43 color_type* allocate(unsigned max_span_len) 44 { 45 if(max_span_len > m_max_span_len) 46 { 47 delete [] m_span; 48 m_span = new color_type[m_max_span_len = max_span_len]; 49 } 50 return m_span; 51 } 52 53 //-------------------------------------------------------------------- 54 color_type* span() 55 { 56 return m_span; 57 } 58 59 private: 60 //-------------------------------------------------------------------- 61 span_allocator(const span_allocator<ColorT>&); 62 const span_allocator<ColorT>& operator = (const span_allocator<ColorT>&); 63 64 unsigned m_max_span_len; 65 color_type* m_span; 66 }; 67 } 68 69 70 #endif 71 72 73