make renderer type a template argument of agg svg renderer

This commit is contained in:
Dane Springmeyer 2011-05-17 06:18:06 +00:00
parent 9458e2d890
commit b578c02c54
4 changed files with 21 additions and 22 deletions

View file

@ -23,28 +23,29 @@
#ifndef MAPNIK_SVG_RENDERER_HPP
#define MAPNIK_SVG_RENDERER_HPP
// mapnik
#include <mapnik/svg/svg_path_attributes.hpp>
#include <mapnik/gradient.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/grid/grid_pixel.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/foreach.hpp>
// agg
#include "agg_path_storage.h"
#include "agg_conv_transform.h"
#include "agg_conv_stroke.h"
#include "agg_conv_contour.h"
#include "agg_conv_curve.h"
#include "agg_color_rgba.h"
#include "agg_renderer_scanline.h"
#include "agg_bounding_rect.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_rendering_buffer.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
#include "agg_scanline_p.h"
#include "agg_scanline_bin.h"
#include "agg_renderer_scanline.h"
#include "agg_span_allocator.h"
#include "agg_span_gradient.h"
@ -52,10 +53,6 @@
#include "agg_gamma_lut.h"
#include "agg_span_interpolator_linear.h"
#include "agg_pixfmt_rgba.h"
#include "agg_path_storage.h"
#include "agg_ellipse.h"
#include <boost/foreach.hpp>
namespace mapnik {
namespace svg {
@ -101,7 +98,7 @@ private:
};
template <typename VertexSource, typename AttributeSource, typename PixelFormat>
template <typename VertexSource, typename AttributeSource, typename ScanlineRenderer, typename PixelFormat>
class svg_renderer : boost::noncopyable
{
typedef agg::conv_curve<VertexSource> curved_type;
@ -110,7 +107,6 @@ class svg_renderer : boost::noncopyable
typedef agg::conv_transform<curved_type> curved_trans_type;
typedef agg::conv_contour<curved_trans_type> curved_trans_contour_type;
typedef agg::renderer_base<PixelFormat> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
public:
svg_renderer(VertexSource & source, AttributeSource const& attributes)
@ -301,7 +297,7 @@ public:
ras.filling_rule(attr.even_odd_flag ? fill_even_odd : fill_non_zero);
color = attr.fill_color;
color.opacity(color.opacity() * attr.opacity * opacity);
renderer_solid ren_s(ren);
ScanlineRenderer ren_s(ren);
ren_s.color(color);
render_scanlines(ras, sl, ren_s);
}
@ -336,7 +332,7 @@ public:
ras.filling_rule(fill_non_zero);
color = attr.stroke_color;
color.opacity(color.opacity() * attr.opacity * opacity);
renderer_solid ren_s(ren);
ScanlineRenderer ren_s(ren);
ren_s.color(color);
render_scanlines(ras, sl, ren_s);
}
@ -398,7 +394,7 @@ public:
}
ras.filling_rule(attr.even_odd_flag ? fill_even_odd : fill_non_zero);
renderer_solid ren_s(ren);
ScanlineRenderer ren_s(ren);
ren_s.color(color);
render_scanlines(ras, sl, ren_s);
}
@ -424,7 +420,7 @@ public:
ras.add_path(curved_stroked_trans, attr.index);
ras.filling_rule(fill_non_zero);
renderer_solid ren_s(ren);
ScanlineRenderer ren_s(ren);
ren_s.color(color);
render_scanlines(ras, sl, ren_s);
}

View file

@ -90,7 +90,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>, agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes());
agg::pod_bvector<path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer(svg_path,(*marker)->attributes());
for (unsigned i=0; i<feature.num_geometries(); ++i)
{

View file

@ -37,8 +37,7 @@
// agg
#include "agg_rasterizer_scanline_aa.h"
#include "agg_renderer_scanline.h"
#include "agg_scanline_u.h"
#include "agg_scanline_p.h"
#include "agg_scanline_bin.h"
#include "agg_path_storage.h"
#include "agg_ellipse.h"
#include "agg_conv_stroke.h"
@ -57,9 +56,8 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
{
typedef coord_transform2<CoordTransform,geometry_type> path_type;
typedef agg::renderer_base<mapnik::pixfmt_gray16> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
agg::scanline_u8 sl;
agg::scanline_p8 sl_line;
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
agg::scanline_bin sl;
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
mapnik::pixfmt_gray16 pixf(buf);
@ -68,7 +66,6 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
renderer ren(renb);
ras_ptr->reset();
ras_ptr->gamma(agg::gamma_linear(0.0, 0.0));
agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_transform();
@ -98,7 +95,9 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>, mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes());
agg::pod_bvector<path_attributes>,
renderer,
mapnik::pixfmt_gray16 > svg_renderer(svg_path,(*marker)->attributes());
bool placed = false;
for (unsigned i=0; i<feature.num_geometries(); ++i)

View file

@ -113,6 +113,7 @@ int main (int argc,char** argv)
typedef agg::pixfmt_rgba32_plain pixfmt;
typedef agg::renderer_base<pixfmt> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
agg::rasterizer_scanline_aa<> ras_ptr;
agg::scanline_u8 sl;
@ -138,6 +139,7 @@ int main (int argc,char** argv)
mapnik::svg::svg_path_adapter svg_path(stl_storage);
mapnik::svg::svg_renderer<mapnik::svg::svg_path_adapter,
agg::pod_bvector<mapnik::svg::path_attributes>,
renderer_solid,
agg::pixfmt_rgba32_plain > svg_renderer_this(svg_path,
(*marker.get_vector_data())->attributes());