render_pattern() needs its own rasterizer

This commit is contained in:
Jiri Drbalek 2018-09-19 08:27:06 +00:00
parent fcec445a2e
commit 692fc7f107
6 changed files with 7 additions and 10 deletions

View file

@ -52,10 +52,9 @@ struct cairo_renderer_process_visitor_p
void operator() (marker_svg const& marker)
{
mapnik::rasterizer ras;
mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr_;
mapnik::image_rgba8 image(bbox_image.width(), bbox_image.height());
render_pattern<image_rgba8>(ras, marker, image_tr_, 1.0, image);
render_pattern<image_rgba8>(marker, image_tr_, 1.0, image);
cairo_pattern pattern(image, opacity_);
pattern.set_extend(CAIRO_EXTEND_REPEAT);
pattern.set_origin(offset_x_, offset_y_);

View file

@ -38,8 +38,7 @@ struct rasterizer;
struct marker_svg;
template <typename T>
void render_pattern(rasterizer & ras,
marker_svg const& marker,
void render_pattern(marker_svg const& marker,
agg::trans_affine const& tr,
double opacity,
T & image);

View file

@ -199,7 +199,7 @@ struct agg_renderer_process_visitor_l
if (image_transform) evaluate_transform(image_tr, feature_, common_.vars_, *image_transform, common_.scale_factor_);
mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr;
image_rgba8 image(bbox_image.width(), bbox_image.height());
render_pattern<buffer_type>(ras_, marker, image_tr, 1.0, image);
render_pattern<buffer_type>(marker, image_tr, 1.0, image);
render_by_pattern_type(image);
}

View file

@ -85,7 +85,7 @@ struct agg_renderer_process_visitor_p
if (image_transform) evaluate_transform(image_tr, feature_, common_.vars_, *image_transform, common_.scale_factor_);
mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr;
mapnik::image_rgba8 image(bbox_image.width(), bbox_image.height());
render_pattern<buffer_type>(*ras_ptr_, marker, image_tr, 1.0, image);
render_pattern<buffer_type>(marker, image_tr, 1.0, image);
render(image);
}

View file

@ -65,13 +65,12 @@ struct prepare_pattern_visitor
std::shared_ptr<cairo_pattern> operator() (mapnik::marker_svg const& marker)
{
double opacity = get<value_double, keys::opacity>(sym_, feature_, common_.vars_);
mapnik::rasterizer ras;
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
auto image_transform = get_optional<transform_type>(sym_, keys::image_transform);
if (image_transform) evaluate_transform(image_tr, feature_, common_.vars_, *image_transform, common_.scale_factor_);
mapnik::box2d<double> const& bbox_image = marker.get_data()->bounding_box() * image_tr;
mapnik::image_rgba8 image(bbox_image.width(), bbox_image.height());
render_pattern<image_rgba8>(ras, marker, image_tr, 1.0, image);
render_pattern<image_rgba8>(marker, image_tr, 1.0, image);
width_ = image.width();
height_ = image.height();
return std::make_shared<cairo_pattern>(image, opacity);

View file

@ -41,8 +41,7 @@
namespace mapnik {
template <>
void render_pattern<image_rgba8>(rasterizer & ras,
marker_svg const& marker,
void render_pattern<image_rgba8>(marker_svg const& marker,
agg::trans_affine const& tr,
double opacity,
image_rgba8 & image)
@ -68,6 +67,7 @@ void render_pattern<image_rgba8>(rasterizer & ras,
svg_attribute_type,
renderer_solid,
pixfmt> svg_renderer(svg_path, marker.get_data()->attributes());
rasterizer ras;
svg_renderer.render(ras, sl, renb, mtx, opacity, bbox);
}