use unique_ptr instead of shared_ptr for glyph_positions_ptr - refs #2516

This commit is contained in:
Dane Springmeyer 2015-07-06 18:47:47 -07:00
parent 3f91186a74
commit 3ed7e347cb
12 changed files with 17 additions and 17 deletions

View file

@ -211,7 +211,7 @@ void render_offset_placements(placements_list const& placements,
pixel_position const& offset,
F render_text) {
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
// move the glyphs to the correct offset
pixel_position base_point = glyphs->get_base_point();

View file

@ -89,7 +89,7 @@ private:
pixel_position marker_pos_;
box2d<double> bbox_;
};
using glyph_positions_ptr = std::shared_ptr<glyph_positions>;
using glyph_positions_ptr = std::unique_ptr<glyph_positions>;
using placements_list = std::list<glyph_positions_ptr>;
}

View file

@ -75,7 +75,7 @@ private:
// Checks for collision.
bool collision(box2d<double> const& box, const value_unicode_string &repeat_key, bool line_placement) const;
// Adds marker to glyph_positions and to collision detector. Returns false if there is a collision.
bool add_marker(glyph_positions_ptr glyphs, pixel_position const& pos) const;
bool add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const;
// Maps upright==auto, left-only and right-only to left,right to simplify processing.
// angle = angle of at start of line (to estimate best option for upright==auto)
text_upright_e simplify_upright(text_upright_e upright, double angle) const;

View file

@ -120,7 +120,7 @@ struct thunk_renderer<image_rgba8>
render_offset_placements(
thunk.placements_,
offset_,
[&] (glyph_positions_ptr glyphs)
[&] (glyph_positions_ptr const& glyphs)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)

View file

@ -60,7 +60,7 @@ void agg_renderer<T0,T1>::process(shield_symbolizer const& sym,
double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0);
placements_list const& placements = helper.get();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)

View file

@ -67,7 +67,7 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
}
placements_list const& placements = helper.get();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
ren.render(*glyphs);
}

View file

@ -95,7 +95,7 @@ struct thunk_renderer
render_offset_placements(
thunk.placements_,
offset_,
[&] (glyph_positions_ptr glyphs)
[&] (glyph_positions_ptr const& glyphs)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)

View file

@ -55,7 +55,7 @@ void cairo_renderer<T>::process(shield_symbolizer const& sym,
double opacity = get<double>(sym,keys::opacity,feature, common_.vars_, 1.0);
placements_list const &placements = helper.get();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark) {
@ -93,7 +93,7 @@ void cairo_renderer<T>::process(text_symbolizer const& sym,
composite_mode_e halo_comp_op = get<composite_mode_e>(sym, keys::halo_comp_op, feature, common_.vars_, src_over);
placements_list const& placements = helper.get();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
context_.add_text(*glyphs, face_manager_, comp_op, halo_comp_op, common_.scale_factor_);
}

View file

@ -129,7 +129,7 @@ struct thunk_renderer
render_offset_placements(
thunk.placements_,
offset_,
[&] (glyph_positions_ptr glyphs)
[&] (glyph_positions_ptr const& glyphs)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)

View file

@ -64,7 +64,7 @@ void grid_renderer<T>::process(shield_symbolizer const& sym,
placements_list const& placements = helper.get();
value_integer feature_id = feature.id();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
marker_info_ptr mark = glyphs->get_marker();
if (mark)

View file

@ -66,7 +66,7 @@ void grid_renderer<T>::process(text_symbolizer const& sym,
placements_list const& placements = helper.get();
value_integer feature_id = feature.id();
for (glyph_positions_ptr glyphs : placements)
for (auto const& glyphs : placements)
{
ren.render(*glyphs, feature_id);
placement_found = true;

View file

@ -118,7 +118,7 @@ text_upright_e placement_finder::simplify_upright(text_upright_e upright, double
bool placement_finder::find_point_placement(pixel_position const& pos)
{
glyph_positions_ptr glyphs = std::make_shared<glyph_positions>();
glyph_positions_ptr glyphs = std::make_unique<glyph_positions>();
std::vector<box2d<double> > bboxes;
glyphs->reserve(layouts_.glyphs_count());
@ -200,7 +200,7 @@ bool placement_finder::find_point_placement(pixel_position const& pos)
// do not render text off the canvas
if (extent_.intersects(label_box))
{
placements_.push_back(glyphs);
placements_.push_back(std::move(glyphs));
}
return true;
@ -215,7 +215,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
vertex_cache::scoped_state begin(pp);
text_upright_e real_orientation = simplify_upright(orientation, pp.angle());
glyph_positions_ptr glyphs = std::make_shared<glyph_positions>();
glyph_positions_ptr glyphs = std::make_unique<glyph_positions>();
std::vector<box2d<double> > bboxes;
glyphs->reserve(layouts_.glyphs_count());
bboxes.reserve(layouts_.glyphs_count());
@ -359,7 +359,7 @@ bool placement_finder::single_line_placement(vertex_cache &pp, text_upright_e or
// do not render text off the canvas
if (extent_.intersects(label_box))
{
placements_.push_back(glyphs);
placements_.push_back(std::move(glyphs));
}
return true;
@ -420,7 +420,7 @@ void placement_finder::set_marker(marker_info_ptr m, box2d<double> box, bool mar
}
bool placement_finder::add_marker(glyph_positions_ptr glyphs, pixel_position const& pos) const
bool placement_finder::add_marker(glyph_positions_ptr & glyphs, pixel_position const& pos) const
{
pixel_position real_pos = (marker_unlocked_ ? pos : glyphs->get_base_point()) + marker_displacement_;
box2d<double> bbox = marker_box_;