From a7ecabcde303a509c74c175c90b40a335dca1958 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Mon, 25 Jan 2016 02:45:53 +0100 Subject: [PATCH] move render_group_symbolizer to separate .cpp - use abstract class render_thunk_list_dispatch for the callback instead of template parameter render_thunks - add class scoped_glyph_positions_offset for temporary shifting of glyph positions - remove render_offset_placements --- Makefile | 4 +- .../render_group_symbolizer.hpp | 66 +++++++++++++++ include/mapnik/text/glyph_positions.hpp | 50 ++++++++++-- include/mapnik/text/renderer.hpp | 27 +++++++ src/agg/process_group_symbolizer.cpp | 73 +++++++---------- src/build.py | 1 + src/cairo/process_group_symbolizer.cpp | 60 +++++--------- src/grid/process_group_symbolizer.cpp | 81 +++++++------------ .../render_group_symbolizer.cpp | 65 +++------------ src/text/glyph_positions.cpp | 2 +- src/text/renderer.cpp | 4 +- 11 files changed, 234 insertions(+), 199 deletions(-) create mode 100644 include/mapnik/renderer_common/render_group_symbolizer.hpp rename include/mapnik/renderer_common/process_group_symbolizer.hpp => src/renderer_common/render_group_symbolizer.cpp (79%) diff --git a/Makefile b/Makefile index 737438066..a0a209126 100755 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ src/json/libmapnik-json.a: # we first build memory intensive files with -j1 $(PYTHON) scons/scons.py -j1 \ --config=cache --implicit-cache --max-drift=1 \ + src/renderer_common/render_group_symbolizer.os \ src/renderer_common/render_thunk_extractor.os \ src/json/libmapnik-json.a \ src/wkt/libmapnik-wkt.a \ @@ -48,11 +49,8 @@ src/json/libmapnik-json.a: src/transform_expression_grammar.os \ src/image_filter_grammar.os \ src/agg/process_markers_symbolizer.os \ - src/agg/process_group_symbolizer.os \ src/grid/process_markers_symbolizer.os \ - src/grid/process_group_symbolizer.os \ src/cairo/process_markers_symbolizer.os \ - src/cairo/process_group_symbolizer.os \ mapnik: src/json/libmapnik-json.a # then install the rest with -j$(JOBS) diff --git a/include/mapnik/renderer_common/render_group_symbolizer.hpp b/include/mapnik/renderer_common/render_group_symbolizer.hpp new file mode 100644 index 000000000..e7b1b2248 --- /dev/null +++ b/include/mapnik/renderer_common/render_group_symbolizer.hpp @@ -0,0 +1,66 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2016 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_RENDERER_COMMON_RENDER_GROUP_SYMBOLIZER_HPP +#define MAPNIK_RENDERER_COMMON_RENDER_GROUP_SYMBOLIZER_HPP + +// mapnik +#include +#include +#include +#include +#include + +namespace mapnik { + +struct render_thunk_list_dispatch +{ + virtual void operator()(vector_marker_render_thunk const& thunk) = 0; + virtual void operator()(raster_marker_render_thunk const& thunk) = 0; + virtual void operator()(text_render_thunk const& thunk) = 0; + + void render_list(render_thunk_list const& thunks, pixel_position const& offset) + { + offset_ = offset; + + for (render_thunk_ptr const& thunk : thunks) + { + util::apply_visitor(std::ref(*this), *thunk); + } + } + +protected: + pixel_position offset_; +}; + +MAPNIK_DECL +void render_group_symbolizer(group_symbolizer const& sym, + feature_impl & feature, + attributes const& vars, + proj_transform const& prj_trans, + box2d const& clipping_extent, + renderer_common & common, + render_thunk_list_dispatch & render_thunks); + +} // namespace mapnik + +#endif // MAPNIK_RENDERER_COMMON_RENDER_GROUP_SYMBOLIZER_HPP diff --git a/include/mapnik/text/glyph_positions.hpp b/include/mapnik/text/glyph_positions.hpp index e956edda8..72314c319 100644 --- a/include/mapnik/text/glyph_positions.hpp +++ b/include/mapnik/text/glyph_positions.hpp @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * *****************************************************************************/ -#ifndef MAPNIK_PLACEMENTS_LIST_HPP -#define MAPNIK_PLACEMENTS_LIST_HPP + +#ifndef MAPNIK_TEXT_GLYPH_POSITIONS_HPP +#define MAPNIK_TEXT_GLYPH_POSITIONS_HPP + //mapnik #include #include @@ -79,7 +81,7 @@ public: pixel_position const& get_base_point() const; void set_base_point(pixel_position const& base_point); void set_marker(marker_info_ptr marker, pixel_position const& marker_pos); - marker_info_ptr get_marker() const; + marker_info_ptr const& get_marker() const; pixel_position const& marker_pos() const; private: std::vector data_; @@ -88,8 +90,46 @@ private: pixel_position marker_pos_; box2d bbox_; }; + using glyph_positions_ptr = std::unique_ptr; using placements_list = std::list; -} -#endif // PLACEMENTS_LIST_HPP + +struct scoped_glyph_positions_offset +{ + scoped_glyph_positions_offset(glyph_positions & glyphs, pixel_position const& offset) + : glyphs_(glyphs) + , base_point_(glyphs.get_base_point()) + , marker_pos_(glyphs.marker_pos()) + { + // move the glyphs to the correct offset + glyphs_.set_base_point(base_point_ + offset); + + // update the position of any marker + if (auto const& marker_info = glyphs_.get_marker()) + { + glyphs_.set_marker(marker_info, marker_pos_ + offset); + } + } + + ~scoped_glyph_positions_offset() + { + // set the base_point back how it was + glyphs_.set_base_point(base_point_); + + // restore marker as well, if there is any + if (auto const& marker_info = glyphs_.get_marker()) + { + glyphs_.set_marker(marker_info, marker_pos_); + } + } + +private: + glyph_positions & glyphs_; + pixel_position base_point_; + pixel_position marker_pos_; +}; + +} // namespace mapnik + +#endif // MAPNIK_TEXT_GLYPH_POSITIONS_HPP diff --git a/include/mapnik/text/renderer.hpp b/include/mapnik/text/renderer.hpp index 1b6bac112..a4cd76ed7 100644 --- a/include/mapnik/text/renderer.hpp +++ b/include/mapnik/text/renderer.hpp @@ -58,8 +58,35 @@ public: composite_mode_e halo_comp_op = src_over, double scale_factor = 1.0, stroker_ptr stroker = stroker_ptr()); + + void set_comp_op(composite_mode_e comp_op) + { + comp_op_ = comp_op; + } + + void set_halo_comp_op(composite_mode_e halo_comp_op) + { + halo_comp_op_ = halo_comp_op; + } + + void set_halo_rasterizer(halo_rasterizer_e rasterizer) + { + rasterizer_ = rasterizer; + } + + void set_scale_factor(double scale_factor) + { + scale_factor_ = scale_factor; + } + + void set_stroker(stroker_ptr stroker) + { + stroker_ = stroker; + } + void set_transform(agg::trans_affine const& transform); void set_halo_transform(agg::trans_affine const& halo_transform); + protected: using glyph_vector = std::vector; void prepare_glyphs(glyph_positions const& positions); diff --git a/src/agg/process_group_symbolizer.cpp b/src/agg/process_group_symbolizer.cpp index f2c8adf48..010d3f18a 100644 --- a/src/agg/process_group_symbolizer.cpp +++ b/src/agg/process_group_symbolizer.cpp @@ -25,20 +25,16 @@ #include #include #include -#include #include -#include #include -#include -#include -#include #include -#include #include +#include #include #include #include #include + // agg #include "agg_trans_affine.h" @@ -55,7 +51,7 @@ template struct thunk_renderer; template <> -struct thunk_renderer +struct thunk_renderer : render_thunk_list_dispatch { using renderer_type = agg_renderer; using buffer_type = renderer_type::buffer_type; @@ -64,12 +60,13 @@ struct thunk_renderer thunk_renderer(renderer_type &ren, std::unique_ptr const& ras_ptr, buffer_type *buf, - renderer_common &common, - pixel_position const &offset) - : ren_(ren), ras_ptr_(ras_ptr), buf_(buf), common_(common), offset_(offset) + renderer_common &common) + : ren_(ren), ras_ptr_(ras_ptr), buf_(buf), common_(common), + tex_(*buf, HALO_RASTERIZER_FULL, src_over, src_over, + common.scale_factor_, common.font_manager_.get_stroker()) {} - void operator()(vector_marker_render_thunk const &thunk) const + virtual void operator()(vector_marker_render_thunk const& thunk) { using blender_type = agg::comp_op_adaptor_rgba_pre; // comp blender using buf_type = agg::rendering_buffer; @@ -95,7 +92,7 @@ struct thunk_renderer render_vector_marker(svg_renderer, *ras_ptr_, renb, thunk.src_->bounding_box(), offset_tr, thunk.opacity_, thunk.snap_to_pixels_); } - void operator()(raster_marker_render_thunk const &thunk) const + virtual void operator()(raster_marker_render_thunk const& thunk) { using blender_type = agg::comp_op_adaptor_rgba_pre; // comp blender using buf_type = agg::rendering_buffer; @@ -113,32 +110,25 @@ struct thunk_renderer render_raster_marker(renb, *ras_ptr_, thunk.src_, offset_tr, thunk.opacity_, common_.scale_factor_, thunk.snap_to_pixels_); } - void operator()(text_render_thunk const &thunk) const + virtual void operator()(text_render_thunk const& thunk) { - text_renderer_type ren(*buf_, thunk.halo_rasterizer_, thunk.comp_op_, thunk.comp_op_, - common_.scale_factor_, common_.font_manager_.get_stroker()); + tex_.set_comp_op(thunk.comp_op_); + tex_.set_halo_comp_op(thunk.comp_op_); + tex_.set_halo_rasterizer(thunk.halo_rasterizer_); - render_offset_placements( - thunk.placements_, - offset_, - [&] (glyph_positions_ptr const& glyphs) + for (auto const& glyphs : thunk.placements_) + { + scoped_glyph_positions_offset tmp_off(*glyphs, offset_); + + if (auto const& mark = glyphs->get_marker()) { - marker_info_ptr mark = glyphs->get_marker(); - if (mark) - { - ren_.render_marker(glyphs->marker_pos(), - *mark->marker_, - mark->transform_, - thunk.opacity_, thunk.comp_op_); - } - ren.render(*glyphs); - }); - } - - template - void operator()(T const &) const - { - throw std::runtime_error("Rendering of this data type is not supported currently by the renderer"); + ren_.render_marker(glyphs->marker_pos(), + *mark->marker_, + mark->transform_, + thunk.opacity_, thunk.comp_op_); + } + tex_.render(*glyphs); + } } private: @@ -146,7 +136,7 @@ private: std::unique_ptr const& ras_ptr_; buffer_type *buf_; renderer_common &common_; - pixel_position offset_; + text_renderer_type tex_; }; template @@ -154,16 +144,11 @@ void agg_renderer::process(group_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + thunk_renderer ren(*this, ras_ptr, current_buffer_, common_); + render_group_symbolizer( sym, feature, common_.vars_, prj_trans, clipping_extent(common_), common_, - [&](render_thunk_list const& thunks, pixel_position const& render_offset) - { - thunk_renderer ren(*this, ras_ptr, current_buffer_, common_, render_offset); - for (render_thunk_ptr const& thunk : thunks) - { - util::apply_visitor(ren, *thunk); - } - }); + ren); } template void agg_renderer::process(group_symbolizer const&, diff --git a/src/build.py b/src/build.py index f135b64ab..1cefbf560 100644 --- a/src/build.py +++ b/src/build.py @@ -253,6 +253,7 @@ source = Split( config_error.cpp color_factory.cpp renderer_common.cpp + renderer_common/render_group_symbolizer.cpp renderer_common/render_pattern.cpp renderer_common/render_thunk_extractor.cpp math.cpp diff --git a/src/cairo/process_group_symbolizer.cpp b/src/cairo/process_group_symbolizer.cpp index a2dc4abbe..0c35ba0ec 100644 --- a/src/cairo/process_group_symbolizer.cpp +++ b/src/cairo/process_group_symbolizer.cpp @@ -25,13 +25,12 @@ // mapnik #include #include -#include #include #include #include // mapnik symbolizer generics -#include +#include namespace mapnik { @@ -47,20 +46,19 @@ namespace { // to render it, and the boxes themselves should already be // in the detector from the placement_finder. template -struct thunk_renderer +struct thunk_renderer : render_thunk_list_dispatch { using renderer_type = cairo_renderer; thunk_renderer(renderer_type & ren, cairo_context & context, cairo_face_manager & face_manager, - renderer_common & common, - pixel_position const& offset) + renderer_common & common) : ren_(ren), context_(context), face_manager_(face_manager), - common_(common), offset_(offset) + common_(common) {} - void operator()(vector_marker_render_thunk const &thunk) const + virtual void operator()(vector_marker_render_thunk const& thunk) { cairo_save_restore guard(context_); context_.set_operator(thunk.comp_op_); @@ -78,7 +76,7 @@ struct thunk_renderer thunk.opacity_); } - void operator()(raster_marker_render_thunk const& thunk) const + virtual void operator()(raster_marker_render_thunk const& thunk) { cairo_save_restore guard(context_); context_.set_operator(thunk.comp_op_); @@ -88,32 +86,24 @@ struct thunk_renderer context_.add_image(offset_tr, thunk.src_, thunk.opacity_); } - void operator()(text_render_thunk const &thunk) const + virtual void operator()(text_render_thunk const& thunk) { cairo_save_restore guard(context_); context_.set_operator(thunk.comp_op_); - render_offset_placements( - thunk.placements_, - offset_, - [&] (glyph_positions_ptr const& glyphs) - { - marker_info_ptr mark = glyphs->get_marker(); - if (mark) - { - ren_.render_marker(glyphs->marker_pos(), - *mark->marker_, - mark->transform_, - thunk.opacity_, thunk.comp_op_); - } - context_.add_text(*glyphs, face_manager_, src_over, src_over, common_.scale_factor_); - }); - } + for (auto const& glyphs : thunk.placements_) + { + scoped_glyph_positions_offset tmp_off(*glyphs, offset_); - template - void operator()(T0 const &) const - { - throw std::runtime_error("Rendering of this type is not supported by the cairo renderer."); + if (auto const& mark = glyphs->get_marker()) + { + ren_.render_marker(glyphs->marker_pos(), + *mark->marker_, + mark->transform_, + thunk.opacity_, thunk.comp_op_); + } + context_.add_text(*glyphs, face_manager_, src_over, src_over, common_.scale_factor_); + } } private: @@ -121,7 +111,6 @@ private: cairo_context & context_; cairo_face_manager & face_manager_; renderer_common & common_; - pixel_position offset_; }; } // anonymous namespace @@ -131,16 +120,11 @@ void cairo_renderer::process(group_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + thunk_renderer ren(*this, context_, face_manager_, common_); + render_group_symbolizer( sym, feature, common_.vars_, prj_trans, common_.query_extent_, common_, - [&](render_thunk_list const& thunks, pixel_position const& render_offset) - { - thunk_renderer ren(*this, context_, face_manager_, common_, render_offset); - for (render_thunk_ptr const& thunk : thunks) - { - util::apply_visitor(ren, *thunk); - } - }); + ren); } template void cairo_renderer::process(group_symbolizer const&, diff --git a/src/grid/process_group_symbolizer.cpp b/src/grid/process_group_symbolizer.cpp index f73118969..a93ea9d59 100644 --- a/src/grid/process_group_symbolizer.cpp +++ b/src/grid/process_group_symbolizer.cpp @@ -29,25 +29,13 @@ #include #include #include -#include -#include -#include #include #include #include #include #include #include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include // agg #include "agg_trans_affine.h" @@ -61,7 +49,7 @@ namespace mapnik { * in the detector from the placement_finder. */ template -struct thunk_renderer +struct thunk_renderer : render_thunk_list_dispatch { using renderer_type = grid_renderer; using buffer_type = typename renderer_type::buffer_type; @@ -71,13 +59,13 @@ struct thunk_renderer grid_rasterizer &ras, buffer_type &pixmap, renderer_common &common, - feature_impl &feature, - pixel_position const &offset) + feature_impl &feature) : ren_(ren), ras_(ras), pixmap_(pixmap), - common_(common), feature_(feature), offset_(offset) + common_(common), feature_(feature), + tex_(pixmap, src_over, common.scale_factor_) {} - void operator()(vector_marker_render_thunk const &thunk) const + virtual void operator()(vector_marker_render_thunk const& thunk) { using buf_type = grid_rendering_buffer; using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; @@ -106,7 +94,7 @@ struct thunk_renderer pixmap_.add_feature(feature_); } - void operator()(raster_marker_render_thunk const &thunk) const + virtual void operator()(raster_marker_render_thunk const& thunk) { using buf_type = grid_rendering_buffer; using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; @@ -122,34 +110,28 @@ struct thunk_renderer pixmap_.add_feature(feature_); } - void operator()(text_render_thunk const &thunk) const + virtual void operator()(text_render_thunk const &thunk) { - text_renderer_type ren(pixmap_, thunk.comp_op_, common_.scale_factor_); + tex_.set_comp_op(thunk.comp_op_); + value_integer feature_id = feature_.id(); - render_offset_placements( - thunk.placements_, - offset_, - [&] (glyph_positions_ptr const& glyphs) - { - marker_info_ptr mark = glyphs->get_marker(); - if (mark) - { - ren_.render_marker(feature_, - glyphs->marker_pos(), - *mark->marker_, - mark->transform_, - thunk.opacity_, thunk.comp_op_); - } - ren.render(*glyphs, feature_id); - }); - pixmap_.add_feature(feature_); - } + for (auto const& glyphs : thunk.placements_) + { + scoped_glyph_positions_offset tmp_off(*glyphs, offset_); - template - void operator()(T1 const &) const - { - // TODO: warning if unimplemented? + if (auto const& mark = glyphs->get_marker()) + { + ren_.render_marker(feature_, + glyphs->marker_pos(), + *mark->marker_, + mark->transform_, + thunk.opacity_, thunk.comp_op_); + } + tex_.render(*glyphs, feature_id); + } + + pixmap_.add_feature(feature_); } private: @@ -158,7 +140,7 @@ private: buffer_type &pixmap_; renderer_common &common_; feature_impl &feature_; - pixel_position offset_; + text_renderer_type tex_; }; template @@ -166,16 +148,11 @@ void grid_renderer::process(group_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + thunk_renderer ren(*this, *ras_ptr, pixmap_, common_, feature); + render_group_symbolizer( sym, feature, common_.vars_, prj_trans, common_.query_extent_, common_, - [&](render_thunk_list const& thunks, pixel_position const& render_offset) - { - thunk_renderer ren(*this, *ras_ptr, pixmap_, common_, feature, render_offset); - for (render_thunk_ptr const& thunk : thunks) - { - util::apply_visitor(ren, *thunk); - } - }); + ren); } template void grid_renderer::process(group_symbolizer const&, diff --git a/include/mapnik/renderer_common/process_group_symbolizer.hpp b/src/renderer_common/render_group_symbolizer.cpp similarity index 79% rename from include/mapnik/renderer_common/process_group_symbolizer.hpp rename to src/renderer_common/render_group_symbolizer.cpp index 1c9de13c2..9892dfc8d 100644 --- a/include/mapnik/renderer_common/process_group_symbolizer.hpp +++ b/src/renderer_common/render_group_symbolizer.cpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2015 Artem Pavlenko + * Copyright (C) 2016 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,72 +20,32 @@ * *****************************************************************************/ -#ifndef MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP -#define MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP - // mapnik -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include #include -#include +#include +#include #include namespace mapnik { -template -void render_offset_placements(placements_list const& placements, - pixel_position const& offset, - F render_text) { - - for (auto const& glyphs : placements) - { - // move the glyphs to the correct offset - pixel_position base_point = glyphs->get_base_point(); - glyphs->set_base_point(base_point + offset); - - // update the position of any marker - marker_info_ptr marker_info = glyphs->get_marker(); - pixel_position marker_pos = glyphs->marker_pos(); - if (marker_info) - { - glyphs->set_marker(marker_info, marker_pos + offset); - } - - render_text(glyphs); - - // Need to put the base_point back how it was in case something else calls this again - // (don't want to add offset twice) or calls with a different offset. - glyphs->set_base_point(base_point); - if (marker_info) - { - glyphs->set_marker(marker_info, marker_pos); - } - } -} - -template void render_group_symbolizer(group_symbolizer const& sym, feature_impl & feature, attributes const& vars, proj_transform const& prj_trans, box2d const& clipping_extent, renderer_common & common, - F render_thunks) + render_thunk_list_dispatch & render_thunks) { // find all column names referenced in the group rules and symbolizers std::set columns; group_attribute_collector column_collector(columns, false); column_collector(sym); - group_symbolizer_properties_ptr props = get(sym, keys::group_properties); + auto props = get(sym, keys::group_properties); // create a new context for the sub features of this group context_ptr sub_feature_ctx = std::make_shared(); @@ -107,10 +67,10 @@ void render_group_symbolizer(group_symbolizer const& sym, // keep track of which lists of render thunks correspond to // entries in the group_layout_manager. std::vector layout_thunks; - size_t num_layout_thunks = 0; // layout manager to store and arrange bboxes of matched features - group_layout_manager layout_manager(props->get_layout(), pixel_position(common.width_ / 2.0, common.height_ / 2.0)); + group_layout_manager layout_manager(props->get_layout()); + layout_manager.set_input_origin(common.width_ * 0.5, common.height_ * 0.5); // run feature or sub feature through the group rules & symbolizers // for each index value in the range @@ -184,7 +144,6 @@ void render_group_symbolizer(group_symbolizer const& sym, // add the bounding box to the layout manager layout_manager.add_member_bound_box(bounds); layout_thunks.emplace_back(std::move(thunks)); - ++num_layout_thunks; break; } } @@ -220,18 +179,16 @@ void render_group_symbolizer(group_symbolizer const& sym, helper.add_box_element(layout_manager.offset_box_at(i), rpt_key_value); } - pixel_position_list positions = helper.get(); + pixel_position_list const& positions = helper.get(); for (pixel_position const& pos : positions) { - for (size_t layout_i = 0; layout_i < num_layout_thunks; ++layout_i) + for (size_t layout_i = 0; layout_i < layout_thunks.size(); ++layout_i) { pixel_position const& offset = layout_manager.offset_at(layout_i); pixel_position render_offset = pos + offset; - render_thunks(layout_thunks[layout_i], render_offset); + render_thunks.render_list(layout_thunks[layout_i], render_offset); } } } } // namespace mapnik - -#endif // MAPNIK_RENDERER_COMMON_PROCESS_GROUP_SYMBOLIZER_HPP diff --git a/src/text/glyph_positions.cpp b/src/text/glyph_positions.cpp index da3b30084..fdcb3a811 100644 --- a/src/text/glyph_positions.cpp +++ b/src/text/glyph_positions.cpp @@ -74,7 +74,7 @@ void glyph_positions::set_marker(marker_info_ptr mark, pixel_position const& mar marker_pos_ = marker_pos; } -marker_info_ptr glyph_positions::get_marker() const +marker_info_ptr const& glyph_positions::get_marker() const { return marker_info_; } diff --git a/src/text/renderer.cpp b/src/text/renderer.cpp index 227c35dbe..163d11c6f 100644 --- a/src/text/renderer.cpp +++ b/src/text/renderer.cpp @@ -60,7 +60,9 @@ void text_renderer::prepare_glyphs(glyph_positions const& positions) FT_Vector pen; FT_Error error; + glyphs_.clear(); glyphs_.reserve(positions.size()); + for (auto const& glyph_pos : positions) { glyph_info const& glyph = glyph_pos.glyph; @@ -121,7 +123,6 @@ agg_text_renderer::agg_text_renderer (pixmap_type & pixmap, template void agg_text_renderer::render(glyph_positions const& pos) { - glyphs_.clear(); prepare_glyphs(pos); FT_Error error; FT_Vector start; @@ -232,7 +233,6 @@ void agg_text_renderer::render(glyph_positions const& pos) template void grid_text_renderer::render(glyph_positions const& pos, value_integer feature_id) { - glyphs_.clear(); prepare_glyphs(pos); FT_Error error; FT_Vector start;