agg_span_converter.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //----------------------------------------------------------------------------
  2. // Anti-Grain Geometry - Version 2.4
  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. //----------------------------------------------------------------------------
  15. #ifndef AGG_SPAN_CONVERTER_INCLUDED
  16. #define AGG_SPAN_CONVERTER_INCLUDED
  17. #include "agg_basics.h"
  18. namespace agg
  19. {
  20. //----------------------------------------------------------span_converter
  21. template<class SpanGenerator, class SpanConverter> class span_converter
  22. {
  23. public:
  24. typedef typename SpanGenerator::color_type color_type;
  25. span_converter(SpanGenerator& span_gen, SpanConverter& span_cnv) :
  26. m_span_gen(&span_gen), m_span_cnv(&span_cnv) {}
  27. void attach_generator(SpanGenerator& span_gen) { m_span_gen = &span_gen; }
  28. void attach_converter(SpanConverter& span_cnv) { m_span_cnv = &span_cnv; }
  29. //--------------------------------------------------------------------
  30. void prepare()
  31. {
  32. m_span_gen->prepare();
  33. m_span_cnv->prepare();
  34. }
  35. //--------------------------------------------------------------------
  36. void generate(color_type* span, int x, int y, unsigned len)
  37. {
  38. m_span_gen->generate(span, x, y, len);
  39. m_span_cnv->generate(span, x, y, len);
  40. }
  41. private:
  42. SpanGenerator* m_span_gen;
  43. SpanConverter* m_span_cnv;
  44. };
  45. }
  46. #endif