clang-format
This commit is contained in:
parent
e790aa6c06
commit
7c24ff09ee
14 changed files with 165 additions and 147 deletions
|
@ -33,29 +33,35 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
namespace svg {
|
namespace svg {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <typename VertexSource>
|
template<typename VertexSource>
|
||||||
struct bounding_box
|
struct bounding_box
|
||||||
{
|
{
|
||||||
bounding_box(VertexSource& vs, double& x1, double& y1, double& x2, double& y2, bool& first)
|
bounding_box(VertexSource& vs, double& x1, double& y1, double& x2, double& y2, bool& first)
|
||||||
: vs_(vs), x1_(x1), y1_(y1), x2_(x2), y2_(y2), first_(first) {}
|
: vs_(vs)
|
||||||
|
, x1_(x1)
|
||||||
|
, y1_(y1)
|
||||||
|
, x2_(x2)
|
||||||
|
, y2_(y2)
|
||||||
|
, first_(first)
|
||||||
|
{}
|
||||||
|
|
||||||
void operator() (group const& g) const
|
void operator()(group const& g) const
|
||||||
{
|
{
|
||||||
for (auto const& elem : g.elements)
|
for (auto const& elem : g.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(bounding_box(vs_, x1_, y1_, x2_, y2_, first_), elem);
|
mapbox::util::apply_visitor(bounding_box(vs_, x1_, y1_, x2_, y2_, first_), elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator() (path_attributes const& attr) const
|
void operator()(path_attributes const& attr) const
|
||||||
{
|
{
|
||||||
vs_.rewind(attr.index);
|
vs_.rewind(attr.index);
|
||||||
vs_.transformer(const_cast<agg::trans_affine&>(attr.transform));
|
vs_.transformer(const_cast<agg::trans_affine&>(attr.transform));
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
double x;
|
double x;
|
||||||
double y;
|
double y;
|
||||||
while(!is_stop(cmd = vs_.vertex(&x, &y)))
|
while (!is_stop(cmd = vs_.vertex(&x, &y)))
|
||||||
{
|
{
|
||||||
if(is_vertex(cmd))
|
if (is_vertex(cmd))
|
||||||
{
|
{
|
||||||
if (first_)
|
if (first_)
|
||||||
{
|
{
|
||||||
|
@ -67,10 +73,14 @@ struct bounding_box
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (x < x1_) x1_ = x;
|
if (x < x1_)
|
||||||
if (y < y1_) y1_ = y;
|
x1_ = x;
|
||||||
if (x > x2_) x2_ = x;
|
if (y < y1_)
|
||||||
if (y > y2_) y2_ = y;
|
y1_ = y;
|
||||||
|
if (x > x2_)
|
||||||
|
x2_ = x;
|
||||||
|
if (y > y2_)
|
||||||
|
y2_ = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,9 +92,9 @@ struct bounding_box
|
||||||
double& y2_;
|
double& y2_;
|
||||||
bool& first_;
|
bool& first_;
|
||||||
};
|
};
|
||||||
} // detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename VertexSource>
|
template<typename VertexSource>
|
||||||
void bounding_box(VertexSource& vs, group const& g, double& x1, double& y1, double& x2, double& y2)
|
void bounding_box(VertexSource& vs, group const& g, double& x1, double& y1, double& x2, double& y2)
|
||||||
{
|
{
|
||||||
bool first = true;
|
bool first = true;
|
||||||
|
@ -98,7 +108,7 @@ void bounding_box(VertexSource& vs, group const& g, double& x1, double& y1, doub
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // svg
|
} // namespace svg
|
||||||
} // mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
#endif //MAPNIK_SVG_BOUNDING_BOX_HPP
|
#endif // MAPNIK_SVG_BOUNDING_BOX_HPP
|
||||||
|
|
|
@ -58,30 +58,27 @@ class svg_converter : util::noncopyable
|
||||||
public:
|
public:
|
||||||
|
|
||||||
svg_converter(VertexSource& source, group& svg_group)
|
svg_converter(VertexSource& source, group& svg_group)
|
||||||
: source_(source),
|
: source_(source)
|
||||||
svg_group_(svg_group),
|
, svg_group_(svg_group)
|
||||||
attr_stack_(),
|
, attr_stack_()
|
||||||
svg_width_(0.0),
|
, svg_width_(0.0)
|
||||||
svg_height_(0.0)
|
, svg_height_(0.0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void set_opacity(double opacity) { svg_group_.opacity = opacity; }
|
void set_opacity(double opacity) { svg_group_.opacity = opacity; }
|
||||||
|
|
||||||
void begin_group()
|
void begin_group()
|
||||||
{
|
{
|
||||||
current_group_->elements.emplace_back(group {cur_attr().opacity, {}, current_group_});
|
current_group_->elements.emplace_back(group{cur_attr().opacity, {}, current_group_});
|
||||||
current_group_ = ¤t_group_->elements.back().get<group>();
|
current_group_ = ¤t_group_->elements.back().get<group>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void end_group()
|
void end_group() { current_group_ = current_group_->parent; }
|
||||||
{
|
|
||||||
current_group_ = current_group_->parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
void begin_path()
|
void begin_path()
|
||||||
{
|
{
|
||||||
std::size_t idx = source_.start_new_path();
|
std::size_t idx = source_.start_new_path();
|
||||||
current_group_->elements.emplace_back(path_attributes {cur_attr(), safe_cast<unsigned>(idx)});
|
current_group_->elements.emplace_back(path_attributes{cur_attr(), safe_cast<unsigned>(idx)});
|
||||||
}
|
}
|
||||||
|
|
||||||
void end_path()
|
void end_path()
|
||||||
|
@ -90,11 +87,11 @@ class svg_converter : util::noncopyable
|
||||||
{
|
{
|
||||||
throw std::runtime_error("end_path : The path was not begun");
|
throw std::runtime_error("end_path : The path was not begun");
|
||||||
}
|
}
|
||||||
//auto& elem = current_group_->elements.back();
|
// auto& elem = current_group_->elements.back();
|
||||||
//auto& attr = elem.get<path_attributes>();
|
// auto& attr = elem.get<path_attributes>();
|
||||||
//unsigned index = attr.index;
|
// unsigned index = attr.index;
|
||||||
//attr = cur_attr();
|
// attr = cur_attr();
|
||||||
//attr.index = index;
|
// attr.index = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_to(double x, double y, bool rel = false) // M, m
|
void move_to(double x, double y, bool rel = false) // M, m
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#ifndef MAPNIK_SVG_GROUP_HPP
|
#ifndef MAPNIK_SVG_GROUP_HPP
|
||||||
#define MAPNIK_SVG_GROUP_HPP
|
#define MAPNIK_SVG_GROUP_HPP
|
||||||
|
|
||||||
|
|
||||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||||
#include <mapbox/variant.hpp>
|
#include <mapbox/variant.hpp>
|
||||||
|
@ -43,7 +42,7 @@ struct group
|
||||||
group* parent = nullptr;
|
group* parent = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // svg
|
} // namespace svg
|
||||||
} // mapnik
|
} // namespace mapnik
|
||||||
|
|
||||||
#endif //MAPNIK_SVG_GROUP_HPP
|
#endif // MAPNIK_SVG_GROUP_HPP
|
||||||
|
|
|
@ -154,8 +154,9 @@ class renderer_agg : util::noncopyable
|
||||||
Renderer ren_g(pixf);
|
Renderer ren_g(pixf);
|
||||||
for (auto const& elem : svg_group_.elements)
|
for (auto const& elem : svg_group_.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(group_renderer<Rasterizer, Scanline, Renderer>
|
mapbox::util::apply_visitor(
|
||||||
(*this, ras, sl, ren_g, mtx, symbol_bbox), elem);
|
group_renderer<Rasterizer, Scanline, Renderer>(*this, ras, sl, ren_g, mtx, symbol_bbox),
|
||||||
|
elem);
|
||||||
}
|
}
|
||||||
ren.blend_from(ren_g.ren(), 0, 0, 0, unsigned(adjusted_opacity * 255));
|
ren.blend_from(ren_g.ren(), 0, 0, 0, unsigned(adjusted_opacity * 255));
|
||||||
}
|
}
|
||||||
|
@ -163,8 +164,9 @@ class renderer_agg : util::noncopyable
|
||||||
{
|
{
|
||||||
for (auto const& elem : svg_group_.elements)
|
for (auto const& elem : svg_group_.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(group_renderer<Rasterizer, Scanline, Renderer>
|
mapbox::util::apply_visitor(
|
||||||
(*this, ras, sl, ren, mtx, symbol_bbox), elem);
|
group_renderer<Rasterizer, Scanline, Renderer>(*this, ras, sl, ren, mtx, symbol_bbox),
|
||||||
|
elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,15 +175,17 @@ class renderer_agg : util::noncopyable
|
||||||
struct group_renderer
|
struct group_renderer
|
||||||
{
|
{
|
||||||
group_renderer(renderer_agg& renderer,
|
group_renderer(renderer_agg& renderer,
|
||||||
Rasterizer & ras, Scanline& sl, Renderer& ren,
|
Rasterizer& ras,
|
||||||
|
Scanline& sl,
|
||||||
|
Renderer& ren,
|
||||||
agg::trans_affine const& mtx,
|
agg::trans_affine const& mtx,
|
||||||
box2d<double> const& symbol_bbox)
|
box2d<double> const& symbol_bbox)
|
||||||
: renderer_(renderer),
|
: renderer_(renderer)
|
||||||
ras_(ras),
|
, ras_(ras)
|
||||||
sl_(sl),
|
, sl_(sl)
|
||||||
ren_(ren),
|
, ren_(ren)
|
||||||
mtx_(mtx),
|
, mtx_(mtx)
|
||||||
symbol_bbox_(symbol_bbox)
|
, symbol_bbox_(symbol_bbox)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void render_gradient(Rasterizer& ras,
|
void render_gradient(Rasterizer& ras,
|
||||||
|
@ -248,7 +252,7 @@ class renderer_agg : util::noncopyable
|
||||||
agg::span_gradient<agg::rgba8, interpolator_type, gradient_adaptor_type, color_func_type>;
|
agg::span_gradient<agg::rgba8, interpolator_type, gradient_adaptor_type, color_func_type>;
|
||||||
|
|
||||||
// the agg radial gradient assumes it is centred on 0
|
// the agg radial gradient assumes it is centred on 0
|
||||||
transform.translate( -x2, -y2);
|
transform.translate(-x2, -y2);
|
||||||
|
|
||||||
// scale everything up since agg turns things into integers a bit too soon
|
// scale everything up since agg turns things into integers a bit too soon
|
||||||
int scaleup = 255;
|
int scaleup = 255;
|
||||||
|
@ -291,7 +295,7 @@ class renderer_agg : util::noncopyable
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator() (group const& g) const
|
void operator()(group const& g) const
|
||||||
{
|
{
|
||||||
double opacity = g.opacity;
|
double opacity = g.opacity;
|
||||||
if (opacity < 1.0)
|
if (opacity < 1.0)
|
||||||
|
@ -302,8 +306,7 @@ class renderer_agg : util::noncopyable
|
||||||
Renderer ren(pixf);
|
Renderer ren(pixf);
|
||||||
for (auto const& elem : g.elements)
|
for (auto const& elem : g.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(
|
mapbox::util::apply_visitor(group_renderer(renderer_, ras_, sl_, ren, mtx_, symbol_bbox_), elem);
|
||||||
group_renderer(renderer_, ras_, sl_, ren, mtx_, symbol_bbox_), elem);
|
|
||||||
}
|
}
|
||||||
ren_.blend_from(ren.ren(), 0, 0, 0, unsigned(opacity * 255));
|
ren_.blend_from(ren.ren(), 0, 0, 0, unsigned(opacity * 255));
|
||||||
}
|
}
|
||||||
|
@ -311,13 +314,12 @@ class renderer_agg : util::noncopyable
|
||||||
{
|
{
|
||||||
for (auto const& elem : g.elements)
|
for (auto const& elem : g.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(
|
mapbox::util::apply_visitor(group_renderer(renderer_, ras_, sl_, ren_, mtx_, symbol_bbox_), elem);
|
||||||
group_renderer(renderer_, ras_, sl_, ren_, mtx_, symbol_bbox_), elem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator() (path_attributes const& attr) const
|
void operator()(path_attributes const& attr) const
|
||||||
{
|
{
|
||||||
using namespace agg;
|
using namespace agg;
|
||||||
trans_affine transform;
|
trans_affine transform;
|
||||||
|
@ -328,7 +330,8 @@ class renderer_agg : util::noncopyable
|
||||||
curved_trans_contour_type curved_trans_contour(curved_trans);
|
curved_trans_contour_type curved_trans_contour(curved_trans);
|
||||||
curved_trans_contour.auto_detect_orientation(true);
|
curved_trans_contour.auto_detect_orientation(true);
|
||||||
|
|
||||||
if (!attr.visibility_flag) return;
|
if (!attr.visibility_flag)
|
||||||
|
return;
|
||||||
|
|
||||||
transform = attr.transform;
|
transform = attr.transform;
|
||||||
|
|
||||||
|
@ -484,26 +487,27 @@ class renderer_agg : util::noncopyable
|
||||||
struct grid_renderer
|
struct grid_renderer
|
||||||
{
|
{
|
||||||
grid_renderer(renderer_agg& renderer,
|
grid_renderer(renderer_agg& renderer,
|
||||||
Rasterizer& ras, Scanline& sl, Renderer& ren,
|
Rasterizer& ras,
|
||||||
|
Scanline& sl,
|
||||||
|
Renderer& ren,
|
||||||
agg::trans_affine const& mtx,
|
agg::trans_affine const& mtx,
|
||||||
mapnik::value_integer const& feature_id)
|
mapnik::value_integer const& feature_id)
|
||||||
: renderer_(renderer),
|
: renderer_(renderer)
|
||||||
ras_(ras),
|
, ras_(ras)
|
||||||
sl_(sl),
|
, sl_(sl)
|
||||||
ren_(ren),
|
, ren_(ren)
|
||||||
mtx_(mtx),
|
, mtx_(mtx)
|
||||||
feature_id_(feature_id)
|
, feature_id_(feature_id)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void operator() (group const& g) const
|
void operator()(group const& g) const
|
||||||
{
|
{
|
||||||
for (auto const& elem : g.elements)
|
for (auto const& elem : g.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(
|
mapbox::util::apply_visitor(grid_renderer(renderer_, ras_, sl_, ren_, mtx_, feature_id_), elem);
|
||||||
grid_renderer(renderer_, ras_, sl_, ren_, mtx_, feature_id_), elem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void operator() (path_attributes const& attr) const
|
void operator()(path_attributes const& attr) const
|
||||||
{
|
{
|
||||||
using namespace agg;
|
using namespace agg;
|
||||||
|
|
||||||
|
@ -594,8 +598,9 @@ class renderer_agg : util::noncopyable
|
||||||
{
|
{
|
||||||
for (auto const& elem : svg_group_.elements)
|
for (auto const& elem : svg_group_.elements)
|
||||||
{
|
{
|
||||||
mapbox::util::apply_visitor(grid_renderer<Rasterizer, Scanline, Renderer>
|
mapbox::util::apply_visitor(
|
||||||
(*this, ras, sl, ren, mtx, feature_id), elem);
|
grid_renderer<Rasterizer, Scanline, Renderer>(*this, ras, sl, ren, mtx, feature_id),
|
||||||
|
elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,7 +40,7 @@ class svg_storage : util::noncopyable
|
||||||
, svg_height_(0)
|
, svg_height_(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
VertexSource& source() { return source_;}
|
VertexSource& source() { return source_; }
|
||||||
|
|
||||||
svg::group& svg_group() { return svg_group_; }
|
svg::group& svg_group() { return svg_group_; }
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,8 @@ struct agg_markers_renderer_context : markers_renderer_context
|
||||||
params.snap_to_pixels);
|
params.snap_to_pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void render_marker(image_rgba8 const& src, markers_dispatch_params const& params, agg::trans_affine const& marker_tr)
|
virtual void
|
||||||
|
render_marker(image_rgba8 const& src, markers_dispatch_params const& params, agg::trans_affine const& marker_tr)
|
||||||
{
|
{
|
||||||
// In the long term this should be a visitor pattern based on the type of
|
// In the long term this should be a visitor pattern based on the type of
|
||||||
// render src provided that converts the destination pixel type required.
|
// render src provided that converts the destination pixel type required.
|
||||||
|
|
|
@ -88,28 +88,28 @@ struct push_explicit_style
|
||||||
boost::optional<color> const& stroke_color,
|
boost::optional<color> const& stroke_color,
|
||||||
boost::optional<double> const& stroke_width,
|
boost::optional<double> const& stroke_width,
|
||||||
boost::optional<double> const& stroke_opacity)
|
boost::optional<double> const& stroke_opacity)
|
||||||
: current_group_(&dst),
|
: current_group_(&dst)
|
||||||
fill_color_(fill_color),
|
, fill_color_(fill_color)
|
||||||
fill_opacity_(fill_opacity),
|
, fill_opacity_(fill_opacity)
|
||||||
stroke_color_(stroke_color),
|
, stroke_color_(stroke_color)
|
||||||
stroke_width_(stroke_width),
|
, stroke_width_(stroke_width)
|
||||||
stroke_opacity_(stroke_opacity)
|
, stroke_opacity_(stroke_opacity)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool operator() (svg::group const& g) const
|
bool operator()(svg::group const& g) const
|
||||||
{
|
{
|
||||||
current_group_->elements.emplace_back(svg::group{g.opacity, {}, current_group_});
|
current_group_->elements.emplace_back(svg::group{g.opacity, {}, current_group_});
|
||||||
current_group_ = ¤t_group_->elements.back().get<svg::group>();
|
current_group_ = ¤t_group_->elements.back().get<svg::group>();
|
||||||
bool success = false;
|
bool success = false;
|
||||||
for (auto const& elem : g.elements)
|
for (auto const& elem : g.elements)
|
||||||
{
|
{
|
||||||
if (mapbox::util::apply_visitor
|
if (mapbox::util::apply_visitor(push_explicit_style(*current_group_,
|
||||||
(push_explicit_style(*current_group_,
|
|
||||||
fill_color_,
|
fill_color_,
|
||||||
fill_opacity_,
|
fill_opacity_,
|
||||||
stroke_color_,
|
stroke_color_,
|
||||||
stroke_width_,
|
stroke_width_,
|
||||||
stroke_opacity_), elem))
|
stroke_opacity_),
|
||||||
|
elem))
|
||||||
{
|
{
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ struct push_explicit_style
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator() (svg::path_attributes const& attr) const
|
bool operator()(svg::path_attributes const& attr) const
|
||||||
{
|
{
|
||||||
svg::path_attributes new_attr{attr, attr.index};
|
svg::path_attributes new_attr{attr, attr.index};
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ struct push_explicit_style
|
||||||
boost::optional<double> const& stroke_opacity_;
|
boost::optional<double> const& stroke_opacity_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // detail
|
} // namespace detail
|
||||||
|
|
||||||
bool push_explicit_style(svg::group const& src,
|
bool push_explicit_style(svg::group const& src,
|
||||||
svg::group& dst,
|
svg::group& dst,
|
||||||
|
@ -194,10 +194,13 @@ bool push_explicit_style(svg::group const& src,
|
||||||
{
|
{
|
||||||
for (auto const& elem : src.elements)
|
for (auto const& elem : src.elements)
|
||||||
{
|
{
|
||||||
if (mapbox::util::apply_visitor
|
if (mapbox::util::apply_visitor(detail::push_explicit_style(dst,
|
||||||
(detail::push_explicit_style
|
fill_color,
|
||||||
(dst, fill_color, fill_opacity,
|
fill_opacity,
|
||||||
stroke_color, stroke_width, stroke_opacity), elem))
|
stroke_color,
|
||||||
|
stroke_width,
|
||||||
|
stroke_opacity),
|
||||||
|
elem))
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,7 @@ struct render_marker_symbolizer_visitor
|
||||||
, renderer_context_(renderer_context)
|
, renderer_context_(renderer_context)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
svg::group const& get_marker_attributes(svg_path_ptr const& stock_marker,
|
svg::group const& get_marker_attributes(svg_path_ptr const& stock_marker, svg::group& custom_group_attrs) const
|
||||||
svg::group& custom_group_attrs) const
|
|
||||||
{
|
{
|
||||||
auto const& stock_group_attrs = stock_marker->svg_group();
|
auto const& stock_group_attrs = stock_marker->svg_group();
|
||||||
if (push_explicit_style(stock_group_attrs, custom_group_attrs, sym_, feature_, common_.vars_))
|
if (push_explicit_style(stock_group_attrs, custom_group_attrs, sym_, feature_, common_.vars_))
|
||||||
|
@ -130,7 +129,7 @@ struct render_marker_symbolizer_visitor
|
||||||
svg_path_ptr marker_ptr = stock_vector_marker;
|
svg_path_ptr marker_ptr = stock_vector_marker;
|
||||||
bool is_ellipse = false;
|
bool is_ellipse = false;
|
||||||
|
|
||||||
//svg_attribute_type s_attributes;
|
// svg_attribute_type s_attributes;
|
||||||
svg::group svg_group_attrs;
|
svg::group svg_group_attrs;
|
||||||
auto const& svg_group_attrs_updated = get_marker_attributes(stock_vector_marker, svg_group_attrs);
|
auto const& svg_group_attrs_updated = get_marker_attributes(stock_vector_marker, svg_group_attrs);
|
||||||
|
|
||||||
|
|
|
@ -548,9 +548,11 @@ void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
||||||
if (parser.css_style_)
|
if (parser.css_style_)
|
||||||
process_css(parser, node);
|
process_css(parser, node);
|
||||||
parse_attr(parser, node);
|
parse_attr(parser, node);
|
||||||
if (parser.path_.cur_attr().opacity < 1.0) parser.path_.begin_group();
|
if (parser.path_.cur_attr().opacity < 1.0)
|
||||||
|
parser.path_.begin_group();
|
||||||
parse_use(parser, node);
|
parse_use(parser, node);
|
||||||
if (parser.path_.cur_attr().opacity < 1.0) parser.path_.end_group();
|
if (parser.path_.cur_attr().opacity < 1.0)
|
||||||
|
parser.path_.end_group();
|
||||||
parser.path_.pop_attr();
|
parser.path_.pop_attr();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -561,9 +563,11 @@ void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
||||||
parse_attr(parser, node);
|
parse_attr(parser, node);
|
||||||
if (parser.path_.display())
|
if (parser.path_.display())
|
||||||
{
|
{
|
||||||
if (parser.path_.cur_attr().opacity < 1.0) parser.path_.begin_group();
|
if (parser.path_.cur_attr().opacity < 1.0)
|
||||||
|
parser.path_.begin_group();
|
||||||
parse_element(parser, node->name(), node);
|
parse_element(parser, node->name(), node);
|
||||||
if (parser.path_.cur_attr().opacity < 1.0) parser.path_.end_group();
|
if (parser.path_.cur_attr().opacity < 1.0)
|
||||||
|
parser.path_.end_group();
|
||||||
}
|
}
|
||||||
parser.path_.pop_attr();
|
parser.path_.pop_attr();
|
||||||
}
|
}
|
||||||
|
@ -624,9 +628,9 @@ void end_element(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
||||||
}
|
}
|
||||||
else if (name == "svg"_case)
|
else if (name == "svg"_case)
|
||||||
{
|
{
|
||||||
//if (node->first_node() != nullptr)
|
// if (node->first_node() != nullptr)
|
||||||
//{
|
//{
|
||||||
//parser.path_.pop_attr();
|
// parser.path_.pop_attr();
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
else if (name == "defs"_case)
|
else if (name == "defs"_case)
|
||||||
|
@ -676,7 +680,7 @@ void parse_element(svg_parser& parser, char const* name, rapidxml::xml_node<char
|
||||||
parse_ellipse(parser, node);
|
parse_ellipse(parser, node);
|
||||||
break;
|
break;
|
||||||
case "svg"_case:
|
case "svg"_case:
|
||||||
//parser.path_.push_attr();
|
// parser.path_.push_attr();
|
||||||
parse_dimensions(parser, node);
|
parse_dimensions(parser, node);
|
||||||
parse_attr(parser, node);
|
parse_attr(parser, node);
|
||||||
parser.path_.set_opacity(parser.path_.cur_attr().opacity);
|
parser.path_.set_opacity(parser.path_.cur_attr().opacity);
|
||||||
|
|
|
@ -265,7 +265,7 @@ TEST_CASE("SVG parser")
|
||||||
agg::line_cap_e expected_cap(agg::square_cap);
|
agg::line_cap_e expected_cap(agg::square_cap);
|
||||||
REQUIRE(group_attrs.elements.size() == 1);
|
REQUIRE(group_attrs.elements.size() == 1);
|
||||||
// FIXME
|
// FIXME
|
||||||
//REQUIRE(attrs[0].line_cap == expected_cap);
|
// REQUIRE(attrs[0].line_cap == expected_cap);
|
||||||
|
|
||||||
double x, y;
|
double x, y;
|
||||||
unsigned cmd;
|
unsigned cmd;
|
||||||
|
@ -432,7 +432,7 @@ TEST_CASE("SVG parser")
|
||||||
agg::line_join_e expected_join(agg::bevel_join);
|
agg::line_join_e expected_join(agg::bevel_join);
|
||||||
REQUIRE(group_attrs.elements.size() == 1);
|
REQUIRE(group_attrs.elements.size() == 1);
|
||||||
// FIXME
|
// FIXME
|
||||||
//REQUIRE(attrs[0].line_join == expected_join);
|
// REQUIRE(attrs[0].line_join == expected_join);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("SVG <line>")
|
SECTION("SVG <line>")
|
||||||
|
@ -443,8 +443,9 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(0.3543307086614174,0.3543307086614174,
|
REQUIRE(
|
||||||
424.8425196850394059,141.3779527559055396));
|
bbox ==
|
||||||
|
mapnik::box2d<double>(0.3543307086614174, 0.3543307086614174, 424.8425196850394059, 141.3779527559055396));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||||
|
@ -478,7 +479,7 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(1.0,1.0,1199.0,399.0));
|
REQUIRE(bbox == mapnik::box2d<double>(1.0, 1.0, 1199.0, 399.0));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||||
|
@ -516,7 +517,7 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(1.0,1.0,1199.0,399.0));
|
REQUIRE(bbox == mapnik::box2d<double>(1.0, 1.0, 1199.0, 399.0));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||||
|
@ -553,7 +554,7 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(1.0,1.0,799.0,599.0));
|
REQUIRE(bbox == mapnik::box2d<double>(1.0, 1.0, 799.0, 599.0));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||||
|
@ -649,7 +650,7 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(1.0,1.0,699.0,199.0));
|
REQUIRE(bbox == mapnik::box2d<double>(1.0, 1.0, 699.0, 199.0));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||||
|
@ -657,7 +658,7 @@ TEST_CASE("SVG parser")
|
||||||
auto const& group_attrs = storage->svg_group();
|
auto const& group_attrs = storage->svg_group();
|
||||||
REQUIRE(group_attrs.elements.size() == 3);
|
REQUIRE(group_attrs.elements.size() == 3);
|
||||||
// FIXME
|
// FIXME
|
||||||
//REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
// REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||||
|
|
||||||
mapnik::svg::svg_path_adapter path(stl_storage);
|
mapnik::svg::svg_path_adapter path(stl_storage);
|
||||||
double x, y;
|
double x, y;
|
||||||
|
@ -699,18 +700,18 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(1.0,1.0,799.0,599.0));
|
REQUIRE(bbox == mapnik::box2d<double>(1.0, 1.0, 799.0, 599.0));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
|
|
||||||
auto const& group_attrs = storage->svg_group();
|
auto const& group_attrs = storage->svg_group();
|
||||||
// FIXME
|
// FIXME
|
||||||
//REQUIRE(attrs.size() == 3);
|
// REQUIRE(attrs.size() == 3);
|
||||||
//REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
// REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||||
//REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
// REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||||
agg::trans_affine transform;
|
agg::trans_affine transform;
|
||||||
transform *= agg::trans_affine_translation(240, 155);
|
transform *= agg::trans_affine_translation(240, 155);
|
||||||
//REQUIRE(attrs[1].fill_gradient.get_transform() == transform);
|
// REQUIRE(attrs[1].fill_gradient.get_transform() == transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("SVG <gradient> with xlink:href")
|
SECTION("SVG <gradient> with xlink:href")
|
||||||
|
@ -721,16 +722,16 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(20,20,460,230));
|
REQUIRE(bbox == mapnik::box2d<double>(20, 20, 460, 230));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
|
|
||||||
auto const& group_attrs = storage->svg_group();
|
auto const& group_attrs = storage->svg_group();
|
||||||
// FIXME
|
// FIXME
|
||||||
//REQUIRE(attrs.elements.size() == 2);
|
// REQUIRE(attrs.elements.size() == 2);
|
||||||
//REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::LINEAR);
|
// REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::LINEAR);
|
||||||
//REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::LINEAR);
|
// REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::LINEAR);
|
||||||
//REQUIRE(attrs[1].fill_gradient.has_stop());
|
// REQUIRE(attrs[1].fill_gradient.has_stop());
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("SVG <gradient> with radial percents")
|
SECTION("SVG <gradient> with radial percents")
|
||||||
|
@ -741,22 +742,22 @@ TEST_CASE("SVG parser")
|
||||||
REQUIRE(marker->is<mapnik::marker_svg>());
|
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||||
auto bbox = svg.bounding_box();
|
auto bbox = svg.bounding_box();
|
||||||
REQUIRE(bbox == mapnik::box2d<double>(0,0,200,200));
|
REQUIRE(bbox == mapnik::box2d<double>(0, 0, 200, 200));
|
||||||
auto storage = svg.get_data();
|
auto storage = svg.get_data();
|
||||||
REQUIRE(storage);
|
REQUIRE(storage);
|
||||||
|
|
||||||
double x1, x2, y1, y2, r;
|
double x1, x2, y1, y2, r;
|
||||||
// FIXME
|
// FIXME
|
||||||
//auto const& attrs = storage->attributes();
|
// auto const& attrs = storage->attributes();
|
||||||
//REQUIRE(attrs.size() == 1);
|
// REQUIRE(attrs.size() == 1);
|
||||||
//REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
// REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||||
//REQUIRE(attrs[0].fill_gradient.has_stop());
|
// REQUIRE(attrs[0].fill_gradient.has_stop());
|
||||||
//attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r);
|
// attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r);
|
||||||
//REQUIRE(x1 == 0);
|
// REQUIRE(x1 == 0);
|
||||||
//REQUIRE(y1 == 0.25);
|
// REQUIRE(y1 == 0.25);
|
||||||
//REQUIRE(x2 == 0.10);
|
// REQUIRE(x2 == 0.10);
|
||||||
//REQUIRE(y2 == 0.10);
|
// REQUIRE(y2 == 0.10);
|
||||||
//REQUIRE(r == 0.75);
|
// REQUIRE(r == 0.75);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("SVG <clipPath>")
|
SECTION("SVG <clipPath>")
|
||||||
|
|
|
@ -56,7 +56,6 @@ mapnik::image_rgba8 render_svg(std::string const& filename, double scale_factor)
|
||||||
using renderer_base = agg::renderer_base<pixfmt>;
|
using renderer_base = agg::renderer_base<pixfmt>;
|
||||||
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||||
|
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras_ptr;
|
agg::rasterizer_scanline_aa<> ras_ptr;
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
|
|
||||||
|
@ -78,9 +77,9 @@ mapnik::image_rgba8 render_svg(std::string const& filename, double scale_factor)
|
||||||
|
|
||||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(svg.get_data()->source());
|
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(svg.get_data()->source());
|
||||||
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
||||||
mapnik::svg::
|
mapnik::svg::renderer_agg<mapnik::svg_path_adapter, mapnik::svg_attribute_type, renderer_solid, pixfmt> renderer(
|
||||||
renderer_agg<mapnik::svg_path_adapter, mapnik::svg_attribute_type, renderer_solid, pixfmt>
|
svg_path,
|
||||||
renderer(svg_path, svg.get_data()->svg_group());
|
svg.get_data()->svg_group());
|
||||||
double opacity = 1.0;
|
double opacity = 1.0;
|
||||||
renderer.render(ras_ptr, sl, renb, mtx, opacity, {0, 0, svg_width, svg_height});
|
renderer.render(ras_ptr, sl, renb, mtx, opacity, {0, 0, svg_width, svg_height});
|
||||||
return im;
|
return im;
|
||||||
|
|
|
@ -56,11 +56,11 @@ MAPNIK_DISABLE_WARNING_POP
|
||||||
struct main_marker_visitor
|
struct main_marker_visitor
|
||||||
{
|
{
|
||||||
main_marker_visitor(std::string const& svg_name, double scale_factor, double opacity, bool verbose, bool auto_open)
|
main_marker_visitor(std::string const& svg_name, double scale_factor, double opacity, bool verbose, bool auto_open)
|
||||||
: svg_name_(svg_name),
|
: svg_name_(svg_name)
|
||||||
scale_factor_(scale_factor),
|
, scale_factor_(scale_factor)
|
||||||
opacity_(opacity),
|
, opacity_(opacity)
|
||||||
verbose_(verbose),
|
, verbose_(verbose)
|
||||||
auto_open_(auto_open)
|
, auto_open_(auto_open)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int operator()(mapnik::marker_svg const& marker) const
|
int operator()(mapnik::marker_svg const& marker) const
|
||||||
|
@ -68,7 +68,7 @@ struct main_marker_visitor
|
||||||
#if 1
|
#if 1
|
||||||
using color_type = agg::rgba8;
|
using color_type = agg::rgba8;
|
||||||
using order_type = agg::order_rgba;
|
using order_type = agg::order_rgba;
|
||||||
using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; //comp blender
|
using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender
|
||||||
using buf_type = agg::rendering_buffer;
|
using buf_type = agg::rendering_buffer;
|
||||||
using pixfmt = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
|
using pixfmt = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
|
||||||
using renderer_base = agg::renderer_base<pixfmt>;
|
using renderer_base = agg::renderer_base<pixfmt>;
|
||||||
|
|
Loading…
Reference in a new issue