Merge branch 'compositing' of github.com:mapnik/mapnik into compositing
This commit is contained in:
commit
d0f0d0b35d
8 changed files with 61 additions and 23 deletions
|
@ -80,6 +80,8 @@ public:
|
|||
void start_map_processing(Map const& map);
|
||||
void start_layer_processing(layer const& lay, box2d<double> const& query_extent);
|
||||
void end_layer_processing(layer const& lay);
|
||||
void start_style_processing(feature_type_style const& st);
|
||||
void end_style_processing(feature_type_style const& st);
|
||||
void process(point_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans);
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
// stl
|
||||
#include <string>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
@ -64,7 +66,7 @@ enum composite_mode_e
|
|||
invert_rgb
|
||||
};
|
||||
|
||||
composite_mode_e comp_op_from_string(std::string const& name);
|
||||
boost::optional<composite_mode_e> comp_op_from_string(std::string const& name);
|
||||
|
||||
template <typename T1, typename T2>
|
||||
void composite(T1 & im, T2 & im2, composite_mode_e mode);
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
//if (out_value < 0) out_value = 0;
|
||||
//if (out_value > 255) out_value = 255;
|
||||
|
||||
// embose
|
||||
// emboss
|
||||
// -2 -1 0
|
||||
// -1 1 1
|
||||
// 0 1 2
|
||||
|
@ -121,14 +121,14 @@ using namespace boost::gil;
|
|||
namespace mapnik { namespace filter { namespace detail {
|
||||
|
||||
static const float blur_matrix[] = {0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111,0.1111};
|
||||
static const float embose_matrix[] = {-2,-1,0,-1,1,1,0,1,2};
|
||||
static const float emboss_matrix[] = {-2,-1,0,-1,1,1,0,1,2};
|
||||
static const float sharpen_matrix[] = {0,-1,0,-1,5,-1,0,-1,0 };
|
||||
static const float edge_detect_matrix[] = {0,1,0,1,-4,1,0,1,0 };
|
||||
|
||||
}
|
||||
|
||||
struct blur {};
|
||||
struct embose {};
|
||||
struct emboss {};
|
||||
struct sharpen {};
|
||||
struct edge_detect {};
|
||||
struct sobel {};
|
||||
|
@ -172,9 +172,9 @@ void process_channel (Src const& src, Dst & dst, mapnik::filter::blur)
|
|||
}
|
||||
|
||||
template <typename Src, typename Dst>
|
||||
void process_channel (Src const& src, Dst & dst, mapnik::filter::embose)
|
||||
void process_channel (Src const& src, Dst & dst, mapnik::filter::emboss)
|
||||
{
|
||||
process_channel_impl(src,dst,mapnik::filter::detail::embose_matrix);
|
||||
process_channel_impl(src,dst,mapnik::filter::detail::emboss_matrix);
|
||||
}
|
||||
|
||||
template <typename Src, typename Dst>
|
||||
|
@ -385,7 +385,7 @@ void apply_filter(Src & src, invert)
|
|||
typedef boost::variant<filter::blur,
|
||||
filter::gray,
|
||||
filter::agg_stack_blur,
|
||||
filter::embose,
|
||||
filter::emboss,
|
||||
filter::sharpen,
|
||||
filter::edge_detect,
|
||||
filter::sobel,
|
||||
|
|
|
@ -54,7 +54,7 @@ struct image_filter_grammar :
|
|||
start = -(filter % no_skip[*char_("; ")])
|
||||
;
|
||||
filter =
|
||||
lit("embose")[push_back(_val,construct<mapnik::filter::embose>())]
|
||||
lit("emboss")[push_back(_val,construct<mapnik::filter::emboss>())]
|
||||
|
|
||||
lit("blur")[push_back(_val,construct<mapnik::filter::blur>())]
|
||||
|
|
||||
|
|
|
@ -721,6 +721,20 @@ void cairo_renderer_base::start_map_processing(Map const& map)
|
|||
#endif
|
||||
}
|
||||
|
||||
void cairo_renderer_base::start_style_processing(feature_type_style const& st)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "start style processing\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void cairo_renderer_base::end_style_processing(feature_type_style const& st)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "end style processing\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
void cairo_renderer_base::process(polygon_symbolizer const& sym,
|
||||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
|
|
|
@ -36,16 +36,16 @@ IMPLEMENT_ENUM( filter_mode_e, filter_mode_strings )
|
|||
|
||||
feature_type_style::feature_type_style()
|
||||
: filter_mode_(FILTER_ALL),
|
||||
scale_denom_validity_(-1),
|
||||
filters_(),
|
||||
comp_op_(clear)
|
||||
comp_op_(clear),
|
||||
scale_denom_validity_(-1)
|
||||
{}
|
||||
|
||||
feature_type_style::feature_type_style(feature_type_style const& rhs, bool deep_copy)
|
||||
: filter_mode_(rhs.filter_mode_),
|
||||
scale_denom_validity_(-1),
|
||||
filters_(rhs.filters_),
|
||||
comp_op_(rhs.comp_op_)
|
||||
comp_op_(rhs.comp_op_),
|
||||
scale_denom_validity_(-1)
|
||||
{
|
||||
if (!deep_copy) {
|
||||
rules_ = rhs.rules_;
|
||||
|
@ -62,9 +62,9 @@ feature_type_style& feature_type_style::operator=(feature_type_style const& rhs)
|
|||
{
|
||||
if (this == &rhs) return *this;
|
||||
rules_=rhs.rules_;
|
||||
scale_denom_validity_ = -1;
|
||||
filters_ = rhs.filters_;
|
||||
comp_op_ = rhs.comp_op_;
|
||||
scale_denom_validity_ = -1;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -69,14 +69,15 @@ static const comp_op_lookup_type comp_lookup = boost::assign::list_of<comp_op_lo
|
|||
(invert,"invert")
|
||||
(invert_rgb,"invert_rgb");
|
||||
|
||||
composite_mode_e comp_op_from_string(std::string const& name)
|
||||
boost::optional<composite_mode_e> comp_op_from_string(std::string const& name)
|
||||
{
|
||||
boost::optional<composite_mode_e> mode;
|
||||
comp_op_lookup_type::right_const_iterator right_iter = comp_lookup.right.find(name);
|
||||
if (right_iter != comp_lookup.right.end())
|
||||
{
|
||||
return right_iter->second;
|
||||
mode.reset(right_iter->second);
|
||||
}
|
||||
return clear;
|
||||
return mode;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2>
|
||||
|
|
|
@ -418,22 +418,34 @@ void map_parser::parse_style(Map & map, xml_node const& sty)
|
|||
optional<std::string> comp_op_name = sty.get_opt_attr<std::string>("comp-op");
|
||||
if (comp_op_name)
|
||||
{
|
||||
composite_mode_e comp_op = comp_op_from_string(*comp_op_name);
|
||||
style.set_comp_op(comp_op);
|
||||
optional<composite_mode_e> comp_op = comp_op_from_string(*comp_op_name);
|
||||
if (comp_op)
|
||||
{
|
||||
style.set_comp_op(*comp_op);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw config_error("failed to parse comp-op: '" + *comp_op_name + "'");
|
||||
}
|
||||
}
|
||||
|
||||
// image filters
|
||||
optional<std::string> filters = sty.get_opt_attr<std::string>("image-filters");
|
||||
if (filters)
|
||||
{
|
||||
std::string::const_iterator itr = (*filters).begin();
|
||||
std::string::const_iterator end = (*filters).end();
|
||||
std::string filter_mode = *filters;
|
||||
if (filter_mode.empty())
|
||||
{
|
||||
throw config_error("failed to parse empty image-filter");
|
||||
}
|
||||
std::string::const_iterator itr = filter_mode.begin();
|
||||
std::string::const_iterator end = filter_mode.end();
|
||||
mapnik::image_filter_grammar<std::string::const_iterator,std::vector<mapnik::filter::filter_type> > g;
|
||||
|
||||
bool result = boost::spirit::qi::phrase_parse(itr,end, g, boost::spirit::qi::ascii::space, style.image_filters());
|
||||
if (!result || itr!=end)
|
||||
{
|
||||
throw config_error("failed to parse:" + std::string(itr,end));
|
||||
throw config_error("failed to parse image-filter: '" + std::string(itr,end) + "'");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,8 +776,15 @@ void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node c
|
|||
optional<std::string> comp_op_name = pt.get_opt_attr<std::string>("comp-op");
|
||||
if (comp_op_name)
|
||||
{
|
||||
composite_mode_e comp_op = comp_op_from_string(*comp_op_name);
|
||||
sym.set_comp_op(comp_op);
|
||||
optional<composite_mode_e> comp_op = comp_op_from_string(*comp_op_name);
|
||||
if (comp_op)
|
||||
{
|
||||
sym.set_comp_op(*comp_op);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw config_error("failed to parse comp-op: '" + *comp_op_name + "'");
|
||||
}
|
||||
}
|
||||
|
||||
optional<std::string> transform_wkt = pt.get_opt_attr<std::string>("transform");
|
||||
|
|
Loading…
Reference in a new issue