make composite method templated and fix visibility issue

(reverts  1ff4125e92)
This commit is contained in:
artemp 2014-12-12 11:39:36 +01:00
parent 3cbe969f03
commit 85d954ab6a
3 changed files with 16 additions and 26 deletions

View file

@ -82,18 +82,13 @@ enum composite_mode_e
MAPNIK_DECL boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> comp_op_to_string(composite_mode_e comp_op);
MAPNIK_DECL void composite(image_data_rgba8 & dst, image_data_rgba8 & src,
template <typename T>
MAPNIK_DECL void composite(T & dst, T & src,
composite_mode_e mode,
float opacity=1,
int dx=0,
int dy=0,
bool premultiply_src=false);
MAPNIK_DECL void composite(image_data_gray32f & dst, image_data_gray32f & src,
composite_mode_e mode,
float opacity=1,
int dx=0,
int dy=0,
bool premultiply_src=false);
}
#endif // MAPNIK_IMAGE_COMPOSITING_HPP

View file

@ -60,13 +60,14 @@ enum scaling_method_e
MAPNIK_DECL boost::optional<scaling_method_e> scaling_method_from_string(std::string const& name);
MAPNIK_DECL boost::optional<std::string> scaling_method_to_string(scaling_method_e scaling_method);
template <typename T> MAPNIK_DECL void scale_image_agg(T & target, T const& source,
scaling_method_e scaling_method,
double image_ratio_x,
double image_ratio_y,
double x_off_f,
double y_off_f,
double filter_factor);
template <typename T>
MAPNIK_DECL void scale_image_agg(T & target, T const& source,
scaling_method_e scaling_method,
double image_ratio_x,
double image_ratio_y,
double x_off_f,
double y_off_f,
double filter_factor);
}
#endif // MAPNIK_IMAGE_SCALING_HPP

View file

@ -122,8 +122,8 @@ For example, if you generate some pattern with AGG (premultiplied) and would lik
*/
void composite(mapnik::image_data_rgba8 & dst, mapnik::image_data_rgba8 & src, composite_mode_e mode,
template <>
MAPNIK_DECL void composite(image_data_rgba8 & dst, image_data_rgba8 & src, composite_mode_e mode,
float opacity,
int dx,
int dy,
@ -147,29 +147,23 @@ void composite(mapnik::image_data_rgba8 & dst, mapnik::image_data_rgba8 & src, c
ren.blend_from(pixf_mask,0,dx,dy,unsigned(255*opacity));
}
void composite(mapnik::image_data_gray32f & dst, mapnik::image_data_gray32f & src, composite_mode_e mode,
template <>
MAPNIK_DECL void composite(image_data_gray32f & dst, image_data_gray32f & src, composite_mode_e mode,
float opacity,
int dx,
int dy,
bool premultiply_src)
{
//using color = agg::gray32;
//using order = agg::order_gray32;
//using blender_type = agg::comp_op_adaptor_rgba_pre<color, order>;
using pixfmt_type = agg::pixfmt_gray32;//agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
using pixfmt_type = agg::pixfmt_gray32;
using renderer_type = agg::renderer_base<pixfmt_type>;
agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.width());
agg::rendering_buffer src_buffer(src.getBytes(),src.width(),src.height(),src.width());
pixfmt_type pixf(dst_buffer);
//pixf.comp_op(static_cast<agg::comp_op_e>(mode));
agg::pixfmt_gray32 pixf_mask(src_buffer);
//if (premultiply_src) pixf_mask.premultiply();
renderer_type ren(pixf);
//ren.blend_from(pixf_mask,0,dx,dy,agg::cover_full);//unsigned(255*opacity));
ren.copy_from(pixf_mask,0,dx,dy);//unsigned(255*opacity));
ren.copy_from(pixf_mask,0,dx,dy);;
}
}