From 3ed7e347cb7f43c7685c282fae6a9069d978dc14 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 6 Jul 2015 18:47:47 -0700 Subject: [PATCH] use unique_ptr instead of shared_ptr for glyph_positions_ptr - refs #2516 --- .../renderer_common/process_group_symbolizer.hpp | 2 +- include/mapnik/text/glyph_positions.hpp | 2 +- include/mapnik/text/placement_finder.hpp | 2 +- src/agg/process_group_symbolizer.cpp | 2 +- src/agg/process_shield_symbolizer.cpp | 2 +- src/agg/process_text_symbolizer.cpp | 2 +- src/cairo/process_group_symbolizer.cpp | 2 +- src/cairo/process_text_symbolizer.cpp | 4 ++-- src/grid/process_group_symbolizer.cpp | 2 +- src/grid/process_shield_symbolizer.cpp | 2 +- src/grid/process_text_symbolizer.cpp | 2 +- src/text/placement_finder.cpp | 10 +++++----- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/mapnik/renderer_common/process_group_symbolizer.hpp b/include/mapnik/renderer_common/process_group_symbolizer.hpp index 006d1a9f3..d593b8ead 100644 --- a/include/mapnik/renderer_common/process_group_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_group_symbolizer.hpp @@ -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(); diff --git a/include/mapnik/text/glyph_positions.hpp b/include/mapnik/text/glyph_positions.hpp index c192037fd..604de8c7c 100644 --- a/include/mapnik/text/glyph_positions.hpp +++ b/include/mapnik/text/glyph_positions.hpp @@ -89,7 +89,7 @@ private: pixel_position marker_pos_; box2d bbox_; }; -using glyph_positions_ptr = std::shared_ptr; +using glyph_positions_ptr = std::unique_ptr; using placements_list = std::list; } diff --git a/include/mapnik/text/placement_finder.hpp b/include/mapnik/text/placement_finder.hpp index f3ffd512a..f2bd36db3 100644 --- a/include/mapnik/text/placement_finder.hpp +++ b/include/mapnik/text/placement_finder.hpp @@ -75,7 +75,7 @@ private: // Checks for collision. bool collision(box2d 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; diff --git a/src/agg/process_group_symbolizer.cpp b/src/agg/process_group_symbolizer.cpp index 836e13533..68c54f2c3 100644 --- a/src/agg/process_group_symbolizer.cpp +++ b/src/agg/process_group_symbolizer.cpp @@ -120,7 +120,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) diff --git a/src/agg/process_shield_symbolizer.cpp b/src/agg/process_shield_symbolizer.cpp index e8d1cc5c5..67fe8de0d 100644 --- a/src/agg/process_shield_symbolizer.cpp +++ b/src/agg/process_shield_symbolizer.cpp @@ -60,7 +60,7 @@ void agg_renderer::process(shield_symbolizer const& sym, double opacity = get(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) diff --git a/src/agg/process_text_symbolizer.cpp b/src/agg/process_text_symbolizer.cpp index c30566d61..078a7abaa 100644 --- a/src/agg/process_text_symbolizer.cpp +++ b/src/agg/process_text_symbolizer.cpp @@ -67,7 +67,7 @@ void agg_renderer::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); } diff --git a/src/cairo/process_group_symbolizer.cpp b/src/cairo/process_group_symbolizer.cpp index 79338664d..d32afcf67 100644 --- a/src/cairo/process_group_symbolizer.cpp +++ b/src/cairo/process_group_symbolizer.cpp @@ -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) diff --git a/src/cairo/process_text_symbolizer.cpp b/src/cairo/process_text_symbolizer.cpp index 176b6c635..06b56cb2d 100644 --- a/src/cairo/process_text_symbolizer.cpp +++ b/src/cairo/process_text_symbolizer.cpp @@ -55,7 +55,7 @@ void cairo_renderer::process(shield_symbolizer const& sym, double opacity = get(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::process(text_symbolizer const& sym, composite_mode_e halo_comp_op = get(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_); } diff --git a/src/grid/process_group_symbolizer.cpp b/src/grid/process_group_symbolizer.cpp index 25c360027..a672f6b8f 100644 --- a/src/grid/process_group_symbolizer.cpp +++ b/src/grid/process_group_symbolizer.cpp @@ -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) diff --git a/src/grid/process_shield_symbolizer.cpp b/src/grid/process_shield_symbolizer.cpp index ae4ffa2d1..781989384 100644 --- a/src/grid/process_shield_symbolizer.cpp +++ b/src/grid/process_shield_symbolizer.cpp @@ -64,7 +64,7 @@ void grid_renderer::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) diff --git a/src/grid/process_text_symbolizer.cpp b/src/grid/process_text_symbolizer.cpp index a615a5db6..3df4ad24f 100644 --- a/src/grid/process_text_symbolizer.cpp +++ b/src/grid/process_text_symbolizer.cpp @@ -66,7 +66,7 @@ void grid_renderer::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; diff --git a/src/text/placement_finder.cpp b/src/text/placement_finder.cpp index 3e7b69bfc..7c09e56f2 100644 --- a/src/text/placement_finder.cpp +++ b/src/text/placement_finder.cpp @@ -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_ptr glyphs = std::make_unique(); std::vector > 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_ptr glyphs = std::make_unique(); std::vector > 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 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 bbox = marker_box_;