Add virtual render method for sg_object - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年06月20日 09:31:28 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年06月20日 09:31:28 +0200
commit4cf954200f830cf7fd62751a33da57f45f1f9ff2 (patch)
tree4ae38faadd6d3aab7fb1b1bbbf1da17ef82cc6c8
parent29309ebb162dabd6b533f3c48fac88e13bf3e570 (diff)
downloadgsl-shell-4cf954200f830cf7fd62751a33da57f45f1f9ff2.tar.gz
Add virtual render method for sg_object
The render method will be used by the canvas class if available to directly render into the buffer and bypass normal rendering mechanisms based on vertex_source. This is meant to allow subpixel LCD font rendering.
Diffstat
-rw-r--r--agg-plot/canvas.h 15
-rw-r--r--agg-plot/sg_object.h 14
2 files changed, 25 insertions, 4 deletions
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;
};
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月29日 01:29:42 +0000

AltStyle によって変換されたページ (->オリジナル) /