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 svg {
|
||||
namespace detail {
|
||||
template <typename VertexSource>
|
||||
template<typename VertexSource>
|
||||
struct bounding_box
|
||||
{
|
||||
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)
|
||||
{
|
||||
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_.transformer(const_cast<agg::trans_affine&>(attr.transform));
|
||||
unsigned cmd;
|
||||
double x;
|
||||
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_)
|
||||
{
|
||||
|
@ -67,10 +73,14 @@ struct bounding_box
|
|||
}
|
||||
else
|
||||
{
|
||||
if (x < x1_) x1_ = x;
|
||||
if (y < y1_) y1_ = y;
|
||||
if (x > x2_) x2_ = x;
|
||||
if (y > y2_) y2_ = y;
|
||||
if (x < x1_)
|
||||
x1_ = x;
|
||||
if (y < y1_)
|
||||
y1_ = y;
|
||||
if (x > x2_)
|
||||
x2_ = x;
|
||||
if (y > y2_)
|
||||
y2_ = y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +92,9 @@ struct bounding_box
|
|||
double& y2_;
|
||||
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)
|
||||
{
|
||||
bool first = true;
|
||||
|
@ -98,7 +108,7 @@ void bounding_box(VertexSource& vs, group const& g, double& x1, double& y1, doub
|
|||
}
|
||||
}
|
||||
|
||||
} // svg
|
||||
} // mapnik
|
||||
} // namespace svg
|
||||
} // namespace mapnik
|
||||
|
||||
#endif //MAPNIK_SVG_BOUNDING_BOX_HPP
|
||||
#endif // MAPNIK_SVG_BOUNDING_BOX_HPP
|
||||
|
|
|
@ -58,30 +58,27 @@ class svg_converter : util::noncopyable
|
|||
public:
|
||||
|
||||
svg_converter(VertexSource& source, group& svg_group)
|
||||
: source_(source),
|
||||
svg_group_(svg_group),
|
||||
attr_stack_(),
|
||||
svg_width_(0.0),
|
||||
svg_height_(0.0)
|
||||
: source_(source)
|
||||
, svg_group_(svg_group)
|
||||
, attr_stack_()
|
||||
, svg_width_(0.0)
|
||||
, svg_height_(0.0)
|
||||
{}
|
||||
|
||||
void set_opacity(double opacity) { svg_group_.opacity = opacity; }
|
||||
|
||||
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>();
|
||||
}
|
||||
|
||||
void end_group()
|
||||
{
|
||||
current_group_ = current_group_->parent;
|
||||
}
|
||||
void end_group() { current_group_ = current_group_->parent; }
|
||||
|
||||
void begin_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()
|
||||
|
@ -90,11 +87,11 @@ class svg_converter : util::noncopyable
|
|||
{
|
||||
throw std::runtime_error("end_path : The path was not begun");
|
||||
}
|
||||
//auto& elem = current_group_->elements.back();
|
||||
//auto& attr = elem.get<path_attributes>();
|
||||
//unsigned index = attr.index;
|
||||
//attr = cur_attr();
|
||||
//attr.index = index;
|
||||
// auto& elem = current_group_->elements.back();
|
||||
// auto& attr = elem.get<path_attributes>();
|
||||
// unsigned index = attr.index;
|
||||
// attr = cur_attr();
|
||||
// attr.index = index;
|
||||
}
|
||||
|
||||
void move_to(double x, double y, bool rel = false) // M, m
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#ifndef MAPNIK_SVG_GROUP_HPP
|
||||
#define MAPNIK_SVG_GROUP_HPP
|
||||
|
||||
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapbox/variant.hpp>
|
||||
|
@ -43,7 +42,7 @@ struct group
|
|||
group* parent = nullptr;
|
||||
};
|
||||
|
||||
} // svg
|
||||
} // mapnik
|
||||
} // namespace svg
|
||||
} // 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);
|
||||
for (auto const& elem : svg_group_.elements)
|
||||
{
|
||||
mapbox::util::apply_visitor(group_renderer<Rasterizer, Scanline, Renderer>
|
||||
(*this, ras, sl, ren_g, mtx, symbol_bbox), elem);
|
||||
mapbox::util::apply_visitor(
|
||||
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));
|
||||
}
|
||||
|
@ -163,8 +164,9 @@ class renderer_agg : util::noncopyable
|
|||
{
|
||||
for (auto const& elem : svg_group_.elements)
|
||||
{
|
||||
mapbox::util::apply_visitor(group_renderer<Rasterizer, Scanline, Renderer>
|
||||
(*this, ras, sl, ren, mtx, symbol_bbox), elem);
|
||||
mapbox::util::apply_visitor(
|
||||
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
|
||||
{
|
||||
group_renderer(renderer_agg& renderer,
|
||||
Rasterizer & ras, Scanline& sl, Renderer& ren,
|
||||
Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
Renderer& ren,
|
||||
agg::trans_affine const& mtx,
|
||||
box2d<double> const& symbol_bbox)
|
||||
: renderer_(renderer),
|
||||
ras_(ras),
|
||||
sl_(sl),
|
||||
ren_(ren),
|
||||
mtx_(mtx),
|
||||
symbol_bbox_(symbol_bbox)
|
||||
: renderer_(renderer)
|
||||
, ras_(ras)
|
||||
, sl_(sl)
|
||||
, ren_(ren)
|
||||
, mtx_(mtx)
|
||||
, symbol_bbox_(symbol_bbox)
|
||||
{}
|
||||
|
||||
void render_gradient(Rasterizer& ras,
|
||||
|
@ -245,10 +249,10 @@ class renderer_agg : util::noncopyable
|
|||
{
|
||||
using gradient_adaptor_type = agg::gradient_radial_focus;
|
||||
using span_gradient_type =
|
||||
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
|
||||
transform.translate( -x2, -y2);
|
||||
transform.translate(-x2, -y2);
|
||||
|
||||
// scale everything up since agg turns things into integers a bit too soon
|
||||
int scaleup = 255;
|
||||
|
@ -271,7 +275,7 @@ class renderer_agg : util::noncopyable
|
|||
{
|
||||
using gradient_adaptor_type = linear_gradient_from_segment;
|
||||
using span_gradient_type =
|
||||
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>;
|
||||
// scale everything up since agg turns things into integers a bit too soon
|
||||
int scaleup = 255;
|
||||
x1 *= scaleup;
|
||||
|
@ -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;
|
||||
if (opacity < 1.0)
|
||||
|
@ -302,8 +306,7 @@ class renderer_agg : util::noncopyable
|
|||
Renderer ren(pixf);
|
||||
for (auto const& elem : g.elements)
|
||||
{
|
||||
mapbox::util::apply_visitor(
|
||||
group_renderer(renderer_, ras_, sl_, ren, mtx_, symbol_bbox_), elem);
|
||||
mapbox::util::apply_visitor(group_renderer(renderer_, ras_, sl_, ren, mtx_, symbol_bbox_), elem);
|
||||
}
|
||||
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)
|
||||
{
|
||||
mapbox::util::apply_visitor(
|
||||
group_renderer(renderer_, ras_, sl_, ren_, mtx_, symbol_bbox_), elem);
|
||||
mapbox::util::apply_visitor(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;
|
||||
trans_affine transform;
|
||||
|
@ -328,7 +330,8 @@ class renderer_agg : util::noncopyable
|
|||
curved_trans_contour_type curved_trans_contour(curved_trans);
|
||||
curved_trans_contour.auto_detect_orientation(true);
|
||||
|
||||
if (!attr.visibility_flag) return;
|
||||
if (!attr.visibility_flag)
|
||||
return;
|
||||
|
||||
transform = attr.transform;
|
||||
|
||||
|
@ -484,26 +487,27 @@ class renderer_agg : util::noncopyable
|
|||
struct grid_renderer
|
||||
{
|
||||
grid_renderer(renderer_agg& renderer,
|
||||
Rasterizer& ras, Scanline& sl, Renderer& ren,
|
||||
Rasterizer& ras,
|
||||
Scanline& sl,
|
||||
Renderer& ren,
|
||||
agg::trans_affine const& mtx,
|
||||
mapnik::value_integer const& feature_id)
|
||||
: renderer_(renderer),
|
||||
ras_(ras),
|
||||
sl_(sl),
|
||||
ren_(ren),
|
||||
mtx_(mtx),
|
||||
feature_id_(feature_id)
|
||||
: renderer_(renderer)
|
||||
, ras_(ras)
|
||||
, sl_(sl)
|
||||
, ren_(ren)
|
||||
, mtx_(mtx)
|
||||
, feature_id_(feature_id)
|
||||
{}
|
||||
|
||||
void operator() (group const& g) const
|
||||
void operator()(group const& g) const
|
||||
{
|
||||
for (auto const& elem : g.elements)
|
||||
{
|
||||
mapbox::util::apply_visitor(
|
||||
grid_renderer(renderer_, ras_, sl_, ren_, mtx_, feature_id_), elem);
|
||||
mapbox::util::apply_visitor(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;
|
||||
|
||||
|
@ -594,8 +598,9 @@ class renderer_agg : util::noncopyable
|
|||
{
|
||||
for (auto const& elem : svg_group_.elements)
|
||||
{
|
||||
mapbox::util::apply_visitor(grid_renderer<Rasterizer, Scanline, Renderer>
|
||||
(*this, ras, sl, ren, mtx, feature_id), elem);
|
||||
mapbox::util::apply_visitor(
|
||||
grid_renderer<Rasterizer, Scanline, Renderer>(*this, ras, sl, ren, mtx, feature_id),
|
||||
elem);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -40,7 +40,7 @@ class svg_storage : util::noncopyable
|
|||
, svg_height_(0)
|
||||
{}
|
||||
|
||||
VertexSource& source() { return source_;}
|
||||
VertexSource& source() { return source_; }
|
||||
|
||||
svg::group& svg_group() { return svg_group_; }
|
||||
|
||||
|
|
|
@ -89,7 +89,8 @@ struct agg_markers_renderer_context : markers_renderer_context
|
|||
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
|
||||
// render src provided that converts the destination pixel type required.
|
||||
|
|
|
@ -146,7 +146,7 @@ void grid_renderer<T>::process(markers_symbolizer const& sym,
|
|||
box2d<double> clip_box = common_.query_extent_;
|
||||
|
||||
using renderer_context_type =
|
||||
detail::grid_markers_renderer_context<svg_renderer_type, renderer_type, buf_type, grid_rasterizer, buffer_type>;
|
||||
detail::grid_markers_renderer_context<svg_renderer_type, renderer_type, buf_type, grid_rasterizer, buffer_type>;
|
||||
renderer_context_type renderer_context(feature, render_buf, *ras_ptr, pixmap_);
|
||||
|
||||
render_markers_symbolizer(sym, feature, prj_trans, common_, clip_box, renderer_context);
|
||||
|
|
|
@ -88,28 +88,28 @@ struct push_explicit_style
|
|||
boost::optional<color> const& stroke_color,
|
||||
boost::optional<double> const& stroke_width,
|
||||
boost::optional<double> const& stroke_opacity)
|
||||
: current_group_(&dst),
|
||||
fill_color_(fill_color),
|
||||
fill_opacity_(fill_opacity),
|
||||
stroke_color_(stroke_color),
|
||||
stroke_width_(stroke_width),
|
||||
stroke_opacity_(stroke_opacity)
|
||||
: current_group_(&dst)
|
||||
, fill_color_(fill_color)
|
||||
, fill_opacity_(fill_opacity)
|
||||
, stroke_color_(stroke_color)
|
||||
, stroke_width_(stroke_width)
|
||||
, 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_ = ¤t_group_->elements.back().get<svg::group>();
|
||||
bool success = false;
|
||||
for (auto const& elem : g.elements)
|
||||
{
|
||||
if (mapbox::util::apply_visitor
|
||||
(push_explicit_style(*current_group_,
|
||||
fill_color_,
|
||||
fill_opacity_,
|
||||
stroke_color_,
|
||||
stroke_width_,
|
||||
stroke_opacity_), elem))
|
||||
if (mapbox::util::apply_visitor(push_explicit_style(*current_group_,
|
||||
fill_color_,
|
||||
fill_opacity_,
|
||||
stroke_color_,
|
||||
stroke_width_,
|
||||
stroke_opacity_),
|
||||
elem))
|
||||
{
|
||||
success = true;
|
||||
}
|
||||
|
@ -118,12 +118,12 @@ struct push_explicit_style
|
|||
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};
|
||||
|
||||
if (!attr.visibility_flag)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
if (!attr.stroke_none)
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ struct push_explicit_style
|
|||
boost::optional<double> const& stroke_opacity_;
|
||||
};
|
||||
|
||||
} // detail
|
||||
} // namespace detail
|
||||
|
||||
bool push_explicit_style(svg::group const& src,
|
||||
svg::group& dst,
|
||||
|
@ -194,10 +194,13 @@ bool push_explicit_style(svg::group const& src,
|
|||
{
|
||||
for (auto const& elem : src.elements)
|
||||
{
|
||||
if (mapbox::util::apply_visitor
|
||||
(detail::push_explicit_style
|
||||
(dst, fill_color, fill_opacity,
|
||||
stroke_color, stroke_width, stroke_opacity), elem))
|
||||
if (mapbox::util::apply_visitor(detail::push_explicit_style(dst,
|
||||
fill_color,
|
||||
fill_opacity,
|
||||
stroke_color,
|
||||
stroke_width,
|
||||
stroke_opacity),
|
||||
elem))
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,7 @@ struct render_marker_symbolizer_visitor
|
|||
, renderer_context_(renderer_context)
|
||||
{}
|
||||
|
||||
svg::group const& get_marker_attributes(svg_path_ptr const& stock_marker,
|
||||
svg::group& custom_group_attrs) const
|
||||
svg::group const& get_marker_attributes(svg_path_ptr const& stock_marker, svg::group& custom_group_attrs) const
|
||||
{
|
||||
auto const& stock_group_attrs = stock_marker->svg_group();
|
||||
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;
|
||||
bool is_ellipse = false;
|
||||
|
||||
//svg_attribute_type s_attributes;
|
||||
// svg_attribute_type s_attributes;
|
||||
svg::group svg_group_attrs;
|
||||
auto const& svg_group_attrs_updated = get_marker_attributes(stock_vector_marker, svg_group_attrs);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ struct thunk_markers_renderer_context : markers_renderer_context
|
|||
}
|
||||
|
||||
virtual void
|
||||
render_marker(image_rgba8 const& src, markers_dispatch_params const& params, agg::trans_affine const& marker_tr)
|
||||
render_marker(image_rgba8 const& src, markers_dispatch_params const& params, agg::trans_affine const& marker_tr)
|
||||
{
|
||||
raster_marker_render_thunk thunk(src, marker_tr, params.opacity, comp_op_, params.snap_to_pixels);
|
||||
thunks_.emplace_back(std::move(thunk));
|
||||
|
|
|
@ -548,9 +548,11 @@ void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
|||
if (parser.css_style_)
|
||||
process_css(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);
|
||||
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();
|
||||
break;
|
||||
default:
|
||||
|
@ -561,9 +563,11 @@ void traverse_tree(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
|||
parse_attr(parser, node);
|
||||
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);
|
||||
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();
|
||||
}
|
||||
|
@ -624,9 +628,9 @@ void end_element(svg_parser& parser, rapidxml::xml_node<char> const* node)
|
|||
}
|
||||
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)
|
||||
|
@ -676,7 +680,7 @@ void parse_element(svg_parser& parser, char const* name, rapidxml::xml_node<char
|
|||
parse_ellipse(parser, node);
|
||||
break;
|
||||
case "svg"_case:
|
||||
//parser.path_.push_attr();
|
||||
// parser.path_.push_attr();
|
||||
parse_dimensions(parser, node);
|
||||
parse_attr(parser, node);
|
||||
parser.path_.set_opacity(parser.path_.cur_attr().opacity);
|
||||
|
@ -1578,7 +1582,7 @@ void parse_radial_gradient(svg_parser& parser, rapidxml::xml_node<char> const* n
|
|||
fy /= parser.path_.height();
|
||||
cx /= parser.path_.width();
|
||||
cy /= parser.path_.height();
|
||||
r /= parser.path_.width();
|
||||
r /= parser.path_.width();
|
||||
}
|
||||
gr.set_units(USER_SPACE_ON_USE_BOUNDING_BOX);
|
||||
}
|
||||
|
|
|
@ -265,7 +265,7 @@ TEST_CASE("SVG parser")
|
|||
agg::line_cap_e expected_cap(agg::square_cap);
|
||||
REQUIRE(group_attrs.elements.size() == 1);
|
||||
// FIXME
|
||||
//REQUIRE(attrs[0].line_cap == expected_cap);
|
||||
// REQUIRE(attrs[0].line_cap == expected_cap);
|
||||
|
||||
double x, y;
|
||||
unsigned cmd;
|
||||
|
@ -432,7 +432,7 @@ TEST_CASE("SVG parser")
|
|||
agg::line_join_e expected_join(agg::bevel_join);
|
||||
REQUIRE(group_attrs.elements.size() == 1);
|
||||
// FIXME
|
||||
//REQUIRE(attrs[0].line_join == expected_join);
|
||||
// REQUIRE(attrs[0].line_join == expected_join);
|
||||
}
|
||||
|
||||
SECTION("SVG <line>")
|
||||
|
@ -443,8 +443,9 @@ TEST_CASE("SVG parser")
|
|||
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
auto bbox = svg.bounding_box();
|
||||
REQUIRE(bbox == mapnik::box2d<double>(0.3543307086614174,0.3543307086614174,
|
||||
424.8425196850394059,141.3779527559055396));
|
||||
REQUIRE(
|
||||
bbox ==
|
||||
mapnik::box2d<double>(0.3543307086614174, 0.3543307086614174, 424.8425196850394059, 141.3779527559055396));
|
||||
auto storage = svg.get_data();
|
||||
REQUIRE(storage);
|
||||
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>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
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>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
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>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||
|
@ -649,15 +650,15 @@ TEST_CASE("SVG parser")
|
|||
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
mapnik::svg::vertex_stl_adapter<mapnik::svg::svg_path_storage> stl_storage(storage->source());
|
||||
|
||||
auto const& group_attrs = storage->svg_group();
|
||||
REQUIRE(group_attrs.elements.size() == 3);
|
||||
// FIXME
|
||||
//REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||
// FIXME
|
||||
// REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||
|
||||
mapnik::svg::svg_path_adapter path(stl_storage);
|
||||
double x, y;
|
||||
|
@ -699,18 +700,18 @@ TEST_CASE("SVG parser")
|
|||
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
|
||||
auto const& group_attrs = storage->svg_group();
|
||||
// FIXME
|
||||
//REQUIRE(attrs.size() == 3);
|
||||
//REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||
//REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||
// REQUIRE(attrs.size() == 3);
|
||||
// REQUIRE(attrs[1].fill_gradient == attrs[2].fill_gradient);
|
||||
// REQUIRE(attrs[1].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||
agg::trans_affine transform;
|
||||
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")
|
||||
|
@ -721,16 +722,16 @@ TEST_CASE("SVG parser")
|
|||
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
|
||||
auto const& group_attrs = storage->svg_group();
|
||||
// FIXME
|
||||
//REQUIRE(attrs.elements.size() == 2);
|
||||
//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.has_stop());
|
||||
// REQUIRE(attrs.elements.size() == 2);
|
||||
// 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.has_stop());
|
||||
}
|
||||
|
||||
SECTION("SVG <gradient> with radial percents")
|
||||
|
@ -741,22 +742,22 @@ TEST_CASE("SVG parser")
|
|||
REQUIRE(marker->is<mapnik::marker_svg>());
|
||||
mapnik::marker_svg const& svg = mapnik::util::get<mapnik::marker_svg>(*marker);
|
||||
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();
|
||||
REQUIRE(storage);
|
||||
|
||||
double x1, x2, y1, y2, r;
|
||||
// FIXME
|
||||
//auto const& attrs = storage->attributes();
|
||||
//REQUIRE(attrs.size() == 1);
|
||||
//REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||
//REQUIRE(attrs[0].fill_gradient.has_stop());
|
||||
//attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r);
|
||||
//REQUIRE(x1 == 0);
|
||||
//REQUIRE(y1 == 0.25);
|
||||
//REQUIRE(x2 == 0.10);
|
||||
//REQUIRE(y2 == 0.10);
|
||||
//REQUIRE(r == 0.75);
|
||||
// auto const& attrs = storage->attributes();
|
||||
// REQUIRE(attrs.size() == 1);
|
||||
// REQUIRE(attrs[0].fill_gradient.get_gradient_type() == mapnik::RADIAL);
|
||||
// REQUIRE(attrs[0].fill_gradient.has_stop());
|
||||
// attrs[0].fill_gradient.get_control_points(x1, y1, x2, y2, r);
|
||||
// REQUIRE(x1 == 0);
|
||||
// REQUIRE(y1 == 0.25);
|
||||
// REQUIRE(x2 == 0.10);
|
||||
// REQUIRE(y2 == 0.10);
|
||||
// REQUIRE(r == 0.75);
|
||||
}
|
||||
|
||||
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_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||
|
||||
|
||||
agg::rasterizer_scanline_aa<> ras_ptr;
|
||||
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::svg_path_adapter svg_path(stl_storage);
|
||||
mapnik::svg::
|
||||
renderer_agg<mapnik::svg_path_adapter, mapnik::svg_attribute_type, renderer_solid, pixfmt>
|
||||
renderer(svg_path, svg.get_data()->svg_group());
|
||||
mapnik::svg::renderer_agg<mapnik::svg_path_adapter, mapnik::svg_attribute_type, renderer_solid, pixfmt> renderer(
|
||||
svg_path,
|
||||
svg.get_data()->svg_group());
|
||||
double opacity = 1.0;
|
||||
renderer.render(ras_ptr, sl, renb, mtx, opacity, {0, 0, svg_width, svg_height});
|
||||
return im;
|
||||
|
|
|
@ -56,11 +56,11 @@ MAPNIK_DISABLE_WARNING_POP
|
|||
struct main_marker_visitor
|
||||
{
|
||||
main_marker_visitor(std::string const& svg_name, double scale_factor, double opacity, bool verbose, bool auto_open)
|
||||
: svg_name_(svg_name),
|
||||
scale_factor_(scale_factor),
|
||||
opacity_(opacity),
|
||||
verbose_(verbose),
|
||||
auto_open_(auto_open)
|
||||
: svg_name_(svg_name)
|
||||
, scale_factor_(scale_factor)
|
||||
, opacity_(opacity)
|
||||
, verbose_(verbose)
|
||||
, auto_open_(auto_open)
|
||||
{}
|
||||
|
||||
int operator()(mapnik::marker_svg const& marker) const
|
||||
|
@ -68,7 +68,7 @@ struct main_marker_visitor
|
|||
#if 1
|
||||
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
|
||||
using blender_type = agg::comp_op_adaptor_rgba_pre<color_type, order_type>; // comp blender
|
||||
using buf_type = agg::rendering_buffer;
|
||||
using pixfmt = agg::pixfmt_custom_blend_rgba<blender_type, buf_type>;
|
||||
using renderer_base = agg::renderer_base<pixfmt>;
|
||||
|
@ -120,7 +120,7 @@ struct main_marker_visitor
|
|||
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::renderer_agg<mapnik::svg_path_adapter, mapnik::svg_attribute_type, renderer_solid, pixfmt>
|
||||
svg_renderer_this(svg_path, marker.get_data()->svg_group());
|
||||
svg_renderer_this(svg_path, marker.get_data()->svg_group());
|
||||
|
||||
svg_renderer_this.render(ras_ptr, sl, renb, mtx, opacity_, bbox);
|
||||
|
||||
|
|
Loading…
Reference in a new issue