diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index d717c252c..3fc78e961 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -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 internal_buffer_; diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 67b4c4b13..f2bf6f0d4 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -248,21 +248,27 @@ void agg_renderer::end_style_processing(feature_type_style const& st) } template -void agg_renderer::render_marker(pixel_position const& pos, marker const& marker, agg::trans_affine const& tr, double opacity) +void agg_renderer::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 renderer_base; - typedef agg::renderer_scanline_aa_solid 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 blender_type; // comp blender + typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; + typedef agg::renderer_base renderer_base; + typedef agg::renderer_scanline_aa_solid 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(comp_op)); renderer_base renb(pixf); - + box2d const& bbox = (*marker.get_vector_data())->bounding_box(); coord c = bbox.center(); // center the svg marker on '0,0' @@ -277,19 +283,19 @@ void agg_renderer::render_marker(pixel_position const& pos, marker const& mar svg_path_adapter svg_path(stl_storage); svg_renderer, - 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); } } diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index cce8ca3b3..bced49428 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -55,19 +55,23 @@ void agg_renderer::process(markers_symbolizer const& sym, { typedef agg::conv_clip_polyline clipped_geometry_type; typedef coord_transform2 path_type; - - typedef agg::pixfmt_rgba32 pixfmt; - typedef agg::renderer_base renderer_base; - typedef agg::renderer_scanline_aa_solid 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 blender_type; // comp blender + typedef agg::pixfmt_custom_blend_rgba pixfmt_comp_type; + typedef agg::renderer_base renderer_base; + typedef agg::renderer_scanline_aa_solid 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(sym.comp_op())); renderer_base renb(pixf); - renderer_solid ren(renb); + renderer_type ren(renb); agg::trans_affine tr; boost::array const& m = sym.get_image_transform(); tr.load_from(&m[0]); @@ -104,9 +108,10 @@ void agg_renderer::process(markers_symbolizer const& sym, using namespace mapnik::svg; vertex_stl_adapter stl_storage((*marker)->source()); svg_path_adapter svg_path(stl_storage); + svg_renderer, - renderer_solid, + renderer_type, agg::pixfmt_rgba32 > svg_renderer(svg_path,(*marker)->attributes()); for (unsigned i=0; inum_geometries(); ++i) @@ -127,7 +132,7 @@ void agg_renderer::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()) diff --git a/src/agg/process_point_symbolizer.cpp b/src/agg/process_point_symbolizer.cpp index 4e98e1e28..6d545e214 100644 --- a/src/agg/process_point_symbolizer.cpp +++ b/src/agg/process_point_symbolizer.cpp @@ -103,7 +103,7 @@ void agg_renderer::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); diff --git a/src/agg/process_shield_symbolizer.cpp b/src/agg/process_shield_symbolizer.cpp index 4cd416c74..db38b5778 100644 --- a/src/agg/process_shield_symbolizer.cpp +++ b/src/agg/process_shield_symbolizer.cpp @@ -55,7 +55,8 @@ void agg_renderer::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);