clang-format

This commit is contained in:
Artem Pavlenko 2022-11-25 13:54:41 +00:00
parent e790aa6c06
commit 7c24ff09ee
14 changed files with 165 additions and 147 deletions

View file

@ -37,7 +37,13 @@ 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
{
@ -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,7 +92,7 @@ struct bounding_box
double& y2_;
bool& first_;
};
} // detail
} // namespace detail
template<typename VertexSource>
void bounding_box(VertexSource& vs, group const& g, double& x1, double& y1, double& x2, double& y2)
@ -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

View file

@ -58,11 +58,11 @@ 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; }
@ -73,10 +73,7 @@ class svg_converter : util::noncopyable
current_group_ = &current_group_->elements.back().get<group>();
}
void end_group()
{
current_group_ = current_group_->parent;
}
void end_group() { current_group_ = current_group_->parent; }
void begin_path()
{

View file

@ -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

View file

@ -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,
@ -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,8 +314,7 @@ 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);
}
}
}
@ -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,23 +487,24 @@ 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
{
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
@ -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

View file

@ -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.

View file

@ -88,12 +88,12 @@ 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
@ -103,13 +103,13 @@ struct push_explicit_style
bool success = false;
for (auto const& elem : g.elements)
{
if (mapbox::util::apply_visitor
(push_explicit_style(*current_group_,
if (mapbox::util::apply_visitor(push_explicit_style(*current_group_,
fill_color_,
fill_opacity_,
stroke_color_,
stroke_width_,
stroke_opacity_), elem))
stroke_opacity_),
elem))
{
success = true;
}
@ -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;
}
}

View file

@ -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_))

View file

@ -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();
}

View file

@ -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());

View file

@ -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;

View file

@ -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