1 /* 2 * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 * 5 * Copyright 2002-2004 Maxim Shemanarev (http://www.antigrain.com) 6 * 7 * 8 */ 9 10 #include <Region.h> 11 12 #include "agg_basics.h" 13 #include "agg_array.h" 14 #include "agg_renderer_base.h" 15 #include "agg_renderer_scanline.h" 16 17 18 namespace agg 19 { 20 21 //============================================render_scanline_subpix_solid 22 template<class Scanline, class BaseRenderer, class ColorT> 23 void render_scanline_subpix_solid(const Scanline& sl, 24 BaseRenderer& ren, 25 const ColorT& color) 26 { 27 int y = sl.y(); 28 unsigned num_spans = sl.num_spans(); 29 typename Scanline::const_iterator span = sl.begin(); 30 31 for(;;) 32 { 33 int x = span->x; 34 if(span->len > 0) 35 { 36 ren.blend_solid_hspan_subpix(x, y, (unsigned)span->len, 37 color, 38 span->covers); 39 } 40 else 41 { 42 ren.blend_hline(x, y, (unsigned)(x - (span->len / 3) - 1), 43 color, 44 *(span->covers)); 45 } 46 if(--num_spans == 0) break; 47 ++span; 48 } 49 } 50 51 //==========================================renderer_scanline_subpix_solid 52 template<class BaseRenderer> class renderer_scanline_subpix_solid 53 { 54 public: 55 typedef BaseRenderer base_ren_type; 56 typedef typename base_ren_type::color_type color_type; 57 58 //-------------------------------------------------------------------- 59 renderer_scanline_subpix_solid() : m_ren(0) {} 60 renderer_scanline_subpix_solid(base_ren_type& ren) : m_ren(&ren) {} 61 void attach(base_ren_type& ren) 62 { 63 m_ren = &ren; 64 } 65 66 //-------------------------------------------------------------------- 67 void color(const color_type& c) { m_color = c; } 68 const color_type& color() const { return m_color; } 69 70 //-------------------------------------------------------------------- 71 void prepare() {} 72 73 //-------------------------------------------------------------------- 74 template<class Scanline> void render(const Scanline& sl) 75 { 76 render_scanline_subpix_solid(sl, *m_ren, m_color); 77 } 78 79 private: 80 base_ren_type* m_ren; 81 color_type m_color; 82 }; 83 } 84