derive virtual_renderer_common from renderer_common

This commit is contained in:
Mickey Rose 2016-01-26 21:18:00 +01:00
parent 844021a892
commit 8a55eefbb5
7 changed files with 41 additions and 39 deletions

View file

@ -42,13 +42,16 @@ namespace mapnik {
struct renderer_common : private util::noncopyable
{
using detector_ptr = std::shared_ptr<label_collision_detector4>;
renderer_common(Map const &m, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor);
renderer_common(Map const &m, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor,
std::shared_ptr<label_collision_detector4> detector);
detector_ptr detector);
renderer_common(Map const &m, request const &req, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor);
~renderer_common();
unsigned width_;
unsigned height_;
@ -60,11 +63,18 @@ struct renderer_common : private util::noncopyable
face_manager_freetype font_manager_;
box2d<double> query_extent_;
view_transform t_;
std::shared_ptr<label_collision_detector4> detector_;
detector_ptr detector_;
protected:
// it's desirable to keep this class implicitly noncopyable to prevent
// inadvertent copying from other places;
// this copy constructor is therefore protected and should only be used
// by virtual_renderer_common
renderer_common(renderer_common const& other);
private:
renderer_common(Map const &m, unsigned width, unsigned height, double scale_factor,
attributes const& vars, view_transform &&t, std::shared_ptr<label_collision_detector4> detector);
attributes const& vars, view_transform && t, detector_ptr detector);
};
}

View file

@ -44,22 +44,9 @@ namespace mapnik {
// being able to interpose our own decisions about whether
// a collision has occurred or not.
struct virtual_renderer_common : private util::noncopyable
struct virtual_renderer_common : renderer_common
{
virtual_renderer_common(renderer_common & common);
~virtual_renderer_common();
unsigned & width_;
unsigned & height_;
double & scale_factor_;
attributes & vars_;
// TODO: dirty hack for cairo renderer, figure out how to remove this
std::shared_ptr<font_library> & shared_font_library_;
font_library & font_library_;
face_manager_freetype & font_manager_;
box2d<double> & query_extent_;
view_transform & t_;
std::unique_ptr<label_collision_detector4> detector_;
explicit virtual_renderer_common(renderer_common const& other);
};
// Base class for extracting the bounding boxes associated with placing

View file

@ -30,7 +30,6 @@
#include <mapnik/symbolizer.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/parse_path.hpp>
#include <mapnik/pixel_position.hpp>
#include <mapnik/renderer_common/process_point_symbolizer.hpp>

View file

@ -30,7 +30,6 @@
#include <mapnik/grid/grid.hpp>
#include <mapnik/geom_util.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/marker.hpp>
#include <mapnik/marker_cache.hpp>
#include <mapnik/parse_path.hpp>

View file

@ -29,10 +29,24 @@
namespace mapnik {
// copy constructor exclusively for virtual_renderer_common
renderer_common::renderer_common(renderer_common const& other)
: width_(other.width_),
height_(other.height_),
scale_factor_(other.scale_factor_),
vars_(other.vars_),
shared_font_library_(other.shared_font_library_),
font_library_(other.font_library_),
font_manager_(other.font_manager_),
query_extent_(other.query_extent_),
t_(other.t_),
detector_(other.detector_)
{}
renderer_common::renderer_common(Map const& map, unsigned width, unsigned height, double scale_factor,
attributes const& vars,
view_transform && t,
std::shared_ptr<label_collision_detector4> detector)
detector_ptr detector)
: width_(width),
height_(height),
scale_factor_(scale_factor),
@ -57,7 +71,7 @@ renderer_common::renderer_common(Map const &m, attributes const& vars, unsigned
renderer_common::renderer_common(Map const &m, attributes const& vars, unsigned offset_x, unsigned offset_y,
unsigned width, unsigned height, double scale_factor,
std::shared_ptr<label_collision_detector4> detector)
detector_ptr detector)
: renderer_common(m, width, height, scale_factor,
vars,
view_transform(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y),
@ -74,4 +88,10 @@ renderer_common::renderer_common(Map const &m, request const &req, attributes co
req.width() + req.buffer_size() ,req.height() + req.buffer_size())))
{}
renderer_common::~renderer_common()
{
// defined in .cpp to make this destructible elsewhere without
// having to #include <mapnik/label_collision_detector.hpp>
}
}

View file

@ -29,23 +29,11 @@
namespace mapnik {
virtual_renderer_common::virtual_renderer_common(renderer_common & common)
: width_(common.width_),
height_(common.height_),
scale_factor_(common.scale_factor_),
vars_(common.vars_),
shared_font_library_(common.shared_font_library_),
font_library_(*shared_font_library_),
font_manager_(common.font_manager_),
query_extent_(common.query_extent_),
t_(common.t_),
detector_(new label_collision_detector4(common.detector_->extent()))
{}
virtual_renderer_common::~virtual_renderer_common()
virtual_renderer_common::virtual_renderer_common(renderer_common const& other)
: renderer_common(other)
{
// defined in .cpp to make this destructible elsewhere without
// having to #include <mapnik/label_collision_detector.hpp>
// replace collision detector with my own so that I don't pollute the original
detector_ = std::make_shared<label_collision_detector4>(other.detector_->extent());
}
namespace detail {

View file

@ -27,7 +27,6 @@
#include <mapnik/svg/output/svg_renderer.hpp>
#include <mapnik/map.hpp>
#include <mapnik/layer.hpp>
#include <mapnik/label_collision_detector.hpp>
#include <mapnik/feature_type_style.hpp>
#include <mapnik/font_set.hpp>