|
From: Vinnie <th...@ya...> - 2009-04-28 14:05:59
|
Can anyone please share some common methods for improving agg's performance? I'm doing a lot of linear blends and shape filled blends. On the linear blends I am both filling and framing shapes (rectangle, rounded rectangle, ellipse, arc). Of course there is plenty of solid color filling and framing, both completely opaque and at various transparencies. I'm also outputting a fair amount of anti-aliased text using the freetype engine. On the linear blends, the majority of them are vertical so I implemented my own routine to write the pixels directly. It is several orders of magnitude faster. For linear blend fills and shape blend fills, I use a bin solid renderer because in all cases of these fills I am following it up with a frame, so the frame covers up the lack of antialiasing on the edge of the fill. There are lots of situations where I am doing solid rectangle fills without a transform so of course I wrote my own routine for that. In fact, for the case where R=G=B I use one ::memset() per row. So are there any easy optimizations I can do? Where is the low hanging optimization fruit? I've studied the agg code and it appears that there is the inline equivalent of per-pixel calculation when doing the gradient fills. For a linear blend this can clearly be optimized because, on a per scanline basis, the series of output colors can be more quickly calculated using a bresenham-style line walking algorithm on the R, G, and B components, using the starting color and ending color of the horizontal line segment (where the starting and ending components would, of course, need a fractional representation for accuracy). Unfortunately this type of optimization doesn't seem possible the way that the agg pipeline is structured and stages are isolated from each other. The top 3 functions in my profiler output are: agg::rasterizer_cells_aa<struct agg::cell_aa>::line agg::gradient_linear_color<struct agg::rgba8>::operator[] agg::pixfmt_alpha_blend_rgb<struct agg::blender_rgb<struct agg::rgba8,struct agg::order_bgr>,class agg::row_accessor<unsigned char> >::blend_solid_hspan (LOL at the last function name) Thanks! |