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
This commit is contained in:
parent
9d7b3d00e1
commit
a7ecabcde3
11 changed files with 234 additions and 199 deletions
4
Makefile
4
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)
|
||||
|
|
66
include/mapnik/renderer_common/render_group_symbolizer.hpp
Normal file
66
include/mapnik/renderer_common/render_group_symbolizer.hpp
Normal file
|
@ -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 <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
#include <mapnik/renderer_common/render_thunk.hpp>
|
||||
#include <mapnik/symbolizer_base.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
|
||||
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<double> const& clipping_extent,
|
||||
renderer_common & common,
|
||||
render_thunk_list_dispatch & render_thunks);
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_RENDERER_COMMON_RENDER_GROUP_SYMBOLIZER_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 <mapnik/box2d.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
|
@ -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<glyph_position> data_;
|
||||
|
@ -88,8 +90,46 @@ private:
|
|||
pixel_position marker_pos_;
|
||||
box2d<double> bbox_;
|
||||
};
|
||||
|
||||
using glyph_positions_ptr = std::unique_ptr<glyph_positions>;
|
||||
|
||||
using placements_list = std::list<glyph_positions_ptr>;
|
||||
}
|
||||
#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
|
||||
|
|
|
@ -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<glyph_t>;
|
||||
void prepare_glyphs(glyph_positions const& positions);
|
||||
|
|
|
@ -25,20 +25,16 @@
|
|||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/agg_render_marker.hpp>
|
||||
#include <mapnik/image_util.hpp>
|
||||
#include <mapnik/image.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/text/renderer.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/renderer_common/process_group_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
#include <mapnik/renderer_common/render_group_symbolizer.hpp>
|
||||
#include <mapnik/svg/svg_renderer_agg.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_converter.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_trans_affine.h"
|
||||
|
||||
|
@ -55,7 +51,7 @@ template <typename T>
|
|||
struct thunk_renderer;
|
||||
|
||||
template <>
|
||||
struct thunk_renderer<image_rgba8>
|
||||
struct thunk_renderer<image_rgba8> : render_thunk_list_dispatch
|
||||
{
|
||||
using renderer_type = agg_renderer<image_rgba8>;
|
||||
using buffer_type = renderer_type::buffer_type;
|
||||
|
@ -64,12 +60,13 @@ struct thunk_renderer<image_rgba8>
|
|||
thunk_renderer(renderer_type &ren,
|
||||
std::unique_ptr<rasterizer> 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<agg::rgba8, agg::order_rgba>; // comp blender
|
||||
using buf_type = agg::rendering_buffer;
|
||||
|
@ -95,7 +92,7 @@ struct thunk_renderer<image_rgba8>
|
|||
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<agg::rgba8, agg::order_rgba>; // comp blender
|
||||
using buf_type = agg::rendering_buffer;
|
||||
|
@ -113,32 +110,25 @@ struct thunk_renderer<image_rgba8>
|
|||
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 <typename T>
|
||||
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<rasterizer> const& ras_ptr_;
|
||||
buffer_type *buf_;
|
||||
renderer_common &common_;
|
||||
pixel_position offset_;
|
||||
text_renderer_type tex_;
|
||||
};
|
||||
|
||||
template <typename T0, typename T1>
|
||||
|
@ -154,16 +144,11 @@ void agg_renderer<T0,T1>::process(group_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
thunk_renderer<buffer_type> 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<buffer_type> 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<image_rgba8>::process(group_symbolizer const&,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
// mapnik
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/make_unique.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/cairo/cairo_renderer.hpp>
|
||||
#include <mapnik/cairo/cairo_render_vector.hpp>
|
||||
|
||||
// mapnik symbolizer generics
|
||||
#include <mapnik/renderer_common/process_group_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/render_group_symbolizer.hpp>
|
||||
|
||||
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 <typename T>
|
||||
struct thunk_renderer
|
||||
struct thunk_renderer : render_thunk_list_dispatch
|
||||
{
|
||||
using renderer_type = cairo_renderer<T>;
|
||||
|
||||
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 <typename T0>
|
||||
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<T>::process(group_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
thunk_renderer<T> 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<T> 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<cairo_ptr>::process(group_symbolizer const&,
|
||||
|
|
|
@ -29,25 +29,13 @@
|
|||
#include <mapnik/grid/grid_renderer_base.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
#include <mapnik/grid/grid_render_marker.hpp>
|
||||
#include <mapnik/attribute_collector.hpp>
|
||||
#include <mapnik/text/placement_finder.hpp>
|
||||
#include <mapnik/text/symbolizer_helpers.hpp>
|
||||
#include <mapnik/text/renderer.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/svg/svg_renderer_agg.hpp>
|
||||
#include <mapnik/svg/svg_storage.hpp>
|
||||
#include <mapnik/svg/svg_path_adapter.hpp>
|
||||
#include <mapnik/svg/svg_path_attributes.hpp>
|
||||
#include <mapnik/group/group_layout_manager.hpp>
|
||||
#include <mapnik/group/group_symbolizer_helper.hpp>
|
||||
#include <mapnik/util/variant.hpp>
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/label_collision_detector.hpp>
|
||||
|
||||
#include <mapnik/geom_util.hpp>
|
||||
#include <mapnik/renderer_common/process_point_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/process_group_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/render_group_symbolizer.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_trans_affine.h"
|
||||
|
@ -61,7 +49,7 @@ namespace mapnik {
|
|||
* in the detector from the placement_finder.
|
||||
*/
|
||||
template <typename T0>
|
||||
struct thunk_renderer
|
||||
struct thunk_renderer : render_thunk_list_dispatch
|
||||
{
|
||||
using renderer_type = grid_renderer<T0>;
|
||||
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 <typename T1>
|
||||
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 <typename T>
|
||||
|
@ -166,16 +148,11 @@ void grid_renderer<T>::process(group_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
thunk_renderer<T> 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<T> 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<grid>::process(group_symbolizer const&,
|
||||
|
|
|
@ -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 <mapnik/pixel_position.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
#include <mapnik/renderer_common/render_thunk_extractor.hpp>
|
||||
#include <mapnik/symbolizer.hpp>
|
||||
#include <mapnik/attribute_collector.hpp>
|
||||
#include <mapnik/feature_factory.hpp>
|
||||
#include <mapnik/group/group_layout_manager.hpp>
|
||||
#include <mapnik/group/group_symbolizer_helper.hpp>
|
||||
#include <mapnik/group/group_symbolizer_properties.hpp>
|
||||
#include <mapnik/text/glyph_positions.hpp>
|
||||
#include <mapnik/renderer_common/render_group_symbolizer.hpp>
|
||||
#include <mapnik/renderer_common/render_thunk_extractor.hpp>
|
||||
#include <mapnik/util/conversions.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename F>
|
||||
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 <typename F>
|
||||
void render_group_symbolizer(group_symbolizer const& sym,
|
||||
feature_impl & feature,
|
||||
attributes const& vars,
|
||||
proj_transform const& prj_trans,
|
||||
box2d<double> 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<std::string> columns;
|
||||
group_attribute_collector column_collector(columns, false);
|
||||
column_collector(sym);
|
||||
|
||||
group_symbolizer_properties_ptr props = get<group_symbolizer_properties_ptr>(sym, keys::group_properties);
|
||||
auto props = get<group_symbolizer_properties_ptr>(sym, keys::group_properties);
|
||||
|
||||
// create a new context for the sub features of this group
|
||||
context_ptr sub_feature_ctx = std::make_shared<mapnik::context_type>();
|
||||
|
@ -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<render_thunk_list> 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
|
|
@ -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_;
|
||||
}
|
||||
|
|
|
@ -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<T>::agg_text_renderer (pixmap_type & pixmap,
|
|||
template <typename T>
|
||||
void agg_text_renderer<T>::render(glyph_positions const& pos)
|
||||
{
|
||||
glyphs_.clear();
|
||||
prepare_glyphs(pos);
|
||||
FT_Error error;
|
||||
FT_Vector start;
|
||||
|
@ -232,7 +233,6 @@ void agg_text_renderer<T>::render(glyph_positions const& pos)
|
|||
template <typename T>
|
||||
void grid_text_renderer<T>::render(glyph_positions const& pos, value_integer feature_id)
|
||||
{
|
||||
glyphs_.clear();
|
||||
prepare_glyphs(pos);
|
||||
FT_Error error;
|
||||
FT_Vector start;
|
||||
|
|
Loading…
Reference in a new issue