Fix seams of mesh faces when warping transparent raster

This commit is contained in:
Jiri Drbalek 2018-08-06 18:14:07 +02:00
parent 1a87e920da
commit 8b27aba0c4

View file

@ -51,6 +51,34 @@
namespace mapnik {
template <typename T>
struct pixel_format
{
using type = typename detail::agg_scaling_traits<T>::pixfmt_pre;
};
template <>
struct pixel_format<image_rgba8>
{
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<color_type, order_type>::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<src_blender, agg::rendering_buffer>;
};
template <typename T>
MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& prj_trans,
box2d<double> const& target_ext, box2d<double> 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<image_type>::pixfmt_pre;
using color_type = typename detail::agg_scaling_traits<image_type>::color_type;
using renderer_base = agg::renderer_base<pixfmt_pre>;
using output_pixfmt_type = typename pixel_format<T>::type;
using renderer_base = agg::renderer_base<output_pixfmt_type>;
using interpolator_type = typename detail::agg_scaling_traits<image_type>::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(