Merge pull request #3967 from mapycz/fix-warp-transparent-raster

Fix seams of mesh faces when warping transparent raster
This commit is contained in:
lightmare 2018-08-15 23:07:29 +02:00 committed by GitHub
commit 6a7317d354
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 4 deletions

View file

@ -51,6 +51,34 @@
namespace mapnik { 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> template <typename T>
MAPNIK_DECL void warp_image (T & target, T const& source, proj_transform const& prj_trans, 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, 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 pixel_type = typename image_type::pixel_type;
using pixfmt_pre = typename detail::agg_scaling_traits<image_type>::pixfmt_pre; 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 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; using interpolator_type = typename detail::agg_scaling_traits<image_type>::interpolator_type;
constexpr std::size_t pixel_size = sizeof(pixel_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.width(),
target.height(), target.height(),
target.width() * pixel_size); target.width() * pixel_size);
pixfmt_pre pixf(buf); output_pixfmt_type pixf(buf);
renderer_base rb(pixf); renderer_base rb(pixf);
rasterizer.clip_box(0, 0, target.width(), target.height()); rasterizer.clip_box(0, 0, target.width(), target.height());
agg::rendering_buffer buf_tile( agg::rendering_buffer buf_tile(

@ -1 +1 @@
Subproject commit 049658fa104f368f78c3e8d9bddd50719492bcd5 Subproject commit 9cf6c17c9ecf9fa970c4f13d8b481817a2cb8015

@ -1 +1 @@
Subproject commit bbeb5ec35c75fa8b5712f8215f132a19e84ea1fb Subproject commit 263360fae07cceee0fbdb7fa213ae76f3977c567