Merge branch 'master' of github.com:mapnik/mapnik

This commit is contained in:
Dane Springmeyer 2013-02-27 19:18:52 -05:00
commit 0404f17f27
3 changed files with 50 additions and 13 deletions

View file

@ -25,10 +25,12 @@
// boost // boost
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
// mapnik
#include <mapnik/css_color_grammar.hpp>
// stl // stl
#include <vector> #include <vector>
namespace mapnik { namespace mapnik {
namespace qi = boost::spirit::qi; namespace qi = boost::spirit::qi;
@ -41,10 +43,12 @@ struct image_filter_grammar :
qi::rule<Iterator, ContType(), qi::ascii::space_type> start; qi::rule<Iterator, ContType(), qi::ascii::space_type> start;
qi::rule<Iterator, ContType(), qi::ascii::space_type> filter; qi::rule<Iterator, ContType(), qi::ascii::space_type> filter;
qi::rule<Iterator, qi::locals<int,int>, void(ContType&), qi::ascii::space_type> agg_blur_filter; qi::rule<Iterator, qi::locals<int,int>, void(ContType&), qi::ascii::space_type> agg_blur_filter;
qi::rule<Iterator, qi::locals<std::string>, void(ContType&), qi::ascii::space_type> hsla_filter; qi::rule<Iterator, qi::locals<double,double,double,double,double,double,double,double>,
qi::rule<Iterator, std::string(), qi::ascii::space_type> string_arg; void(ContType&), qi::ascii::space_type> hsla_filter;
qi::rule<Iterator, qi::locals<mapnik::color,mapnik::color>, void(ContType&), qi::ascii::space_type> colorize_alpha_filter;
qi::rule<Iterator, qi::ascii::space_type> no_args; qi::rule<Iterator, qi::ascii::space_type> no_args;
qi::uint_parser< unsigned, 10, 1, 3 > radius_; qi::uint_parser< unsigned, 10, 1, 3 > radius_;
css_color_grammar<Iterator> css_color_;
}; };
} }

View file

@ -25,10 +25,10 @@
// mapnik // mapnik
#include <mapnik/config.hpp> #include <mapnik/config.hpp>
#include <mapnik/color.hpp>
// boost // boost
#include <boost/variant.hpp>
#include <boost/variant/variant_fwd.hpp> #include <boost/variant/variant_fwd.hpp>
// stl // stl
#include <vector> #include <vector>
#include <ostream> #include <ostream>
@ -56,9 +56,21 @@ struct agg_stack_blur
struct hsla struct hsla
{ {
hsla(std::string const& tint_string) hsla(double h0, double h1,
: tinter(tint_string) {} double s0, double s1,
std::string tinter; double l0, double l1,
double a0, double a1)
{
// TODO: implement me!
}
};
struct colorize_alpha
{
colorize_alpha(mapnik::color const& c0, mapnik::color const& c1)
{
// TODO: implement me!
}
}; };
typedef boost::variant<filter::blur, typedef boost::variant<filter::blur,
@ -71,7 +83,8 @@ typedef boost::variant<filter::blur,
filter::x_gradient, filter::x_gradient,
filter::y_gradient, filter::y_gradient,
filter::invert, filter::invert,
filter::hsla> filter_type; filter::hsla,
filter::colorize_alpha> filter_type;
inline std::ostream& operator<< (std::ostream& os, blur) inline std::ostream& operator<< (std::ostream& os, blur)
{ {
@ -93,7 +106,7 @@ inline std::ostream& operator<< (std::ostream& os, agg_stack_blur const& filter)
inline std::ostream& operator<< (std::ostream& os, hsla const& filter) inline std::ostream& operator<< (std::ostream& os, hsla const& filter)
{ {
os << "hsla(" << filter.tinter << ')'; os << "hsla(" << "TODO" << ')';
return os; return os;
} }

View file

@ -44,10 +44,17 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
using qi::_1; using qi::_1;
using qi::_a; using qi::_a;
using qi::_b; using qi::_b;
using qi::_c;
using qi::_d;
using qi::_e;
using qi::_f;
using qi::_g;
using qi::_h;
using qi::_r1; using qi::_r1;
using qi::eps; using qi::eps;
using qi::char_; using qi::char_;
using qi::lexeme; using qi::lexeme;
using qi::double_;
using boost::spirit::ascii::string; using boost::spirit::ascii::string;
using phoenix::push_back; using phoenix::push_back;
using phoenix::construct; using phoenix::construct;
@ -83,6 +90,8 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
agg_blur_filter(_val) agg_blur_filter(_val)
| |
hsla_filter(_val) hsla_filter(_val)
|
colorize_alpha_filter(_val)
; ;
agg_blur_filter = lit("agg-stack-blur")[_a = 1, _b = 1] agg_blur_filter = lit("agg-stack-blur")[_a = 1, _b = 1]
@ -92,11 +101,22 @@ image_filter_grammar<Iterator,ContType>::image_filter_grammar()
[push_back(_r1,construct<mapnik::filter::agg_stack_blur>(_a,_b))] [push_back(_r1,construct<mapnik::filter::agg_stack_blur>(_a,_b))]
; ;
hsla_filter = (lit("hsla") >> lit('(') >> string_arg[_a = _1] >> lit(')')) hsla_filter = lit("hsla")
[push_back(_r1,construct<mapnik::filter::hsla>(_a))] >> lit('(')
>> double_[_a = _1] >> lit('x') >> double_[_b = _1] >> lit(';')
>> double_[_c = _1] >> lit('x') >> double_[_d = _1] >> lit(';')
>> double_[_e = _1] >> lit('x') >> double_[_f = _1] >> lit(';')
>> double_[_g = _1] >> lit('x') >> double_[_h = _1] >> lit(')')
[push_back(_r1, construct<mapnik::filter::hsla>(_a,_b,_c,_d,_e,_f,_g,_h))]
;
colorize_alpha_filter = lit("colorize-alpha")
>> lit('(')
>> css_color_[_a = _1] >> lit(',')
>> css_color_[_b = _1] >> lit(')')
[push_back(_r1,construct<mapnik::filter::colorize_alpha>(_a,_b))]
; ;
string_arg = +~char_(')');
no_args = -(lit('(') >> lit(')')); no_args = -(lit('(') >> lit(')'));
} }