20 #ifndef AGG_RENDERER_MCLIP_INCLUDED 21 #define AGG_RENDERER_MCLIP_INCLUDED 23 #include "agg_basics.h" 24 #include "agg_array.h" 25 #include "agg_renderer_base.h" 35 typedef typename pixfmt_type::color_type color_type;
36 typedef typename pixfmt_type::row_data row_data;
43 m_bounds(m_ren.xmin(), m_ren.ymin(), m_ren.xmax(), m_ren.ymax())
45 void attach(pixfmt_type& pixf)
52 const pixfmt_type& ren()
const {
return m_ren.ren(); }
53 pixfmt_type& ren() {
return m_ren.ren(); }
56 unsigned width()
const {
return m_ren.width(); }
57 unsigned height()
const {
return m_ren.height(); }
60 const rect_i& clip_box()
const {
return m_ren.clip_box(); }
61 int xmin()
const {
return m_ren.xmin(); }
62 int ymin()
const {
return m_ren.ymin(); }
63 int xmax()
const {
return m_ren.xmax(); }
64 int ymax()
const {
return m_ren.ymax(); }
67 const rect_i& bounding_clip_box()
const {
return m_bounds; }
68 int bounding_xmin()
const {
return m_bounds.x1; }
69 int bounding_ymin()
const {
return m_bounds.y1; }
70 int bounding_xmax()
const {
return m_bounds.x2; }
71 int bounding_ymax()
const {
return m_bounds.y2; }
79 const rect_i& cb = m_clip[0];
80 m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2);
87 if(++m_curr_cb < m_clip.size())
89 const rect_i& cb = m_clip[m_curr_cb];
90 m_ren.clip_box_naked(cb.x1, cb.y1, cb.x2, cb.y2);
97 void reset_clipping(
bool visibility)
99 m_ren.reset_clipping(visibility);
102 m_bounds = m_ren.clip_box();
106 void add_clip_box(
int x1,
int y1,
int x2,
int y2)
108 rect_i cb(x1, y1, x2, y2);
110 if(cb.clip(
rect_i(0, 0, width() - 1, height() - 1)))
113 if(cb.x1 < m_bounds.x1) m_bounds.x1 = cb.x1;
114 if(cb.y1 < m_bounds.y1) m_bounds.y1 = cb.y1;
115 if(cb.x2 > m_bounds.x2) m_bounds.x2 = cb.x2;
116 if(cb.y2 > m_bounds.y2) m_bounds.y2 = cb.y2;
121 void clear(
const color_type& c)
127 void copy_pixel(
int x,
int y,
const color_type& c)
132 if(m_ren.inbox(x, y))
134 m_ren.ren().copy_pixel(x, y, c);
138 while(next_clip_box());
142 void blend_pixel(
int x,
int y,
const color_type& c, cover_type cover)
147 if(m_ren.inbox(x, y))
149 m_ren.ren().blend_pixel(x, y, c, cover);
153 while(next_clip_box());
157 color_type pixel(
int x,
int y)
const 162 if(m_ren.inbox(x, y))
164 return m_ren.ren().pixel(x, y);
167 while(next_clip_box());
168 return color_type::no_color();
172 void copy_hline(
int x1,
int y,
int x2,
const color_type& c)
177 m_ren.copy_hline(x1, y, x2, c);
179 while(next_clip_box());
183 void copy_vline(
int x,
int y1,
int y2,
const color_type& c)
188 m_ren.copy_vline(x, y1, y2, c);
190 while(next_clip_box());
194 void blend_hline(
int x1,
int y,
int x2,
195 const color_type& c, cover_type cover)
200 m_ren.blend_hline(x1, y, x2, c, cover);
202 while(next_clip_box());
206 void blend_vline(
int x,
int y1,
int y2,
207 const color_type& c, cover_type cover)
212 m_ren.blend_vline(x, y1, y2, c, cover);
214 while(next_clip_box());
218 void copy_bar(
int x1,
int y1,
int x2,
int y2,
const color_type& c)
223 m_ren.copy_bar(x1, y1, x2, y2, c);
225 while(next_clip_box());
229 void blend_bar(
int x1,
int y1,
int x2,
int y2,
230 const color_type& c, cover_type cover)
235 m_ren.blend_bar(x1, y1, x2, y2, c, cover);
237 while(next_clip_box());
241 void blend_solid_hspan(
int x,
int y,
int len,
242 const color_type& c,
const cover_type* covers)
247 m_ren.blend_solid_hspan(x, y, len, c, covers);
249 while(next_clip_box());
253 void blend_solid_vspan(
int x,
int y,
int len,
254 const color_type& c,
const cover_type* covers)
259 m_ren.blend_solid_vspan(x, y, len, c, covers);
261 while(next_clip_box());
266 void copy_color_hspan(
int x,
int y,
int len,
const color_type* colors)
271 m_ren.copy_color_hspan(x, y, len, colors);
273 while(next_clip_box());
277 void blend_color_hspan(
int x,
int y,
int len,
278 const color_type* colors,
279 const cover_type* covers,
280 cover_type cover = cover_full)
285 m_ren.blend_color_hspan(x, y, len, colors, covers, cover);
287 while(next_clip_box());
291 void blend_color_vspan(
int x,
int y,
int len,
292 const color_type* colors,
293 const cover_type* covers,
294 cover_type cover = cover_full)
299 m_ren.blend_color_vspan(x, y, len, colors, covers, cover);
301 while(next_clip_box());
313 m_ren.copy_from(from, rc, x_to, y_to);
315 while(next_clip_box());
319 template<
class SrcPixelFormatRenderer>
320 void blend_from(
const SrcPixelFormatRenderer& src,
321 const rect_i* rect_src_ptr = 0,
324 cover_type cover = cover_full)
329 m_ren.blend_from(src, rect_src_ptr, dx, dy, cover);
331 while(next_clip_box());