noncopyable renderer_common (needed for upcoming font work)

This commit is contained in:
Dane Springmeyer 2014-09-24 22:46:19 -07:00
parent a26a82dc12
commit 60a55cb48b
5 changed files with 38 additions and 23 deletions

View file

@ -28,6 +28,7 @@
#include <mapnik/box2d.hpp> // for box2d
#include <mapnik/view_transform.hpp> // for view_transform
#include <mapnik/attribute.hpp>
#include <mapnik/noncopyable.hpp>
// fwd declarations to speed up compile
namespace mapnik {
@ -39,7 +40,7 @@ namespace mapnik {
namespace mapnik {
struct renderer_common
struct renderer_common : private mapnik::noncopyable
{
renderer_common(Map const &m, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor);
@ -48,7 +49,6 @@ struct renderer_common
std::shared_ptr<label_collision_detector4> detector);
renderer_common(request const &req, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor);
renderer_common(renderer_common const& other);
unsigned width_;
unsigned height_;

View file

@ -38,6 +38,7 @@
#include <mapnik/util/conversions.hpp>
#include <mapnik/util/variant.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/noncopyable.hpp>
// agg
#include <agg_trans_affine.h>
@ -48,6 +49,35 @@ class proj_transform;
struct glyph_info;
class text_symbolizer_helper;
struct virtual_renderer_common : private mapnik::noncopyable
{
virtual_renderer_common(renderer_common & common) :
width_(common.width_),
height_(common.height_),
scale_factor_(common.scale_factor_),
vars_(common.vars_),
shared_font_engine_(common.shared_font_engine_),
font_engine_(*shared_font_engine_),
font_manager_(common.font_manager_),
query_extent_(common.query_extent_),
t_(common.t_),
detector_(std::make_shared<label_collision_detector4>(common.detector_->extent())) {}
unsigned & width_;
unsigned & height_;
double & scale_factor_;
attributes & vars_;
// TODO: dirty hack for cairo renderer, figure out how to remove this
std::shared_ptr<freetype_engine> & shared_font_engine_;
freetype_engine & font_engine_;
face_manager<freetype_engine> & font_manager_;
box2d<double> & query_extent_;
view_transform & t_;
std::shared_ptr<label_collision_detector4> detector_;
};
// General:
// The approach here is to run the normal symbolizers, but in
@ -117,7 +147,7 @@ struct render_thunk_extractor : public util::static_visitor<>
feature_impl & feature,
attributes const& vars,
proj_transform const& prj_trans,
renderer_common & common,
virtual_renderer_common & common,
box2d<double> const& clipping_extent);
void operator()(point_symbolizer const& sym) const;
@ -140,7 +170,7 @@ private:
feature_impl & feature_;
attributes const& vars_;
proj_transform const& prj_trans_;
renderer_common & common_;
virtual_renderer_common & common_;
box2d<double> clipping_extent_;
void update_box() const;
@ -211,8 +241,7 @@ void render_group_symbolizer(group_symbolizer const& sym,
// create a copied 'virtual' common renderer for processing sub feature symbolizers
// create an empty detector for it, so we are sure we won't hit anything
renderer_common virtual_renderer(common);
virtual_renderer.detector_ = std::make_shared<label_collision_detector4>(common.detector_->extent());
virtual_renderer_common virtual_renderer(common);
// keep track of which lists of render thunks correspond to
// entries in the group_layout_manager.

View file

@ -32,11 +32,11 @@
namespace mapnik {
template <typename F>
template <typename F,typename RendererType>
void render_point_symbolizer(point_symbolizer const &sym,
mapnik::feature_impl &feature,
proj_transform const &prj_trans,
renderer_common &common,
RendererType &common,
F render_marker)
{
std::string filename = get<std::string>(sym, keys::file, feature, common.vars_);

View file

@ -73,18 +73,4 @@ renderer_common::renderer_common(request const &req, attributes const& vars, uns
req.width() + req.buffer_size() ,req.height() + req.buffer_size())))
{}
renderer_common::renderer_common(renderer_common const &other)
: width_(other.width_),
height_(other.height_),
scale_factor_(other.scale_factor_),
vars_(other.vars_),
shared_font_engine_(other.shared_font_engine_),
font_engine_(*shared_font_engine_),
font_manager_(font_engine_),
query_extent_(),
t_(other.t_),
detector_(other.detector_)
{
}
}

View file

@ -76,7 +76,7 @@ render_thunk_extractor::render_thunk_extractor(box2d<double> & box,
feature_impl & feature,
attributes const& vars,
proj_transform const& prj_trans,
renderer_common & common,
virtual_renderer_common & common,
box2d<double> const& clipping_extent)
: box_(box), thunks_(thunks), feature_(feature), vars_(vars), prj_trans_(prj_trans),
common_(common), clipping_extent_(clipping_extent)