+ use compositing renderer for markers,points and shields
This commit is contained in:
parent
55d5d8596d
commit
1b210ba456
5 changed files with 43 additions and 30 deletions
|
@ -70,8 +70,9 @@ public:
|
|||
|
||||
void start_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,
|
||||
mapnik::feature_ptr const& feature,
|
||||
|
@ -103,7 +104,7 @@ public:
|
|||
void process(markers_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans);
|
||||
|
||||
|
||||
inline bool process(rule::symbolizers const& /*syms*/,
|
||||
mapnik::feature_ptr const& /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
|
@ -111,9 +112,9 @@ public:
|
|||
// agg renderer doesn't support processing of multiple symbolizers.
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
void painted(bool painted);
|
||||
|
||||
|
||||
private:
|
||||
buffer_type & pixmap_;
|
||||
boost::shared_ptr<buffer_type> internal_buffer_;
|
||||
|
|
|
@ -248,21 +248,27 @@ void agg_renderer<T>::end_style_processing(feature_type_style const& st)
|
|||
}
|
||||
|
||||
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())
|
||||
{
|
||||
typedef agg::pixfmt_rgba32 pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
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->gamma(agg::gamma_power());
|
||||
agg::scanline_u8 sl;
|
||||
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
|
||||
pixfmt pixf(buf);
|
||||
agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
|
||||
pixfmt_comp_type pixf(buf);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(comp_op));
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
||||
box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box();
|
||||
coord<double,2> c = bbox.center();
|
||||
// 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_renderer<svg_path_adapter,
|
||||
agg::pod_bvector<path_attributes>,
|
||||
renderer_solid,
|
||||
renderer_type,
|
||||
agg::pixfmt_rgba32> svg_renderer(svg_path,
|
||||
(*marker.get_vector_data())->attributes());
|
||||
|
||||
svg_renderer.render(*ras_ptr, sl, renb, mtx, opacity, bbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: Add subpixel support
|
||||
pixmap_.set_rectangle_alpha2(**marker.get_bitmap_data(),
|
||||
boost::math::iround(pos.x),
|
||||
boost::math::iround(pos.y),
|
||||
opacity);
|
||||
{
|
||||
composite(current_buffer_->data(), **marker.get_bitmap_data(),
|
||||
comp_op, opacity,
|
||||
boost::math::iround(pos.x),
|
||||
boost::math::iround(pos.y),
|
||||
false, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,19 +55,23 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
{
|
||||
typedef agg::conv_clip_polyline<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
typedef agg::pixfmt_rgba32 pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
|
||||
|
||||
typedef agg::rgba8 color_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
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->gamma(agg::gamma_power());
|
||||
agg::scanline_u8 sl;
|
||||
agg::scanline_p8 sl_line;
|
||||
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_solid ren(renb);
|
||||
renderer_type ren(renb);
|
||||
agg::trans_affine tr;
|
||||
boost::array<double,6> const& m = sym.get_image_transform();
|
||||
tr.load_from(&m[0]);
|
||||
|
@ -104,9 +108,10 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
using namespace mapnik::svg;
|
||||
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>,
|
||||
renderer_solid,
|
||||
renderer_type,
|
||||
agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes());
|
||||
|
||||
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))
|
||||
{
|
||||
|
||||
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?
|
||||
//if (!sym.get_ignore_placement())
|
||||
|
|
|
@ -103,7 +103,7 @@ void agg_renderer<T>::process(point_symbolizer const& sym,
|
|||
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())
|
||||
detector_->insert(label_ext);
|
||||
|
|
|
@ -55,7 +55,8 @@ void agg_renderer<T>::process(shield_symbolizer const& sym,
|
|||
render_marker(helper.get_marker_position(placements[ii]),
|
||||
helper.get_marker(),
|
||||
helper.get_image_transform(),
|
||||
sym.get_opacity());
|
||||
sym.get_opacity(),
|
||||
sym.comp_op());
|
||||
|
||||
ren.prepare_glyphs(&(placements[ii]));
|
||||
ren.render(placements[ii].center);
|
||||
|
|
Loading…
Reference in a new issue