author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年06月20日 09:31:28 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年06月20日 09:31:28 +0200 |
commit | 4cf954200f830cf7fd62751a33da57f45f1f9ff2 (patch) | |
tree | 4ae38faadd6d3aab7fb1b1bbbf1da17ef82cc6c8 | |
parent | 29309ebb162dabd6b533f3c48fac88e13bf3e570 (diff) | |
download | gsl-shell-4cf954200f830cf7fd62751a33da57f45f1f9ff2.tar.gz |
-rw-r--r-- | agg-plot/canvas.h | 15 | ||||
-rw-r--r-- | agg-plot/sg_object.h | 14 |
diff --git a/agg-plot/canvas.h b/agg-plot/canvas.h index 9b79f871..92e5111c 100644 --- a/agg-plot/canvas.h +++ b/agg-plot/canvas.h @@ -61,12 +61,14 @@ class canvas_gen : private pixel { double m_width; double m_height; + agg::rendering_buffer& m_rbuf; + public: canvas_gen(agg::rendering_buffer& ren_buf, double width, double height, agg::rgba bgcol): pixel(ren_buf), rb(pixel::pixfmt), rs(rb), ras(), sl(), bg_color(bgcol), - m_width(width), m_height(height) + m_width(width), m_height(height), m_rbuf(ren_buf) { }; @@ -90,9 +92,14 @@ public: void draw(sg_object& vs, agg::rgba8 c) { - this->ras.add_path(vs); - this->rs.color(c); - agg::render_scanlines(this->ras, this->sl, this->rs); + bool direct_render = vs.render(m_rbuf, this->ras, this->sl, c); + + if (!direct_render) + { + this->ras.add_path(vs); + this->rs.color(c); + agg::render_scanlines(this->ras, this->sl, this->rs); + } }; void draw_outline(sg_object& vs, agg::rgba8 c) diff --git a/agg-plot/sg_object.h b/agg-plot/sg_object.h index 00dabda1..0dba92dc 100644 --- a/agg-plot/sg_object.h +++ b/agg-plot/sg_object.h @@ -24,6 +24,10 @@ #include "agg_trans_affine.h" #include "agg_bounding_rect.h" #include "agg_conv_transform.h" +#include "agg_rendering_buffer.h" +#include "agg_scanline_p.h" +#include "agg_rasterizer_scanline_aa.h" + #include "draw_svg.h" #include "utils.h" #include "resource-manager.h" @@ -41,6 +45,11 @@ struct sg_object : public vertex_source { virtual void apply_transform(const agg::trans_affine& m, double as) = 0; virtual void bounding_box(double *x1, double *y1, double *x2, double *y2) = 0; + virtual bool render(agg::rendering_buffer& ren_buf, agg::rasterizer_scanline_aa<>& ras, agg::scanline_p8& sl, agg::rgba8 c) + { + return false; + } + virtual bool affine_compose(agg::trans_affine& m) { return false; } virtual str write_svg(int id, agg::rgba8 c, double h) { @@ -198,6 +207,11 @@ public: virtual bool affine_compose(agg::trans_affine& m) { return this->m_source->affine_compose(m); } + virtual bool render(agg::rendering_buffer& ren_buf, agg::rasterizer_scanline_aa<>& ras, agg::scanline_p8& sl, agg::rgba8 c) + { + return m_source->render(ren_buf, ras, sl, c); + } + private: sg_object* m_source; }; |