+ move renderer to agg_helpers
This commit is contained in:
parent
9840c7df4c
commit
8038561984
5 changed files with 65 additions and 71 deletions
|
@ -23,8 +23,15 @@
|
|||
#ifndef MAPNIK_AGG_HELPERS_HPP
|
||||
#define MAPNIK_AGG_HELPERS_HPP
|
||||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_gamma_functions.h"
|
||||
#include "agg_math_stroke.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_scanline_p.h"
|
||||
#include "agg_renderer_outline_aa.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -86,6 +93,47 @@ void set_join_caps(Stroke const& stroke_, PathType & stroke)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename PixelFormat>
|
||||
struct renderer_ : private boost::noncopyable
|
||||
{
|
||||
typedef PixelFormat pixfmt_type;
|
||||
typedef typename pixfmt_type::color_type color_type;
|
||||
typedef typename pixfmt_type::row_data row_data;
|
||||
typedef agg::renderer_base<pixfmt_type> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
typedef agg::scanline_u8 scanline_type;
|
||||
|
||||
renderer_()
|
||||
: renb_(),
|
||||
ren_(renb_)
|
||||
{}
|
||||
|
||||
template <typename PF>
|
||||
void attach(PF & pf)
|
||||
{
|
||||
renb_.attach(pf);
|
||||
}
|
||||
|
||||
void color(color_type const& c)
|
||||
{
|
||||
ren_.color(c);
|
||||
}
|
||||
|
||||
template <typename Rasterizer>
|
||||
void render(Rasterizer & ras)
|
||||
{
|
||||
agg::render_scanlines(ras, sl_, ren_);
|
||||
sl_. reset_spans();
|
||||
}
|
||||
|
||||
scanline_type sl_;
|
||||
ren_base renb_;
|
||||
renderer ren_;
|
||||
};
|
||||
|
||||
struct aa_renderer : renderer_<agg::pixfmt_rgba32_plain> {};
|
||||
|
||||
}
|
||||
|
||||
#endif //MAPNIK_AGG_HELPERS_HPP
|
||||
|
|
|
@ -30,14 +30,6 @@
|
|||
#include <mapnik/label_collision_detector.hpp>
|
||||
#include <mapnik/map.hpp>
|
||||
|
||||
// agg FIXME
|
||||
|
||||
#include "agg_basics.h"
|
||||
#include "agg_pixfmt_rgba.h"
|
||||
#include "agg_scanline_u.h"
|
||||
#include "agg_scanline_p.h"
|
||||
//#include "agg_renderer_outline_aa.h"
|
||||
#include "agg_renderer_scanline.h"
|
||||
// boost
|
||||
#include <boost/utility.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
@ -51,51 +43,11 @@ namespace agg {
|
|||
struct trans_affine;
|
||||
}
|
||||
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class marker;
|
||||
|
||||
struct rasterizer;
|
||||
|
||||
|
||||
template <typename PixelFormat>
|
||||
struct stroke_renderer
|
||||
{
|
||||
typedef PixelFormat pixfmt_type;
|
||||
typedef typename pixfmt_type::color_type color_type;
|
||||
typedef typename pixfmt_type::row_data row_data;
|
||||
typedef agg::renderer_base<pixfmt_type> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
typedef agg::scanline_u8 scanline_type;
|
||||
|
||||
stroke_renderer()
|
||||
: renb_(),
|
||||
ren_(renb_)
|
||||
{}
|
||||
|
||||
template <typename PF>
|
||||
void attach(PF & pf)
|
||||
{
|
||||
renb_.attach(pf);
|
||||
}
|
||||
|
||||
void color(color_type const& c)
|
||||
{
|
||||
ren_.color(c);
|
||||
}
|
||||
|
||||
template <typename Rasterizer>
|
||||
void render(Rasterizer & ras)
|
||||
{
|
||||
agg::render_scanlines(ras, sl_, ren_);
|
||||
}
|
||||
|
||||
scanline_type sl_;
|
||||
ren_base renb_;
|
||||
renderer ren_;
|
||||
};
|
||||
|
||||
struct aa_renderer;
|
||||
|
||||
template <typename T>
|
||||
class MAPNIK_DECL agg_renderer : public feature_style_processor<agg_renderer<T> >,
|
||||
|
@ -163,7 +115,7 @@ public:
|
|||
|
||||
private:
|
||||
T & pixmap_;
|
||||
stroke_renderer<agg::pixfmt_rgba32_plain> stroker_;
|
||||
boost::scoped_ptr<aa_renderer> renderer_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
double scale_factor_;
|
||||
|
@ -173,6 +125,7 @@ private:
|
|||
boost::shared_ptr<label_collision_detector4> detector_;
|
||||
boost::scoped_ptr<rasterizer> ras_ptr;
|
||||
box2d<double> query_extent_;
|
||||
|
||||
void setup(Map const &m);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
@ -34,7 +35,6 @@
|
|||
#include <mapnik/svg/svg_renderer.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
||||
|
||||
// agg
|
||||
#define AGG_RENDERING_BUFFER row_ptr_cache<int8u>
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -115,7 +115,7 @@ template <typename T>
|
|||
agg_renderer<T>::agg_renderer(Map const& m, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y)
|
||||
: feature_style_processor<agg_renderer>(m, scale_factor),
|
||||
pixmap_(pixmap),
|
||||
stroker_(),
|
||||
renderer_(new aa_renderer),
|
||||
width_(pixmap_.width()),
|
||||
height_(pixmap_.height()),
|
||||
scale_factor_(scale_factor),
|
||||
|
@ -133,6 +133,7 @@ agg_renderer<T>::agg_renderer(Map const& m, T & pixmap, boost::shared_ptr<label_
|
|||
double scale_factor, unsigned offset_x, unsigned offset_y)
|
||||
: feature_style_processor<agg_renderer>(m, scale_factor),
|
||||
pixmap_(pixmap),
|
||||
renderer_(),
|
||||
width_(pixmap_.width()),
|
||||
height_(pixmap_.height()),
|
||||
scale_factor_(scale_factor),
|
||||
|
|
|
@ -51,8 +51,8 @@ template <typename T>
|
|||
void agg_renderer<T>::process(line_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
|
||||
{
|
||||
|
||||
stroke const& stroke_ = sym.get_stroke();
|
||||
color const& col = stroke_.get_color();
|
||||
unsigned r=col.red();
|
||||
|
@ -98,7 +98,8 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
{
|
||||
ras_ptr->reset();
|
||||
set_gamma_method(stroke_, ras_ptr);
|
||||
renderer_.attach(pixf);
|
||||
renderer_->attach(pixf);
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
|
@ -193,8 +194,8 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
}
|
||||
}
|
||||
|
||||
renderer_.color(agg::rgba8(r, g, b, int(a*stroke_.get_opacity())));
|
||||
renderer_.render(*ras_ptr);
|
||||
renderer_->color(agg::rgba8(r, g, b, int(a*stroke_.get_opacity())));
|
||||
renderer_->render(*ras_ptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,27 +47,19 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
color const& fill_ = sym.get_fill();
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4);
|
||||
agg::pixfmt_rgba32_plain pixf(buf);
|
||||
|
||||
ren_base renb(pixf);
|
||||
|
||||
unsigned r=fill_.red();
|
||||
unsigned g=fill_.green();
|
||||
unsigned b=fill_.blue();
|
||||
unsigned a=fill_.alpha();
|
||||
//renb.clip_box(0,0,width_,height_);
|
||||
renderer ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
||||
set_gamma_method(sym,ras_ptr);
|
||||
|
||||
renderer_->attach(pixf);
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
box2d<double> inflated_extent = query_extent_ * 1.1;
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
|
@ -92,18 +84,17 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
}
|
||||
//if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
|
||||
agg::render_scanlines(*ras_ptr, sl, ren);
|
||||
renderer_->color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
|
||||
renderer_->render(*ras_ptr);
|
||||
}
|
||||
|
||||
|
||||
template void agg_renderer<image_32>::process(polygon_symbolizer const&,
|
||||
mapnik::feature_ptr const&,
|
||||
proj_transform const&);
|
||||
|
|
Loading…
Reference in a new issue