From 8b27aba0c412b129a379101c00450819d3835ef4 Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Mon, 6 Aug 2018 18:14:07 +0200 Subject: [PATCH 1/2] Fix seams of mesh faces when warping transparent raster --- src/warp.cpp | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/warp.cpp b/src/warp.cpp index 58f0fbeee..b066bbfd1 100644 --- a/src/warp.cpp +++ b/src/warp.cpp @@ -51,6 +51,34 @@ namespace mapnik { +template +struct pixel_format +{ + using type = typename detail::agg_scaling_traits::pixfmt_pre; +}; + +template <> +struct pixel_format +{ + struct src_blender + { + using color_type = agg::rgba8; + using order_type = agg::order_rgba; + using value_type = typename color_type::value_type; + + static inline void blend_pix(unsigned /*op*/, value_type* p, + unsigned cr, unsigned cg, unsigned cb, + unsigned ca, + unsigned cover) + { + agg::comp_op_rgba_src::blend_pix(p, cr, cg, cb, ca, cover); + } + }; + + // Use comp_op_src to fix seams between faces of the mesh + using type = agg::pixfmt_custom_blend_rgba; +}; + template MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& prj_trans, box2d const& target_ext, box2d const& source_ext, @@ -61,7 +89,8 @@ MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& using pixel_type = typename image_type::pixel_type; using pixfmt_pre = typename detail::agg_scaling_traits::pixfmt_pre; using color_type = typename detail::agg_scaling_traits::color_type; - using renderer_base = agg::renderer_base; + using output_pixfmt_type = typename pixel_format::type; + using renderer_base = agg::renderer_base; using interpolator_type = typename detail::agg_scaling_traits::interpolator_type; constexpr std::size_t pixel_size = sizeof(pixel_type); @@ -95,7 +124,7 @@ MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& target.width(), target.height(), target.width() * pixel_size); - pixfmt_pre pixf(buf); + output_pixfmt_type pixf(buf); renderer_base rb(pixf); rasterizer.clip_box(0, 0, target.width(), target.height()); agg::rendering_buffer buf_tile( From b50498cb535b4bbb9ee588917373cfcca1ddf1be Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 7 Aug 2018 11:58:24 +0000 Subject: [PATCH 2/2] Update test data --- test/data | 2 +- test/data-visual | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data b/test/data index 049658fa1..9cf6c17c9 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit 049658fa104f368f78c3e8d9bddd50719492bcd5 +Subproject commit 9cf6c17c9ecf9fa970c4f13d8b481817a2cb8015 diff --git a/test/data-visual b/test/data-visual index bbeb5ec35..263360fae 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit bbeb5ec35c75fa8b5712f8215f132a19e84ea1fb +Subproject commit 263360fae07cceee0fbdb7fa213ae76f3977c567