From bcf145488429fa52eb823aa262251d695e9b9233 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 10 Jul 2013 16:44:20 -0400 Subject: [PATCH] optimize svg rendering by moving bbox calc only needed by gradient rendering into gradient code --- include/mapnik/svg/svg_renderer_agg.hpp | 27 ++++++++----------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/include/mapnik/svg/svg_renderer_agg.hpp b/include/mapnik/svg/svg_renderer_agg.hpp index 778e726ca..d3586873a 100644 --- a/include/mapnik/svg/svg_renderer_agg.hpp +++ b/include/mapnik/svg/svg_renderer_agg.hpp @@ -119,11 +119,12 @@ public: void render_gradient(Rasterizer& ras, Scanline& sl, Renderer& ren, - const gradient &grad, + gradient const& grad, agg::trans_affine const& mtx, double opacity, - const box2d &symbol_bbox, - const box2d &path_bbox) + box2d const& symbol_bbox, + curved_trans_type & curved_trans, + unsigned path_id) { typedef agg::gamma_lut gamma_lut_type; typedef agg::gradient_lut, 1024> color_func_type; @@ -165,17 +166,13 @@ public: if (grad.get_units() == OBJECT_BOUNDING_BOX) { - bx1=path_bbox.minx(); - by1=path_bbox.miny(); - bx2=path_bbox.maxx(); - by2=path_bbox.maxy(); + bounding_rect_single(curved_trans, path_id, &bx1, &by1, &bx2, &by2); } transform.translate(-bx1,-by1); transform.scale(1.0/(bx2-bx1),1.0/(by2-by1)); } - if (grad.get_gradient_type() == RADIAL) { typedef agg::gradient_radial_focus gradient_adaptor_type; @@ -261,10 +258,6 @@ public: transform = attr.transform; - double bx1,by1,bx2,by2; - bounding_rect_single(curved_trans, attr.index, &bx1, &by1, &bx2, &by2); - box2d path_bbox(bx1,by1,bx2,by2); - transform *= mtx; double scl = transform.scale(); //curved_.approximation_method(curve_inc); @@ -290,7 +283,7 @@ public: if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT) { - render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * attr.opacity * opacity, symbol_bbox, path_bbox); + render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index); } else { @@ -326,7 +319,7 @@ public: if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT) { - render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, path_bbox); + render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, curved_trans, attr.index); } else { @@ -349,7 +342,7 @@ public: int feature_id, agg::trans_affine const& mtx, double opacity, - const box2d &symbol_bbox) + box2d const& symbol_bbox) { using namespace agg; @@ -369,10 +362,6 @@ public: transform = attr.transform; - double bx1,by1,bx2,by2; - bounding_rect_single(curved_trans, attr.index, &bx1, &by1, &bx2, &by2); - box2d path_bbox(bx1,by1,bx2,by2); - transform *= mtx; double scl = transform.scale(); //curved_.approximation_method(curve_inc);