Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2012-05-15 10:35:56 -07:00
commit fb0ef869d6
9 changed files with 56 additions and 41 deletions

View file

@ -35,8 +35,10 @@ namespace agg
//------------------------------------------------------------pod_allocator //------------------------------------------------------------pod_allocator
template<class T> struct pod_allocator template<class T> struct pod_allocator
{ {
static T* allocate(unsigned num) { return static_cast<T*>(::operator new(sizeof(T)*num));} //static T* allocate(unsigned num) { return static_cast<T*>(::operator new(sizeof(T)*num));}
static void deallocate(T* ptr, unsigned) { ::operator delete(ptr) ;} //static void deallocate(T* ptr, unsigned) { ::operator delete(ptr) ;}
static T* allocate(unsigned num) { return new T [num]; }
static void deallocate(T* ptr, unsigned) { delete [] ptr; }
}; };
// Single object allocator. It's also can be replaced with your custom // Single object allocator. It's also can be replaced with your custom

View file

@ -70,8 +70,9 @@ public:
void start_style_processing(feature_type_style const& st); void start_style_processing(feature_type_style const& st);
void end_style_processing(feature_type_style const& st); void end_style_processing(feature_type_style const& st);
void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity); void render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr,
double opacity, composite_mode_e comp_op);
void process(point_symbolizer const& sym, void process(point_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
@ -103,7 +104,7 @@ public:
void process(markers_symbolizer const& sym, void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature, mapnik::feature_ptr const& feature,
proj_transform const& prj_trans); proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/, inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/, mapnik::feature_ptr const& /*feature*/,
proj_transform const& /*prj_trans*/) proj_transform const& /*prj_trans*/)
@ -111,9 +112,9 @@ public:
// agg renderer doesn't support processing of multiple symbolizers. // agg renderer doesn't support processing of multiple symbolizers.
return false; return false;
}; };
void painted(bool painted); void painted(bool painted);
private: private:
buffer_type & pixmap_; buffer_type & pixmap_;
boost::shared_ptr<buffer_type> internal_buffer_; boost::shared_ptr<buffer_type> internal_buffer_;

View file

@ -77,15 +77,15 @@ class MAPNIK_DECL gradient
// transform // transform
agg::trans_affine transform_; agg::trans_affine transform_;
public: public:
explicit gradient(); gradient();
gradient(gradient const& other); gradient(gradient const& other);
gradient& operator=(const gradient& rhs); gradient& operator=(const gradient& rhs);
void set_gradient_type(gradient_e grad); void set_gradient_type(gradient_e grad);
gradient_e get_gradient_type() const; gradient_e get_gradient_type() const;
void set_transform(agg::trans_affine transform); void set_transform(agg::trans_affine const& transform);
agg::trans_affine get_transform() const; agg::trans_affine const& get_transform() const;
void set_units(gradient_unit_e units); void set_units(gradient_unit_e units);
gradient_unit_e get_units() const; gradient_unit_e get_units() const;

View file

@ -248,21 +248,27 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
} }
template <typename T> template <typename T>
void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity) void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr,
double opacity, composite_mode_e comp_op)
{ {
if (marker.is_vector()) if (marker.is_vector())
{ {
typedef agg::pixfmt_rgba32 pixfmt; typedef agg::rgba8 color_type;
typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::order_rgba order_type;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::pixel32_type pixel_type;
typedef agg::comp_op_adaptor_rgba<color_type, order_type> blender_type; // comp blender
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type;
ras_ptr->reset(); ras_ptr->reset();
ras_ptr->gamma(agg::gamma_power()); ras_ptr->gamma(agg::gamma_power());
agg::scanline_u8 sl; agg::scanline_u8 sl;
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
pixfmt pixf(buf); pixfmt_comp_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(comp_op));
renderer_base renb(pixf); renderer_base renb(pixf);
box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box(); box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box();
coord<double,2> c = bbox.center(); coord<double,2> c = bbox.center();
// center the svg marker on '0,0' // center the svg marker on '0,0'
@ -277,19 +283,19 @@ void agg_renderer<T>::render_marker(pixel_position const& pos, marker const& mar
svg_path_adapter svg_path(stl_storage); svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter, svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>, agg::pod_bvector<path_attributes>,
renderer_solid, renderer_type,
agg::pixfmt_rgba32> svg_renderer(svg_path, agg::pixfmt_rgba32> svg_renderer(svg_path,
(*marker.get_vector_data())->attributes()); (*marker.get_vector_data())->attributes());
svg_renderer.render(*ras_ptr, sl, renb, mtx, opacity, bbox); svg_renderer.render(*ras_ptr, sl, renb, mtx, opacity, bbox);
} }
else else
{ {
//TODO: Add subpixel support composite(current_buffer_->data(), **marker.get_bitmap_data(),
pixmap_.set_rectangle_alpha2(**marker.get_bitmap_data(), comp_op, opacity,
boost::math::iround(pos.x), boost::math::iround(pos.x),
boost::math::iround(pos.y), boost::math::iround(pos.y),
opacity); false, false);
} }
} }

View file

@ -55,19 +55,23 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
{ {
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type; typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
typedef agg::rgba8 color_type;
typedef agg::pixfmt_rgba32 pixfmt; typedef agg::order_rgba order_type;
typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::pixel32_type pixel_type;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::comp_op_adaptor_rgba<color_type, order_type> blender_type; // comp blender
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type;
ras_ptr->reset(); ras_ptr->reset();
ras_ptr->gamma(agg::gamma_power()); ras_ptr->gamma(agg::gamma_power());
agg::scanline_u8 sl; agg::scanline_u8 sl;
agg::scanline_p8 sl_line; agg::scanline_p8 sl_line;
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
pixfmt pixf(buf); pixfmt_comp_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
renderer_base renb(pixf); renderer_base renb(pixf);
renderer_solid ren(renb); renderer_type ren(renb);
agg::trans_affine tr; agg::trans_affine tr;
boost::array<double,6> const& m = sym.get_image_transform(); boost::array<double,6> const& m = sym.get_image_transform();
tr.load_from(&m[0]); tr.load_from(&m[0]);
@ -104,9 +108,10 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
using namespace mapnik::svg; using namespace mapnik::svg;
vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source()); vertex_stl_adapter<svg_path_storage> stl_storage((*marker)->source());
svg_path_adapter svg_path(stl_storage); svg_path_adapter svg_path(stl_storage);
svg_renderer<svg_path_adapter, svg_renderer<svg_path_adapter,
agg::pod_bvector<path_attributes>, agg::pod_bvector<path_attributes>,
renderer_solid, renderer_type,
agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes()); agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes());
for (unsigned i=0; i<feature->num_geometries(); ++i) for (unsigned i=0; i<feature->num_geometries(); ++i)
@ -127,7 +132,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
detector_->has_placement(extent)) detector_->has_placement(extent))
{ {
render_marker(pixel_position(x - 0.5 * w, y - 0.5 * h) ,**mark, tr, sym.get_opacity()); render_marker(pixel_position(x - 0.5 * w, y - 0.5 * h) ,**mark, tr, sym.get_opacity(), sym.comp_op());
// TODO - impl this for markers? // TODO - impl this for markers?
//if (!sym.get_ignore_placement()) //if (!sym.get_ignore_placement())

View file

@ -103,7 +103,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
detector_->has_placement(label_ext)) detector_->has_placement(label_ext))
{ {
render_marker(pixel_position(x - 0.5 * w, y - 0.5 * h) ,**marker,tr, sym.get_opacity()); render_marker(pixel_position(x - 0.5 * w, y - 0.5 * h) ,**marker,tr, sym.get_opacity(), sym.comp_op());
if (!sym.get_ignore_placement()) if (!sym.get_ignore_placement())
detector_->insert(label_ext); detector_->insert(label_ext);

View file

@ -55,7 +55,8 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
render_marker(helper.get_marker_position(placements[ii]), render_marker(helper.get_marker_position(placements[ii]),
helper.get_marker(), helper.get_marker(),
helper.get_image_transform(), helper.get_image_transform(),
sym.get_opacity()); sym.get_opacity(),
sym.comp_op());
ren.prepare_glyphs(&(placements[ii])); ren.prepare_glyphs(&(placements[ii]));
ren.render(placements[ii].center); ren.render(placements[ii].center);

View file

@ -44,9 +44,9 @@ gradient::gradient()
x2_(0), x2_(0),
y2_(0), y2_(0),
r_(0), r_(0),
units_(OBJECT_BOUNDING_BOX) units_(OBJECT_BOUNDING_BOX),
{ transform_()
} {}
gradient::gradient(gradient const& other) gradient::gradient(gradient const& other)
: gradient_type_(other.gradient_type_), : gradient_type_(other.gradient_type_),
@ -77,11 +77,11 @@ gradient_e gradient::get_gradient_type() const
return gradient_type_; return gradient_type_;
} }
void gradient::set_transform(agg::trans_affine transform) void gradient::set_transform(agg::trans_affine const& transform)
{ {
transform_ = transform; transform_ = transform;
} }
agg::trans_affine gradient::get_transform() const agg::trans_affine const& gradient::get_transform() const
{ {
return transform_; return transform_;
} }

View file

@ -1031,7 +1031,7 @@ void map_parser::parse_markers_symbolizer(rule & rule, xml_node const& sym)
} }
boost::array<double,6> matrix; boost::array<double,6> matrix;
tr.store_to(&matrix[0]); tr.store_to(&matrix[0]);
symbol.set_transform(matrix); symbol.set_image_transform(matrix);
} }
optional<color> c = sym.get_opt_attr<color>("fill"); optional<color> c = sym.get_opt_attr<color>("fill");