+ pass scale_factor to vertex_converter
This commit is contained in:
parent
44c5efbf75
commit
e23fdb276f
5 changed files with 43 additions and 16 deletions
|
@ -121,7 +121,7 @@ struct converter_traits<T, mapnik::dash_tag>
|
|||
static void setup(geometry_type & geom, Args & args)
|
||||
{
|
||||
typename boost::mpl::at<Args,boost::mpl::int_<2> >::type sym = boost::fusion::at_c<2>(args);
|
||||
double scale_factor = 1.0; //FIXME
|
||||
double scale_factor = boost::fusion::at_c<5>(args);
|
||||
stroke const& stroke_ = sym.get_stroke();
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
|
@ -312,14 +312,17 @@ struct vertex_converter : private boost::noncopyable
|
|||
rasterizer_type&,
|
||||
symbolizer_type const&,
|
||||
trans_type const&,
|
||||
proj_trans_type const&
|
||||
proj_trans_type const&,
|
||||
double //scale-factor
|
||||
> args_type;
|
||||
|
||||
vertex_converter(bbox_type const& b, rasterizer_type & ras,
|
||||
symbolizer_type const& sym, trans_type & tr, proj_trans_type const& prj_trans)
|
||||
symbolizer_type const& sym, trans_type & tr,
|
||||
proj_trans_type const& prj_trans,
|
||||
double scale_factor)
|
||||
: disp_(args_type(boost::cref(b),boost::ref(ras),
|
||||
boost::cref(sym),boost::cref(tr),
|
||||
boost::cref(prj_trans))) {}
|
||||
boost::cref(prj_trans),scale_factor)) {}
|
||||
|
||||
template <typename Geometry>
|
||||
void apply(Geometry & geom)
|
||||
|
|
|
@ -88,7 +88,7 @@ void agg_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
|
||||
typedef boost::mpl::vector<clip_line_tag,transform_tag> conv_types;
|
||||
vertex_converter<box2d<double>,rasterizer_type,line_pattern_symbolizer, proj_transform, CoordTransform, conv_types>
|
||||
converter(ext,ras,sym,t_,prj_trans);
|
||||
converter(ext,ras,sym,t_,prj_trans,scale_factor_);
|
||||
|
||||
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
||||
converter.set<transform_tag>(); //always transform
|
||||
|
|
|
@ -105,7 +105,7 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
typedef boost::mpl::vector<clip_line_tag,transform_tag, offset_transform_tag, affine_transform_tag, smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
vertex_converter<box2d<double>,rasterizer,line_symbolizer, proj_transform, CoordTransform,conv_types>
|
||||
converter(ext,*ras_ptr,sym,t_,prj_trans);
|
||||
converter(ext,*ras_ptr,sym,t_,prj_trans,scale_factor_);
|
||||
|
||||
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
|
||||
converter.set<transform_tag>(); // always transform
|
||||
|
|
|
@ -46,6 +46,30 @@
|
|||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename ColorT,typename Order>
|
||||
struct multiplier
|
||||
{
|
||||
typedef typename ColorT::value_type value_type;
|
||||
typedef typename ColorT::calc_type calc_type;
|
||||
|
||||
void operator() (value_type * p) const
|
||||
{
|
||||
calc_type a = p[Order::A];
|
||||
if(a < ColorT::base_mask)
|
||||
{
|
||||
if(a == 0)
|
||||
{
|
||||
p[Order::R] = p[Order::G] = p[Order::B] = 0;
|
||||
return;
|
||||
}
|
||||
p[Order::R] = value_type((p[Order::R] * a + ColorT::base_mask) >> ColorT::base_shift);
|
||||
p[Order::G] = value_type((p[Order::G] * a + ColorT::base_mask) >> ColorT::base_shift);
|
||||
p[Order::B] = value_type((p[Order::B] * a + ColorT::base_mask) >> ColorT::base_shift);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
|
@ -54,7 +78,6 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->raw_data(), width_, height_, width_ * 4);
|
||||
agg::pixfmt_rgba32_plain pixf(buf);
|
||||
|
||||
|
@ -82,7 +105,6 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
boost::optional<image_ptr> pat = (*marker)->get_bitmap_data();
|
||||
|
||||
if (!pat) return;
|
||||
|
@ -106,7 +128,9 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
agg::row_accessor<agg::int8u> pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4);
|
||||
agg::span_allocator<agg::rgba8> sa;
|
||||
rendering_buffer pixf_pattern(pattern_rbuf);
|
||||
pixf_pattern.premultiply();
|
||||
|
||||
pixf_pattern.for_each_pixel(multiplier<agg::rgba8,agg::order_rgba>());
|
||||
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
||||
unsigned num_geometries = feature->num_geometries();
|
||||
|
@ -137,7 +161,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
box2d<double> inflated_extent = query_extent_ * 1.1;
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>,rasterizer,polygon_pattern_symbolizer, proj_transform, CoordTransform,conv_types>
|
||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans);
|
||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans, scale_factor_);
|
||||
|
||||
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
||||
converter.set<transform_tag>(); //always transform
|
||||
|
|
|
@ -51,7 +51,7 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
|
||||
typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
|
||||
vertex_converter<box2d<double>,rasterizer,polygon_symbolizer, proj_transform, CoordTransform,conv_types>
|
||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans);
|
||||
converter(inflated_extent,*ras_ptr,sym,t_,prj_trans,scale_factor_);
|
||||
|
||||
if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
|
||||
converter.set<transform_tag>(); //always transform
|
||||
|
|
Loading…
Reference in a new issue