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 render(mapnik::image_rgba8 const& image) const { 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; } using vertex_converter_type = vertex_converter<clip_poly_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; using pattern_type = agg_polygon_pattern<vertex_converter_type>; pattern_type pattern(image, common_, sym_, feature_, prj_trans_); pattern_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_))); pattern_type::renderer_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); pattern_type::img_source_type img_src(pixf_pattern); if (prj_trans_.equal() && pattern.clip_) pattern.converter_.set<clip_poly_tag>(); ras_ptr_->filling_rule(agg::fill_even_odd); pattern.render(renb, *ras_ptr_); }
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 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<T>::process(polygon_pattern_symbolizer const& sym, mapnik::feature_ptr const& feature, proj_transform const& prj_trans) { typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type; typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type; typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base; typedef agg::wrap_mode_repeat wrap_x_type; typedef agg::wrap_mode_repeat wrap_y_type; typedef agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_plain, agg::row_accessor<agg::int8u>, agg::pixel32_type> rendering_buffer; typedef agg::image_accessor_wrap<rendering_buffer, wrap_x_type, wrap_y_type> img_source_type; typedef agg::span_pattern_rgba<img_source_type> span_gen_type; typedef agg::renderer_scanline_aa<ren_base, agg::span_allocator<agg::rgba8>, span_gen_type> renderer_type; agg::rendering_buffer buf(pixmap_.raw_data(),width_,height_, width_ * 4); agg::pixfmt_rgba32_plain pixf(buf); ren_base renb(pixf); agg::scanline_u8 sl; ras_ptr->reset(); set_gamma_method(sym,ras_ptr); std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); boost::optional<mapnik::marker_ptr> marker; if ( !filename.empty() ) { marker = marker_cache::instance()->find(filename, true); } else { std::clog << "### Warning: file not found: " << filename << "\n"; } if (!marker) return; if (!(*marker)->is_bitmap()) { std::clog << "### Warning only images (not '" << filename << "') are supported in the polygon_pattern_symbolizer\n"; return; } boost::optional<image_ptr> pat = (*marker)->get_bitmap_data(); if (!pat) return; unsigned w=(*pat)->width(); unsigned h=(*pat)->height(); agg::row_accessor<agg::int8u> pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4); agg::span_allocator<agg::rgba8> sa; agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_plain, agg::row_accessor<agg::int8u>, agg::pixel32_type> pixf_pattern(pattern_rbuf); img_source_type img_src(pixf_pattern); unsigned num_geometries = feature->num_geometries(); pattern_alignment_e align = sym.get_alignment(); unsigned offset_x=0; unsigned offset_y=0; if (align == LOCAL_ALIGNMENT) { double x0=0,y0=0; if (num_geometries>0) // FIXME: hmm...? { clipped_geometry_type clipped(feature->get_geometry(0)); clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy()); path_type path(t_,clipped,prj_trans); path.vertex(&x0,&y0); } offset_x = unsigned(width_-x0); offset_y = unsigned(height_-y0); } span_gen_type sg(img_src, offset_x, offset_y); renderer_type rp(renb,sa, sg); //metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;i<num_geometries;++i) { geometry_type & geom = feature->get_geometry(i); if (geom.num_points() > 2) { clipped_geometry_type clipped(geom); clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_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); } } agg::render_scanlines(*ras_ptr, sl, rp); }
void agg_renderer<T0,T1>::process(building_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { using transform_path_type = transform_path_adapter<view_transform, vertex_adapter>; using ren_base = agg::renderer_base<agg::pixfmt_rgba32_pre>; using renderer = agg::renderer_scanline_aa_solid<ren_base>; agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize()); agg::pixfmt_rgba32_pre pixf(buf); ren_base renb(pixf); value_double opacity = get<value_double,keys::fill_opacity>(sym,feature, common_.vars_); color const& fill = get<color, keys::fill>(sym, feature, common_.vars_); unsigned r=fill.red(); unsigned g=fill.green(); unsigned b=fill.blue(); unsigned a=fill.alpha(); renderer ren(renb); agg::scanline_u8 sl; ras_ptr->reset(); 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; } double height = get<double, keys::height>(sym, feature, common_.vars_) * common_.scale_factor_; render_building_symbolizer( feature, height, [&,r,g,b,a,opacity](path_type const& faces) { vertex_adapter va(faces); transform_path_type faces_path (this->common_.t_,va,prj_trans); ras_ptr->add_path(faces_path); ren.color(agg::rgba8_pre(int(r*0.8), int(g*0.8), int(b*0.8), int(a * opacity))); agg::render_scanlines(*ras_ptr, sl, ren); this->ras_ptr->reset(); }, [&,r,g,b,a,opacity](path_type const& frame) { vertex_adapter va(frame); transform_path_type path(common_.t_,va, prj_trans); agg::conv_stroke<transform_path_type> stroke(path); stroke.width(common_.scale_factor_); ras_ptr->add_path(stroke); ren.color(agg::rgba8_pre(int(r*0.8), int(g*0.8), int(b*0.8), int(a * opacity))); agg::render_scanlines(*ras_ptr, sl, ren); ras_ptr->reset(); }, [&,r,g,b,a,opacity](path_type const& roof) { vertex_adapter va(roof); transform_path_type roof_path (common_.t_,va,prj_trans); ras_ptr->add_path(roof_path); ren.color(agg::rgba8_pre(r, g, b, int(a * opacity))); agg::render_scanlines(*ras_ptr, sl, ren); }); }
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_); std::shared_ptr<mapnik::marker const> marker = marker_cache::instance().find(filename, true); if (marker->is<marker_null>()) { return; } 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; } using vertex_converter_type = vertex_converter<transform2_tag, clip_poly_tag, transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; using pattern_type = agg_polygon_pattern<vertex_converter_type>; common_pattern_process_visitor visitor(common_, sym, feature); image_rgba8 image(util::apply_visitor(visitor, *marker)); pattern_type pattern(image, common_, sym, feature, prj_trans); pattern_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_))); pattern_type::renderer_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); pattern_type::img_source_type img_src(pixf_pattern); if (pattern.clip_ && !pattern.prj_trans_.equal()) { pattern.converter_.template set<transform2_tag>(); } else { pattern.converter_.template set<transform_tag>(); } if (pattern.clip_) pattern.converter_.set<clip_poly_tag>(); ras_ptr->filling_rule(agg::fill_even_odd); pattern.render(renb, *ras_ptr); }