From: Gordon S. <sch...@ho...> - 2004-07-20 13:19:02
|
Speaking of performance, I am testing AGG with a dynamic graph representation (live animation), any hints on how to get max performance at reasonable quality (here is a snip of the "bezier" line drawing): agg::path_storage ps; ps.remove_all(); int tot = m_graph.getEdgePointsCount(e->Get()); if (tot) { PointF p; for(int i = 0; i < tot; ++i) { p = m_graph.getEdgePoint(e->Get(), i); if (i == 0) ps.move_to(p.X, p.Y); else ps.line_to(p.X, p.Y); } agg::conv_smooth_poly1<agg::path_storage> smooth(ps); agg::conv_curve<agg::conv_smooth_poly1<agg::path_storage> > curve(smooth); smooth.smooth_value(1.0); stroke_fine<agg::conv_curve<agg::conv_smooth_poly1<agg::path_storage> > > s(curve, LINE_WIDTH); ras.add_path(s); renderer.color(m_color_profile[cat][COLOR_LINE]); ras.render(m_sl, renderer); "Maxim Shemanarev" <mc...@an...> wrote in message news:cdhoda$5uu$1...@se...... > Hi Doug, > > > Now I am > > wondering what is the minimal process needed to add anti-aliasing? Is it > > as simple as putting a differnt renderer in? Basic code I am using is > > below. > > No, it's a bit different. The renderers perform only very simple operations, > such as drawing primirives, blending spans (scanlines to be exact), etc. The > concept of drawing anti-aliased shapes is based on the scanline rasterizer. > The rasterizer converts an arbitrary closed polygon to a number of scanlines > with possible anti-aliasing. And the only the scanline rasterizer can do is > to rasterize polygons. But it works with subpixel accuracy and > anti-aliasing. If you want to draw a line you will have to calculate its > closed contour and rasterize it as a polygon. AGG provides appropriate > converters that allow for calculating strokes. > > To be short, the following code should do: > > typedef agg::pixfmt_rgba32 pixfmt; > typedef agg::renderer_base<pixfmt> base_renderer; > typedef agg::renderer_scanline_p_solid<base_renderer> scanline_renderer; > > pixfmt pixf(rbuf); > base_renderer base_rend(pixf); > scanline_renderer scanline_rend(base_rend); > > // Rasterizer & scanline > agg::rasterizer_scanline_aa<> ras; > agg::scanline_p8 sl; > > ras.reset(); > ras.move_to_d(<x,y>); > ras.line_to_d(<x,y>); > ras.line_to_d(<x,y>); > . . . > > scanline_rend.color(agg::rgba8(0, 0, 0)); > ras.render(sl, scanline_rend); > > You can also use agg::path_storage and any available converters, such as > conv_transform, conv_stroke, etc. See examples/console/bezier_test/* > > There is also a general purpose scanline renderer that acceps an arbitrary > span generator. This mechanism allows you for drawing gradients, transformed > images, etc. > See > http://antigrain.com/tips/gradients_tutorial/gradients_tutorial.agdoc.html > > Anti-aliased lines can be drawn with agg::renderer_outline_aa, it's more > restrictive and mostly dedicated for drawing thin AA lines, but works about > 2-2.5 times faster. It's the next step > > McSeem > > > McSeem > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by BEA Weblogic Workshop > FREE Java Enterprise J2EE developer tools! > Get your free copy of BEA WebLogic Workshop 8.1 today. > http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click |