void agg_renderer<T0,T1>::process(shield_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { box2d<double> clip_box = clipping_extent(); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clip_box); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature, common_.vars_, HALO_RASTERIZER_FULL); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over); composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_, src_over); agg_text_renderer<T0> ren(*current_buffer_, halo_rasterizer, comp_op, halo_comp_op, common_.scale_factor_, common_.font_manager_.get_stroker()); double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0); placements_list const& placements = helper.get(); for (glyph_positions_ptr glyphs : placements) { if (glyphs->marker()) render_marker(glyphs->marker_pos(), *(glyphs->marker()->marker), glyphs->marker()->transform, opacity, comp_op); ren.render(*glyphs); } }
void agg_renderer<T0,T1>::process(group_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { thunk_renderer<buffer_type> ren(*this, ras_ptr, current_buffer_, common_); render_group_symbolizer( sym, feature, common_.vars_, prj_trans, clipping_extent(common_), common_, ren); }
void agg_renderer<T0,T1>::process(shield_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { box2d<double> clip_box = clipping_extent(common_); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clip_box, tr); pixel_position originalLocation = helper.getScreenPostion(); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature, common_.vars_, HALO_RASTERIZER_FULL); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over); composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_, src_over); agg_text_renderer<T0> ren(*current_buffer_, halo_rasterizer, comp_op, halo_comp_op, common_.scale_factor_, common_.font_manager_.get_stroker()); double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0); placements_list const& placements = helper.get(); for (glyph_positions_ptr glyphs : placements) { ren.render(*glyphs, originalLocation); if (glyphs->marker()) { agg::trans_affine tr; tr *= glyphs->marker()->transform; //apply any transform specified in the style xml tr *= glyphs->marker_placement_tr(); //apply any special placement transform render_marker(sym, feature, glyphs->marker_pos(), *(glyphs->marker()->marker), tr, opacity, comp_op); } } }
void agg_renderer<T0,T1>::process(group_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { render_group_symbolizer( sym, feature, common_.vars_, prj_trans, clipping_extent(common_), common_, [&](render_thunk_list const& thunks, pixel_position const& render_offset) { thunk_renderer<buffer_type> ren(*this, ras_ptr, current_buffer_, common_, render_offset); for (render_thunk_ptr const& thunk : thunks) { util::apply_visitor(ren, *thunk); } }); }
void agg_renderer<T0,T1>::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { using conv_types = boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag>; using vertex_converter_type = vertex_converter<box2d<double>, rasterizer, polygon_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl>; ras_ptr->reset(); double gamma = get<value_double>(sym, keys::gamma, feature, common_.vars_, 1.0); gamma_method_enum gamma_method = get<gamma_method_enum>(sym, keys::gamma_method, feature, common_.vars_, GAMMA_POWER); if (gamma != gamma_ || gamma_method != gamma_method_) { set_gamma_method(ras_ptr, gamma, gamma_method); gamma_method_ = gamma_method; gamma_ = gamma; } box2d<double> clip_box = clipping_extent(); agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); render_polygon_symbolizer<vertex_converter_type>( sym, feature, prj_trans, common_, clip_box, *ras_ptr, [&](color const &fill, double opacity) { unsigned r=fill.red(); unsigned g=fill.green(); unsigned b=fill.blue(); unsigned a=fill.alpha(); using color_type = agg::rgba8; using order_type = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using renderer_base = agg::renderer_base<pixfmt_comp_type>; using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>; pixfmt_comp_type pixf(buf); auto comp_op = get<agg::comp_op_e>(sym, keys::comp_op, feature, common_.vars_, agg::comp_op_src_over); pixf.comp_op(comp_op); renderer_base renb(pixf); renderer_type ren(renb); ren.color(agg::rgba8_pre(r, g, b, int(a * opacity))); agg::scanline_u8 sl; ras_ptr->filling_rule(agg::fill_even_odd); agg::render_scanlines(*ras_ptr, sl, ren); }); }
void grid_renderer<T>::process(text_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { box2d<double> clip_box = clipping_extent(common_); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clip_box, tr, common_.symbol_cache_); bool placement_found = false; composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over); grid_text_renderer<T> ren(pixmap_, comp_op, common_.scale_factor_); auto halo_transform = get_optional<transform_type>(sym, keys::halo_transform); if (halo_transform) { agg::trans_affine halo_affine_transform; evaluate_transform(halo_affine_transform, feature, common_.vars_, *halo_transform, common_.scale_factor_); ren.set_halo_transform(halo_affine_transform); } placements_list const& placements = helper.get(); value_integer feature_id = feature.id(); for (auto const& glyphs : placements) { ren.render(*glyphs, feature_id); placement_found = true; } if (placement_found) { pixmap_.add_feature(feature); } }
cairo_polygon_pattern(mapnik::marker const& marker, renderer_common const& common, symbolizer_base const& sym, mapnik::feature_impl const& feature, proj_transform const& prj_trans) : cairo_pattern_base{marker, common, sym, feature, prj_trans}, clip_(get<value_bool, keys::clip>(sym_, feature_, common_.vars_)), clip_box_(clipping_extent(common)), tr_(geom_transform()), converter_(clip_box_, sym, common.t_, prj_trans, tr_, feature, common.vars_, common.scale_factor_) { value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_); converter_.template set<affine_transform_tag>(); if (simplify_tolerance > 0.0) converter_.template set<simplify_tag>(); if (smooth > 0.0) converter_.template set<smooth_tag>(); }
void agg_renderer<T>::process(text_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { box2d<double> clip_box = clipping_extent(); text_symbolizer_helper helper( sym, feature, prj_trans, width_, height_, scale_factor_, t_, font_manager_, *detector_, clip_box); agg_text_renderer<T> ren(*current_buffer_, sym.get_halo_rasterizer(), sym.comp_op(), scale_factor_, font_manager_.get_stroker()); placements_list const& placements = helper.get(); for (glyph_positions_ptr glyphs : placements) { ren.render(*glyphs); } }
void agg_renderer<T0,T1>::process(shield_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { box2d<double> clip_box = clipping_extent(common_); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, common_.scale_factor_, common_.t_, common_.font_manager_, *common_.detector_, clip_box, tr); halo_rasterizer_enum halo_rasterizer = get<halo_rasterizer_enum>(sym, keys::halo_rasterizer, feature, common_.vars_, HALO_RASTERIZER_FULL); composite_mode_e comp_op = get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over); composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_, src_over); agg_text_renderer<T0> ren(*current_buffer_, halo_rasterizer, comp_op, halo_comp_op, common_.scale_factor_, common_.font_manager_.get_stroker()); double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0); placements_list const& placements = helper.get(); for (glyph_positions_ptr glyphs : placements) { marker_info_ptr mark = glyphs->get_marker(); if (mark) { render_marker(glyphs->marker_pos(), mark->marker_, mark->transform_, opacity, comp_op); } ren.render(*glyphs); } }
void agg_renderer<T0,T1>::process(line_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { color const& col = get<color, keys::stroke>(sym, feature, common_.vars_); unsigned r=col.red(); unsigned g=col.green(); unsigned b=col.blue(); unsigned a=col.alpha(); double gamma = get<value_double, keys::stroke_gamma>(sym, feature, common_.vars_); gamma_method_enum gamma_method = get<gamma_method_enum, keys::stroke_gamma_method>(sym, feature, common_.vars_); ras_ptr->reset(); if (gamma != gamma_ || gamma_method != gamma_method_) { set_gamma_method(ras_ptr, gamma, gamma_method); gamma_method_ = gamma_method; gamma_ = gamma; } agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); using color_type = agg::rgba8; using order_type = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using renderer_base = agg::renderer_base<pixfmt_comp_type>; pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym, feature, common_.vars_))); renderer_base renb(pixf); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); box2d<double> clip_box = clipping_extent(common_); value_bool clip = get<value_bool, keys::clip>(sym, feature, common_.vars_); value_double width = get<value_double, keys::stroke_width>(sym, feature, common_.vars_); value_double opacity = get<value_double,keys::stroke_opacity>(sym,feature, common_.vars_); value_double offset = get<value_double, keys::offset>(sym, feature, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_); line_rasterizer_enum rasterizer_e = get<line_rasterizer_enum, keys::line_rasterizer>(sym, feature, common_.vars_); if (clip) { double padding = static_cast<double>(common_.query_extent_.width()/pixmap_.width()); double half_stroke = 0.5 * width; if (half_stroke > 1) { padding *= half_stroke; } if (std::fabs(offset) > 0) { padding *= std::fabs(offset) * 1.2; } padding *= common_.scale_factor_; clip_box.pad(padding); // debugging //box2d<double> inverse = query_extent_; //inverse.pad(-padding); //draw_geo_extent(inverse,mapnik::color("red")); } if (rasterizer_e == RASTERIZER_FAST) { using renderer_type = agg::renderer_outline_aa<renderer_base>; using rasterizer_type = agg::rasterizer_outline_aa<renderer_type>; agg::line_profile_aa profile(width * common_.scale_factor_, agg::gamma_power(gamma)); renderer_type ren(renb, profile); ren.color(agg::rgba8_pre(r, g, b, int(a * opacity))); rasterizer_type ras(ren); set_join_caps_aa(sym, ras, feature, common_.vars_); vertex_converter<rasterizer_type,clip_line_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag, offset_transform_tag, dash_tag, stroke_tag> converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set<clip_line_tag>(); // optional clip (default: true) converter.set<transform_tag>(); // always transform if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter for (geometry_type const& geom : feature.paths()) { if (geom.size() > 1) { vertex_adapter va(geom); converter.apply(va); } } } else { vertex_converter<rasterizer,clip_line_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag, offset_transform_tag, dash_tag, stroke_tag> converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set<clip_line_tag>(); // optional clip (default: true) converter.set<transform_tag>(); // always transform if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (has_key(sym, keys::stroke_dasharray)) converter.set<dash_tag>(); converter.set<stroke_tag>(); //always stroke for (geometry_type const& geom : feature.paths()) { if (geom.size() > 1) { vertex_adapter va(geom); converter.apply(va); } } using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>; renderer_type ren(renb); ren.color(agg::rgba8_pre(r, g, b, int(a * opacity))); agg::scanline_u8 sl; ras_ptr->filling_rule(agg::fill_non_zero); agg::render_scanlines(*ras_ptr, sl, ren); } }
void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { using color = agg::rgba8; using order = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>; using pattern_filter_type = agg::pattern_filter_bilinear_rgba8; using pattern_type = agg::line_image_pattern<pattern_filter_type>; using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using renderer_base = agg::renderer_base<pixfmt_type>; using renderer_type = agg::renderer_outline_image<renderer_base, pattern_type>; using rasterizer_type = agg::rasterizer_outline_aa<renderer_type>; std::string filename = get<std::string>(sym, keys::file, feature, common_.vars_); if (filename.empty()) return; boost::optional<mapnik::marker_ptr> marker_ptr = marker_cache::instance().find(filename, true); if (!marker_ptr || !(*marker_ptr)) return; boost::optional<image_ptr> pat; // TODO - re-implement at renderer level like polygon_pattern symbolizer double opacity = get<value_double>(sym, keys::opacity, feature, common_.vars_,1.0); if ((*marker_ptr)->is_bitmap()) { pat = (*marker_ptr)->get_bitmap_data(); } else { agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); auto image_transform = get_optional<transform_type>(sym, keys::image_transform); if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform); pat = render_pattern(*ras_ptr, **marker_ptr, image_tr, 1.0); } if (!pat) return; bool clip = get<value_bool>(sym, keys::clip, feature, common_.vars_, false); double offset = get<value_double>(sym, keys::offset, feature, common_.vars_, 0.0); double simplify_tolerance = get<value_double>(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0); double smooth = get<value_double>(sym, keys::smooth, feature, common_.vars_, false); agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); pixfmt_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e>(sym, keys::comp_op, feature, common_.vars_, src_over))); renderer_base ren_base(pixf); agg::pattern_filter_bilinear_rgba8 filter; pattern_source source(*(*pat), opacity); pattern_type pattern (filter,source); renderer_type ren(ren_base, pattern); rasterizer_type ras(ren); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); box2d<double> clip_box = clipping_extent(common_); if (clip) { double padding = (double)(common_.query_extent_.width()/pixmap_.width()); double half_stroke = (*marker_ptr)->width()/2.0; if (half_stroke > 1) padding *= half_stroke; if (std::fabs(offset) > 0) padding *= std::fabs(offset) * 1.2; padding *= common_.scale_factor_; clip_box.pad(padding); } using conv_types = boost::mpl::vector<clip_line_tag, transform_tag, affine_transform_tag, simplify_tag,smooth_tag, offset_transform_tag>; vertex_converter<box2d<double>, rasterizer_type, line_pattern_symbolizer, view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set<clip_line_tag>(); //optional clip (default: true) converter.set<transform_tag>(); //always transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { converter.apply(geom); } } }
void operator() (marker_svg const& marker) const { using color = agg::rgba8; using order = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>; using pattern_filter_type = agg::pattern_filter_bilinear_rgba8; using pattern_type = agg::line_image_pattern<pattern_filter_type>; using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using renderer_base = agg::renderer_base<pixfmt_type>; using renderer_type = agg::renderer_outline_image<renderer_base, pattern_type>; using rasterizer_type = agg::rasterizer_outline_aa<renderer_type>; value_double opacity = get<value_double, keys::opacity>(sym_, feature_, common_.vars_); agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); auto image_transform = get_optional<transform_type>(sym_, keys::image_transform); if (image_transform) evaluate_transform(image_tr, feature_, common_.vars_, *image_transform, common_.scale_factor_); mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr; image_rgba8 image(bbox_image.width(), bbox_image.height()); render_pattern<buffer_type>(*ras_ptr_, marker, image_tr, 1.0, image); value_bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_); value_double offset = get<value_double, keys::offset>(sym_, feature_, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym_, feature_, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym_, feature_, common_.vars_); agg::rendering_buffer buf(current_buffer_->bytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->row_size()); pixfmt_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym_, feature_, common_.vars_))); renderer_base ren_base(pixf); agg::pattern_filter_bilinear_rgba8 filter; pattern_source source(image, opacity); pattern_type pattern (filter,source); renderer_type ren(ren_base, pattern); double half_stroke = std::max(marker.width()/2.0,marker.height()/2.0); int rast_clip_padding = static_cast<int>(std::round(half_stroke)); ren.clip_box(-rast_clip_padding,-rast_clip_padding,common_.width_+rast_clip_padding,common_.height_+rast_clip_padding); rasterizer_type ras(ren); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym_, keys::geometry_transform); if (transform) evaluate_transform(tr, feature_, common_.vars_, *transform, common_.scale_factor_); box2d<double> clip_box = clipping_extent(common_); if (clip) { double padding = (double)(common_.query_extent_.width()/pixmap_.width()); if (half_stroke > 1) padding *= half_stroke; if (std::fabs(offset) > 0) padding *= std::fabs(offset) * 1.2; padding *= common_.scale_factor_; clip_box.pad(padding); } using vertex_converter_type = vertex_converter<clip_line_tag, transform_tag, affine_transform_tag, simplify_tag,smooth_tag, offset_transform_tag>; vertex_converter_type converter(clip_box,sym_,common_.t_,prj_trans_,tr,feature_,common_.vars_,common_.scale_factor_); if (clip) converter.set<clip_line_tag>(); converter.set<transform_tag>(); //always transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter using apply_vertex_converter_type = detail::apply_vertex_converter<vertex_converter_type, rasterizer_type>; using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>; apply_vertex_converter_type apply(converter, ras); mapnik::util::apply_visitor(vertex_processor_type(apply),feature_.get_geometry()); }
void operator() (marker_rgba8 const& marker) { using color = agg::rgba8; using order = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>; using pattern_filter_type = agg::pattern_filter_bilinear_rgba8; using pattern_type = agg::line_image_pattern<pattern_filter_type>; using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using renderer_base = agg::renderer_base<pixfmt_type>; using renderer_type = agg::renderer_outline_image<renderer_base, pattern_type>; using rasterizer_type = agg::rasterizer_outline_aa<renderer_type>; value_double opacity = get<value_double, keys::opacity>(sym_, feature_, common_.vars_); mapnik::image_rgba8 const& image = marker.get_data(); value_bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_); value_double offset = get<value_double, keys::offset>(sym_, feature_, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym_, feature_, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym_, feature_, common_.vars_); agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); pixfmt_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym_, feature_, common_.vars_))); renderer_base ren_base(pixf); agg::pattern_filter_bilinear_rgba8 filter; pattern_source source(image, opacity); pattern_type pattern (filter,source); renderer_type ren(ren_base, pattern); ren.clip_box(0,0,common_.width_,common_.height_); rasterizer_type ras(ren); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym_, keys::geometry_transform); if (transform) evaluate_transform(tr, feature_, common_.vars_, *transform, common_.scale_factor_); box2d<double> clip_box = clipping_extent(common_); if (clip) { double padding = (double)(common_.query_extent_.width()/pixmap_.width()); double half_stroke = marker.width()/2.0; if (half_stroke > 1) padding *= half_stroke; if (std::fabs(offset) > 0) padding *= std::fabs(offset) * 1.2; padding *= common_.scale_factor_; clip_box.pad(padding); } vertex_converter<rasterizer_type, clip_line_tag, transform_tag, affine_transform_tag, simplify_tag,smooth_tag, offset_transform_tag> converter(clip_box,ras,sym_,common_.t_,prj_trans_,tr,feature_,common_.vars_,common_.scale_factor_); if (clip) converter.set<clip_line_tag>(); //optional clip (default: true) converter.set<transform_tag>(); //always transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (std::fabs(offset) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter for (geometry_type const& geom : feature_.paths()) { if (geom.size() > 1) { vertex_adapter va(geom); converter.apply(va); } } }
void agg_renderer<T>::process(line_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { stroke const& stroke_ = sym.get_stroke(); color const& col = stroke_.get_color(); unsigned r=col.red(); unsigned g=col.green(); unsigned b=col.blue(); unsigned a=col.alpha(); ras_ptr->reset(); if (stroke_.get_gamma() != gamma_ || stroke_.get_gamma_method() != gamma_method_) { set_gamma_method(stroke_, ras_ptr); gamma_method_ = stroke_.get_gamma_method(); gamma_ = stroke_.get_gamma(); } agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); typedef agg::rgba8 color_type; typedef agg::order_rgba order_type; typedef agg::comp_op_adaptor_rgba_pre<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 boost::mpl::vector<clip_line_tag, transform_tag, offset_transform_tag, affine_transform_tag, simplify_tag, smooth_tag, dash_tag, stroke_tag> conv_types; pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op())); renderer_base renb(pixf); agg::trans_affine tr; evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d<double> clip_box = clipping_extent(); if (sym.clip()) { double padding = (double)(query_extent_.width()/pixmap_.width()); double half_stroke = stroke_.get_width()/2.0; if (half_stroke > 1) padding *= half_stroke; if (std::fabs(sym.offset()) > 0) padding *= std::fabs(sym.offset()) * 1.2; padding *= scale_factor_; clip_box.pad(padding); // debugging //box2d<double> inverse = query_extent_; //inverse.pad(-padding); //draw_geo_extent(inverse,mapnik::color("red")); } if (sym.get_rasterizer() == RASTERIZER_FAST) { typedef agg::renderer_outline_aa<renderer_base> renderer_type; typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; agg::line_profile_aa profile(stroke_.get_width() * scale_factor_, agg::gamma_power(stroke_.get_gamma())); renderer_type ren(renb, profile); ren.color(agg::rgba8_pre(r, g, b, int(a*stroke_.get_opacity()))); rasterizer_type ras(ren); set_join_caps_aa(stroke_,ras); vertex_converter<box2d<double>, rasterizer_type, line_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> converter(clip_box,ras,sym,t_,prj_trans,tr,scale_factor_); if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true) converter.set<transform_tag>(); // always transform if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { converter.apply(geom); } } } else { vertex_converter<box2d<double>, rasterizer, line_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> converter(clip_box,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_); if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true) converter.set<transform_tag>(); // always transform if (std::fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset converter.set<affine_transform_tag>(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter if (stroke_.has_dash()) converter.set<dash_tag>(); converter.set<stroke_tag>(); //always stroke for (geometry_type & geom : feature.paths()) { if (geom.size() > 1) { converter.apply(geom); } } typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type; renderer_type ren(renb); ren.color(agg::rgba8_pre(r, g, b, int(a * stroke_.get_opacity()))); agg::scanline_u8 sl; ras_ptr->filling_rule(agg::fill_non_zero); agg::render_scanlines(*ras_ptr, sl, ren); } }
void operator() (marker_svg const& marker) { agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); auto image_transform = get_optional<transform_type>(sym_, keys::image_transform); if (image_transform) evaluate_transform(image_tr, feature_, common_.vars_, *image_transform); mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr; mapnik::image_rgba8 image(bbox_image.width(), bbox_image.height()); render_pattern<buffer_type>(*ras_ptr_, marker, image_tr, 1.0, image); agg::rendering_buffer buf(current_buffer_->bytes(), current_buffer_->width(), current_buffer_->height(), current_buffer_->row_size()); ras_ptr_->reset(); value_double gamma = get<value_double, keys::gamma>(sym_, feature_, common_.vars_); gamma_method_enum gamma_method = get<gamma_method_enum, keys::gamma_method>(sym_, feature_, common_.vars_); if (gamma != gamma_ || gamma_method != gamma_method_) { set_gamma_method(ras_ptr_, gamma, gamma_method); gamma_method_ = gamma_method; gamma_ = gamma; } value_bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_); value_double opacity = get<double, keys::opacity>(sym_, feature_, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym_, feature_, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym_, feature_, common_.vars_); box2d<double> clip_box = clipping_extent(common_); using color = agg::rgba8; using order = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>; using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using wrap_x_type = agg::wrap_mode_repeat; using wrap_y_type = agg::wrap_mode_repeat; using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre, wrap_x_type, wrap_y_type>; using span_gen_type = agg::span_pattern_rgba<img_source_type>; using ren_base = agg::renderer_base<pixfmt_type>; using renderer_type = agg::renderer_scanline_aa_alpha<ren_base, agg::span_allocator<agg::rgba8>, span_gen_type>; pixfmt_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym_, feature_, common_.vars_))); ren_base renb(pixf); unsigned w = image.width(); unsigned h = image.height(); agg::rendering_buffer pattern_rbuf((agg::int8u*)image.bytes(),w,h,w*4); agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); pattern_alignment_enum alignment = get<pattern_alignment_enum, keys::alignment>(sym_, feature_, common_.vars_); unsigned offset_x=0; unsigned offset_y=0; if (alignment == LOCAL_ALIGNMENT) { double x0 = 0; double y0 = 0; using apply_local_alignment = detail::apply_local_alignment; apply_local_alignment apply(common_.t_,prj_trans_, clip_box, x0, y0); util::apply_visitor(geometry::vertex_processor<apply_local_alignment>(apply), feature_.get_geometry()); offset_x = unsigned(current_buffer_->width() - x0); offset_y = unsigned(current_buffer_->height() - y0); } span_gen_type sg(img_src, offset_x, offset_y); agg::span_allocator<agg::rgba8> sa; renderer_type rp(renb,sa, sg, unsigned(opacity * 255)); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym_, keys::geometry_transform); if (transform) evaluate_transform(tr, feature_, common_.vars_, *transform, common_.scale_factor_); using vertex_converter_type = vertex_converter<clip_poly_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; vertex_converter_type converter(clip_box,sym_,common_.t_,prj_trans_,tr,feature_,common_.vars_,common_.scale_factor_); if (prj_trans_.equal() && clip) converter.set<clip_poly_tag>(); converter.set<transform_tag>(); //always transform converter.set<affine_transform_tag>(); // optional affine transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter using apply_vertex_converter_type = detail::apply_vertex_converter<vertex_converter_type, rasterizer>; using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>; apply_vertex_converter_type apply(converter, *ras_ptr_); mapnik::util::apply_visitor(vertex_processor_type(apply),feature_.get_geometry()); agg::scanline_u8 sl; ras_ptr_->filling_rule(agg::fill_even_odd); agg::render_scanlines(*ras_ptr_, sl, rp); }
void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { std::string filename = get<std::string, keys::file>(sym, feature, common_.vars_); if (filename.empty()) return; std::shared_ptr<mapnik::marker const> marker = marker_cache::instance().find(filename, true); buffer_type & current_buffer = buffers_.top().get(); agg::rendering_buffer buf(current_buffer.bytes(), current_buffer.width(), current_buffer.height(), current_buffer.row_size()); ras_ptr->reset(); value_double gamma = get<value_double, keys::gamma>(sym, feature, common_.vars_); gamma_method_enum gamma_method = get<gamma_method_enum, keys::gamma_method>(sym, feature, common_.vars_); if (gamma != gamma_ || gamma_method != gamma_method_) { set_gamma_method(ras_ptr, gamma, gamma_method); gamma_method_ = gamma_method; gamma_ = gamma; } value_bool clip = get<value_bool, keys::clip>(sym, feature, common_.vars_); value_double opacity = get<double, keys::opacity>(sym, feature, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_); using color = agg::rgba8; using order = agg::order_rgba; using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>; using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>; using wrap_x_type = agg::wrap_mode_repeat; using wrap_y_type = agg::wrap_mode_repeat; using img_source_type = agg::image_accessor_wrap<agg::pixfmt_rgba32_pre, wrap_x_type, wrap_y_type>; using span_gen_type = agg::span_pattern_rgba<img_source_type>; using ren_base = agg::renderer_base<pixfmt_type>; using renderer_type = agg::renderer_scanline_aa_alpha<ren_base, agg::span_allocator<agg::rgba8>, span_gen_type>; pixfmt_type pixf(buf); pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym, feature, common_.vars_))); ren_base renb(pixf); common_pattern_process_visitor<polygon_pattern_symbolizer, rasterizer> visitor(*ras_ptr, common_, sym, feature); image_rgba8 image(util::apply_visitor(visitor, *marker)); unsigned w = image.width(); unsigned h = image.height(); agg::rendering_buffer pattern_rbuf((agg::int8u*)image.bytes(),w,h,w*4); agg::pixfmt_rgba32_pre pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); box2d<double> clip_box = clipping_extent(common_); coord<unsigned, 2> offset(detail::offset(sym, feature, prj_trans, common_, clip_box)); span_gen_type sg(img_src, offset.x, offset.y); agg::span_allocator<agg::rgba8> sa; renderer_type rp(renb,sa, sg, unsigned(opacity * 255)); agg::trans_affine tr; auto transform = get_optional<transform_type>(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); using vertex_converter_type = vertex_converter<clip_poly_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; vertex_converter_type converter(clip_box, sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); converter.set<transform_tag>(); //always transform converter.set<affine_transform_tag>(); // optional affine transform if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter using apply_vertex_converter_type = detail::apply_vertex_converter<vertex_converter_type, rasterizer>; using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>; apply_vertex_converter_type apply(converter, *ras_ptr); mapnik::util::apply_visitor(vertex_processor_type(apply),feature.get_geometry()); agg::scanline_u8 sl; ras_ptr->filling_rule(agg::fill_even_odd); agg::render_scanlines(*ras_ptr, sl, rp); }
void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { composite_mode_e comp_op = get<composite_mode_e, keys::comp_op>(sym, feature, common_.vars_); std::string filename = get<std::string, keys::file>(sym, feature, common_.vars_); value_bool clip = get<value_bool, keys::clip>(sym, feature, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_); value_double opacity = get<value_double, keys::opacity>(sym, feature, common_.vars_); agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); auto image_transform = get_optional<transform_type>(sym, keys::image_transform); if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform); cairo_save_restore guard(context_); context_.set_operator(comp_op); boost::optional<mapnik::marker_ptr> marker = mapnik::marker_cache::instance().find(filename,true); if (!marker || !(*marker)) return; unsigned offset_x=0; unsigned offset_y=0; box2d<double> const& clip_box = clipping_extent(common_); pattern_alignment_enum alignment = get<pattern_alignment_enum, keys::alignment>(sym, feature, common_.vars_); if (alignment == LOCAL_ALIGNMENT) { double x0 = 0.0; double y0 = 0.0; if (feature.num_geometries() > 0) { using clipped_geometry_type = agg::conv_clip_polygon<geometry_type>; using path_type = transform_path_adapter<view_transform,clipped_geometry_type>; clipped_geometry_type clipped(feature.get_geometry(0)); clipped.clip_box(clip_box.minx(), clip_box.miny(), clip_box.maxx(), clip_box.maxy()); path_type path(common_.t_, clipped, prj_trans); path.vertex(&x0, &y0); } offset_x = std::abs(clip_box.width() - x0); offset_y = std::abs(clip_box.height() - y0); } if ((*marker)->is_bitmap()) { cairo_pattern pattern(**((*marker)->get_bitmap_data()), opacity); pattern.set_extend(CAIRO_EXTEND_REPEAT); pattern.set_origin(offset_x, offset_y); context_.set_pattern(pattern); } else { mapnik::rasterizer ras; image_ptr image = render_pattern(ras, **marker, image_tr, 1.0); // cairo_pattern pattern(*image, opacity); pattern.set_extend(CAIRO_EXTEND_REPEAT); pattern.set_origin(offset_x, offset_y); context_.set_pattern(pattern); } agg::trans_affine tr; auto geom_transform = get_optional<transform_type>(sym, keys::geometry_transform); if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); } vertex_converter<cairo_context,clip_poly_tag,transform_tag,affine_transform_tag,simplify_tag,smooth_tag> converter(clip_box, context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); //optional clip (default: true) converter.set<transform_tag>(); //always transform converter.set<affine_transform_tag>(); if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter for ( geometry_type & geom : feature.paths()) { if (geom.size() > 2) { converter.apply(geom); } } // fill polygon context_.set_fill_rule(CAIRO_FILL_RULE_EVEN_ODD); context_.fill(); }
void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { composite_mode_e comp_op = get<composite_mode_e, keys::comp_op>(sym, feature, common_.vars_); std::string filename = get<std::string, keys::file>(sym, feature, common_.vars_); value_bool clip = get<value_bool, keys::clip>(sym, feature, common_.vars_); value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_); value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_); value_double opacity = get<value_double, keys::opacity>(sym, feature, common_.vars_); agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); auto image_transform = get_optional<transform_type>(sym, keys::image_transform); if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform); cairo_save_restore guard(context_); context_.set_operator(comp_op); std::shared_ptr<mapnik::marker const> marker = mapnik::marker_cache::instance().find(filename,true); if (marker->is<mapnik::marker_null>()) return; unsigned offset_x=0; unsigned offset_y=0; box2d<double> const& clip_box = clipping_extent(common_); pattern_alignment_enum alignment = get<pattern_alignment_enum, keys::alignment>(sym, feature, common_.vars_); if (alignment == LOCAL_ALIGNMENT) { double x0 = 0.0; double y0 = 0.0; using apply_local_alignment = detail::apply_local_alignment; apply_local_alignment apply(common_.t_, prj_trans, clip_box, x0, y0); util::apply_visitor(geometry::vertex_processor<apply_local_alignment>(apply), feature.get_geometry()); offset_x = std::abs(clip_box.width() - x0); offset_y = std::abs(clip_box.height() - y0); } util::apply_visitor(cairo_renderer_process_visitor_p(context_, image_tr, offset_x, offset_y, opacity), *marker); agg::trans_affine tr; auto geom_transform = get_optional<transform_type>(sym, keys::geometry_transform); if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); } using vertex_converter_type = vertex_converter< clip_poly_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; vertex_converter_type converter(clip_box,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set<clip_poly_tag>(); //optional clip (default: true) converter.set<transform_tag>(); //always transform converter.set<affine_transform_tag>(); if (simplify_tolerance > 0.0) converter.set<simplify_tag>(); // optional simplify converter if (smooth > 0.0) converter.set<smooth_tag>(); // optional smooth converter using apply_vertex_converter_type = detail::apply_vertex_converter<vertex_converter_type, cairo_context>; using vertex_processor_type = geometry::vertex_processor<apply_vertex_converter_type>; apply_vertex_converter_type apply(converter, context_); mapnik::util::apply_visitor(vertex_processor_type(apply),feature.get_geometry()); // fill polygon context_.set_fill_rule(CAIRO_FILL_RULE_EVEN_ODD); context_.fill(); }