Merge branch 'fix-group-symbolizer-crash' of https://github.com/lightmare/mapnik into lightmare-fix-group-symbolizer-crash
This commit is contained in:
commit
c29f944726
17 changed files with 73 additions and 89 deletions
|
@ -26,19 +26,14 @@
|
|||
#define MAPNIK_CAIRO_RENDER_VECTOR_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
|
||||
namespace agg { struct trans_affine; }
|
||||
#include <mapnik/marker.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
class cairo_context;
|
||||
struct pixel_position;
|
||||
template <typename T> class box2d;
|
||||
namespace svg { struct path_attributes; }
|
||||
|
||||
void render_vector_marker(cairo_context & context, svg::svg_path_adapter & svg_path,
|
||||
agg::pod_bvector<svg::path_attributes> const & attributes,
|
||||
void render_vector_marker(cairo_context & context, svg_path_adapter & svg_path,
|
||||
svg_attribute_type const& attributes,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
double opacity);
|
||||
|
||||
|
|
|
@ -27,25 +27,20 @@
|
|||
#include <mapnik/image.hpp>
|
||||
#include <mapnik/svg/svg_storage.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#include <mapnik/warning_ignore_agg.hpp>
|
||||
#include "agg_array.h"
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
// stl
|
||||
#include <deque>
|
||||
#include <memory>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
struct image_any;
|
||||
namespace svg { struct path_attributes; }
|
||||
|
||||
using svg::svg_path_adapter;
|
||||
|
||||
using svg_attribute_type = agg::pod_bvector<svg::path_attributes>;
|
||||
using svg_attribute_type = std::deque<svg::path_attributes>;
|
||||
using svg_storage_type = svg::svg_storage<svg::svg_path_storage, svg_attribute_type>;
|
||||
using svg_path_ptr = std::shared_ptr<svg_storage_type>;
|
||||
using image_ptr = std::shared_ptr<image_any>;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include <mapnik/geometry/centroid.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/marker.hpp> // for svg_storage_type
|
||||
#include <mapnik/marker.hpp> // svg_attribute_type, svg_storage_type
|
||||
#include <mapnik/markers_placement.hpp>
|
||||
#include <mapnik/attribute.hpp>
|
||||
#include <mapnik/geometry/box2d.hpp>
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#pragma GCC diagnostic pop
|
||||
|
||||
// stl
|
||||
#include <deque>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace mapnik {
|
||||
|
@ -61,16 +62,16 @@ public:
|
|||
void begin_path()
|
||||
{
|
||||
std::size_t idx = source_.start_new_path();
|
||||
attributes_.add(path_attributes(cur_attr(), safe_cast<unsigned>(idx)));
|
||||
attributes_.emplace_back(cur_attr(), safe_cast<unsigned>(idx));
|
||||
}
|
||||
|
||||
void end_path()
|
||||
{
|
||||
if(attributes_.size() == 0)
|
||||
if (attributes_.empty())
|
||||
{
|
||||
throw std::runtime_error("end_path : The path was not begun");
|
||||
}
|
||||
path_attributes& attr = attributes_[attributes_.size() - 1];
|
||||
path_attributes& attr = attributes_.back();
|
||||
unsigned idx = attr.index;
|
||||
attr = cur_attr();
|
||||
attr.index = idx;
|
||||
|
@ -183,17 +184,19 @@ public:
|
|||
|
||||
void push_attr()
|
||||
{
|
||||
attr_stack_.add(attr_stack_.size() ?
|
||||
attr_stack_[attr_stack_.size() - 1] :
|
||||
path_attributes());
|
||||
if (attr_stack_.empty())
|
||||
attr_stack_.push_back(path_attributes());
|
||||
else
|
||||
attr_stack_.push_back(attr_stack_.back());
|
||||
}
|
||||
|
||||
void pop_attr()
|
||||
{
|
||||
if(attr_stack_.size() == 0)
|
||||
if (attr_stack_.empty())
|
||||
{
|
||||
throw std::runtime_error("pop_attr : Attribute stack is empty");
|
||||
}
|
||||
attr_stack_.remove_last();
|
||||
attr_stack_.pop_back();
|
||||
}
|
||||
|
||||
// Attribute setting functions.
|
||||
|
@ -226,15 +229,18 @@ public:
|
|||
attr.stroke_color.opacity(a * s.opacity());
|
||||
attr.stroke_flag = true;
|
||||
}
|
||||
|
||||
void dash_array(dash_array && dash)
|
||||
{
|
||||
path_attributes& attr = cur_attr();
|
||||
attr.dash = std::move(dash);
|
||||
}
|
||||
|
||||
void dash_offset(double offset)
|
||||
{
|
||||
cur_attr().dash_offset = offset;
|
||||
}
|
||||
|
||||
void even_odd(bool flag)
|
||||
{
|
||||
cur_attr().even_odd_flag = flag;
|
||||
|
@ -264,6 +270,7 @@ public:
|
|||
{
|
||||
cur_attr().stroke_width = w;
|
||||
}
|
||||
|
||||
void fill_none()
|
||||
{
|
||||
cur_attr().fill_none = true;
|
||||
|
@ -352,11 +359,11 @@ public:
|
|||
|
||||
path_attributes& cur_attr()
|
||||
{
|
||||
if(attr_stack_.size() == 0)
|
||||
if (attr_stack_.empty())
|
||||
{
|
||||
throw std::runtime_error("cur_attr : Attribute stack is empty");
|
||||
}
|
||||
return attr_stack_[attr_stack_.size() - 1];
|
||||
return attr_stack_.back();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -370,7 +377,7 @@ private:
|
|||
};
|
||||
|
||||
|
||||
using svg_converter_type = svg_converter<svg_path_adapter,agg::pod_bvector<mapnik::svg::path_attributes> >;
|
||||
using svg_converter_type = svg_converter<svg_path_adapter, std::deque<path_attributes> >;
|
||||
|
||||
}}
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ private:
|
|||
};
|
||||
|
||||
template <typename VertexSource, typename AttributeSource, typename ScanlineRenderer, typename PixelFormat>
|
||||
class svg_renderer_agg : util::noncopyable
|
||||
class renderer_agg : util::noncopyable
|
||||
{
|
||||
public:
|
||||
using curved_type = agg::conv_curve<VertexSource>;
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
using vertex_source_type = VertexSource;
|
||||
using attribute_source_type = AttributeSource;
|
||||
|
||||
svg_renderer_agg(VertexSource & source, AttributeSource const& attributes)
|
||||
renderer_agg(VertexSource & source, AttributeSource const& attributes)
|
||||
: source_(source),
|
||||
curved_(source_),
|
||||
curved_dashed_(curved_),
|
||||
|
|
|
@ -416,14 +416,12 @@ struct agg_render_marker_visitor
|
|||
mtx *= agg::trans_affine_scaling(common_.scale_factor_);
|
||||
// render the marker at the center of the marker box
|
||||
mtx.translate(pos_.x, pos_.y);
|
||||
using namespace mapnik::svg;
|
||||
vertex_stl_adapter<svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type> svg_renderer(svg_path,
|
||||
marker.get_data()->attributes());
|
||||
svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type> svg_renderer(svg_path, marker.get_data()->attributes());
|
||||
|
||||
// https://github.com/mapnik/mapnik/issues/1316
|
||||
// https://github.com/mapnik/mapnik/issues/1866
|
||||
|
|
|
@ -75,10 +75,10 @@ struct thunk_renderer<image_rgba8> : render_thunk_list_dispatch
|
|||
using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
|
||||
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||
using svg_renderer_type = svg::svg_renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type>;
|
||||
using svg_renderer_type = svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type>;
|
||||
ras_ptr_->reset();
|
||||
buf_type render_buffer(buf_.bytes(), buf_.width(), buf_.height(), buf_.row_size());
|
||||
pixfmt_comp_type pixf(render_buffer);
|
||||
|
@ -90,7 +90,8 @@ struct thunk_renderer<image_rgba8> : render_thunk_list_dispatch
|
|||
|
||||
agg::trans_affine offset_tr = thunk.tr_;
|
||||
offset_tr.translate(offset_.x, offset_.y);
|
||||
render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(), offset_tr, thunk.opacity_, thunk.snap_to_pixels_);
|
||||
render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(),
|
||||
offset_tr, thunk.opacity_, thunk.snap_to_pixels_);
|
||||
}
|
||||
|
||||
virtual void operator()(raster_marker_render_thunk const& thunk)
|
||||
|
|
|
@ -108,7 +108,6 @@ void agg_renderer<T0,T1>::process(markers_symbolizer const& sym,
|
|||
feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
using namespace mapnik::svg;
|
||||
using color_type = agg::rgba8;
|
||||
using order_type = agg::order_rgba;
|
||||
using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender
|
||||
|
@ -116,11 +115,10 @@ void agg_renderer<T0,T1>::process(markers_symbolizer const& sym,
|
|||
using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
|
||||
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
|
||||
using renderer_type = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||
using svg_renderer_type = svg_renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type>;
|
||||
|
||||
using svg_renderer_type = svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type>;
|
||||
ras_ptr->reset();
|
||||
|
||||
double gamma = get<value_double, keys::gamma>(sym, feature, common_.vars_);
|
||||
|
|
|
@ -31,18 +31,16 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
void render_vector_marker(cairo_context & context, svg_path_adapter & svg_path,
|
||||
svg_attribute_type const& attributes,
|
||||
|
||||
void render_vector_marker(cairo_context & context, svg::svg_path_adapter & svg_path,
|
||||
agg::pod_bvector<svg::path_attributes> const & attrs,
|
||||
box2d<double> const& bbox, agg::trans_affine const& tr,
|
||||
double opacity)
|
||||
{
|
||||
using namespace mapnik::svg;
|
||||
agg::trans_affine transform;
|
||||
|
||||
for(unsigned i = 0; i < attrs.size(); ++i)
|
||||
for (auto const& attr : attributes)
|
||||
{
|
||||
mapnik::svg::path_attributes const& attr = attrs[i];
|
||||
if (!attr.visibility_flag)
|
||||
continue;
|
||||
cairo_save_restore guard(context);
|
||||
|
|
|
@ -268,11 +268,11 @@ struct cairo_render_marker_visitor
|
|||
marker_tr *= tr_;
|
||||
}
|
||||
marker_tr *= agg::trans_affine_scaling(common_.scale_factor_);
|
||||
agg::pod_bvector<svg::path_attributes> const & attrs = vmarker->attributes();
|
||||
auto const& attributes = vmarker->attributes();
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(vmarker->source());
|
||||
svg::svg_path_adapter svg_path(stl_storage);
|
||||
marker_tr.translate(pos_.x, pos_.y);
|
||||
render_vector_marker(context_, svg_path, attrs, bbox, marker_tr, opacity_);
|
||||
render_vector_marker(context_, svg_path, attributes, bbox, marker_tr, opacity_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,14 +172,12 @@ struct grid_render_marker_visitor
|
|||
mtx *= agg::trans_affine_scaling(common_.scale_factor_);
|
||||
// render the marker at the center of the marker box
|
||||
mtx.translate(pos_.x, pos_.y);
|
||||
using namespace mapnik::svg;
|
||||
vertex_stl_adapter<svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_renderer_agg<svg_path_adapter,
|
||||
agg::pod_bvector<path_attributes>,
|
||||
renderer_type,
|
||||
pixfmt_type> svg_renderer(svg_path,
|
||||
marker.get_data()->attributes());
|
||||
svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_type> svg_renderer(svg_path, marker.get_data()->attributes());
|
||||
|
||||
svg_renderer.render_id(*ras_ptr_, sl, renb, feature_.id(), mtx, opacity_, bbox);
|
||||
}
|
||||
|
|
|
@ -72,24 +72,20 @@ struct thunk_renderer : render_thunk_list_dispatch
|
|||
using buf_type = grid_rendering_buffer;
|
||||
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
|
||||
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
|
||||
|
||||
using namespace mapnik::svg;
|
||||
using svg_renderer_type = svg_renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_type>;
|
||||
|
||||
using svg_renderer_type = svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_type>;
|
||||
buf_type render_buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_);
|
||||
ras_.reset();
|
||||
pixfmt_type pixf(render_buf);
|
||||
grid_renderer_base_type renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
vertex_stl_adapter<svg_path_storage> stl_storage(thunk.src_->source());
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(thunk.src_->source());
|
||||
svg_path_adapter svg_path(stl_storage);
|
||||
svg_renderer_type svg_renderer(svg_path, thunk.attrs_);
|
||||
agg::trans_affine offset_tr = thunk.tr_;
|
||||
offset_tr.translate(offset_.x, offset_.y);
|
||||
//render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(), offset_tr, thunk.opacity_, thunk.snap_to_pixels_);
|
||||
agg::scanline_bin sl;
|
||||
svg_renderer.render_id(ras_, sl, renb, feature_.id(), offset_tr, thunk.opacity_, thunk.src_->bounding_box());
|
||||
pixmap_.add_feature(feature_);
|
||||
|
|
|
@ -141,12 +141,10 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
|
|||
using buf_type = grid_rendering_buffer;
|
||||
using pixfmt_type = typename grid_renderer_base_type::pixfmt_type;
|
||||
using renderer_type = agg::renderer_scanline_bin_solid<grid_renderer_base_type>;
|
||||
|
||||
using namespace mapnik::svg;
|
||||
using svg_renderer_type = svg_renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_type>;
|
||||
using svg_renderer_type = svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_type>;
|
||||
|
||||
buf_type render_buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_);
|
||||
ras_ptr->reset();
|
||||
|
|
|
@ -94,7 +94,7 @@ bool push_explicit_style(svg_attribute_type const& src,
|
|||
for(unsigned i = 0; i < src.size(); ++i)
|
||||
{
|
||||
dst.push_back(src[i]);
|
||||
mapnik::svg::path_attributes & attr = dst.last();
|
||||
mapnik::svg::path_attributes & attr = dst.back();
|
||||
if (!attr.visibility_flag)
|
||||
continue;
|
||||
success = true;
|
||||
|
|
|
@ -62,13 +62,12 @@ void render_pattern<image_rgba8>(rasterizer & ras,
|
|||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
||||
mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes>,
|
||||
renderer_solid,
|
||||
pixfmt > svg_renderer(svg_path,
|
||||
marker.get_data()->attributes());
|
||||
svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
svg_path_adapter svg_path(stl_storage);
|
||||
svg::renderer_agg<svg_path_adapter,
|
||||
svg_attribute_type,
|
||||
renderer_solid,
|
||||
pixfmt> svg_renderer(svg_path, marker.get_data()->attributes());
|
||||
|
||||
svg_renderer.render(ras, sl, renb, mtx, opacity, bbox);
|
||||
}
|
||||
|
|
|
@ -1410,8 +1410,8 @@ void parse_linear_gradient(svg_parser & parser, rapidxml::xml_node<char> const*
|
|||
parser.gradient_map_[id] = gr;
|
||||
}
|
||||
|
||||
svg_parser::svg_parser(svg_converter<svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes> > & path, bool strict)
|
||||
|
||||
svg_parser::svg_parser(svg_converter_type & path, bool strict)
|
||||
: path_(path),
|
||||
is_defs_(false),
|
||||
err_handler_(strict) {}
|
||||
|
|
|
@ -84,8 +84,9 @@ struct main_marker_visitor
|
|||
agg::trans_affine mtx = {};
|
||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(marker.get_data()->source());
|
||||
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
||||
mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes>,
|
||||
mapnik::svg::renderer_agg<
|
||||
mapnik::svg_path_adapter,
|
||||
mapnik::svg_attribute_type,
|
||||
renderer_solid,
|
||||
agg::pixfmt_rgba32_pre > svg_renderer_this(svg_path,
|
||||
marker.get_data()->attributes());
|
||||
|
|
Loading…
Reference in a new issue