diff --git a/include/mapnik/image_filter.hpp b/include/mapnik/image_filter.hpp index 4f09f2c2e..1ed44b0df 100644 --- a/include/mapnik/image_filter.hpp +++ b/include/mapnik/image_filter.hpp @@ -449,11 +449,11 @@ void apply_filter(Src & src, hsla const& op) double s2 = tint.s0 + (s * (tint.s1 - tint.s0)); double l2 = tint.l0 + (l * (tint.l1 - tint.l0)); if (h2 > 1) h2 = 1; - if (h2 < 0) h2 = 0; + else if (h2 < 0) h2 = 0; if (s2 > 1) s2 = 1; - if (s2 < 0) s2 = 0; + else if (s2 < 0) s2 = 0; if (l2 > 1) l2 = 1; - if (l2 < 0) l2 = 0; + else if (l2 < 0) l2 = 0; hsl2rgb(h2,s2,l2,r,g,b); // premultiply // we only work with premultiplied source, diff --git a/include/mapnik/image_filter_grammar.hpp b/include/mapnik/image_filter_grammar.hpp index 054cd856e..823b21b93 100644 --- a/include/mapnik/image_filter_grammar.hpp +++ b/include/mapnik/image_filter_grammar.hpp @@ -39,7 +39,10 @@ struct image_filter_grammar : { image_filter_grammar(); qi::rule start; - qi::rule, qi::ascii::space_type> filter; + qi::rule filter; + qi::rule, void(ContType&), qi::ascii::space_type> agg_blur_filter; + qi::rule, void(ContType&), qi::ascii::space_type> hsla_filter; + qi::rule string_arg; qi::uint_parser< unsigned, 10, 1, 3 > radius_; }; diff --git a/include/mapnik/image_filter_types.hpp b/include/mapnik/image_filter_types.hpp index 9504d441d..cf49ed0d6 100644 --- a/include/mapnik/image_filter_types.hpp +++ b/include/mapnik/image_filter_types.hpp @@ -30,7 +30,6 @@ #include // stl -#include #include #include #include // for std::back_insert_iterator @@ -71,7 +70,8 @@ typedef boost::variant filter_type; + filter::invert, + filter::hsla> filter_type; inline std::ostream& operator<< (std::ostream& os, blur) { diff --git a/include/mapnik/util/hsl.hpp b/include/mapnik/util/hsl.hpp index 715b8f72c..3c8c62e2f 100644 --- a/include/mapnik/util/hsl.hpp +++ b/include/mapnik/util/hsl.hpp @@ -2,7 +2,7 @@ * * This file is part of Mapnik (c++ mapping toolkit) * - * Copyright (C) 2012 Artem Pavlenko + * Copyright (C) 2013 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public diff --git a/src/image_filter_grammar.cpp b/src/image_filter_grammar.cpp index 1601b2904..80becb931 100644 --- a/src/image_filter_grammar.cpp +++ b/src/image_filter_grammar.cpp @@ -44,8 +44,11 @@ image_filter_grammar::image_filter_grammar() using qi::_1; using qi::_a; using qi::_b; + using qi::_r1; using qi::eps; using qi::char_; + using qi::lexeme; + using boost::spirit::ascii::string; using phoenix::push_back; using phoenix::construct; @@ -75,15 +78,26 @@ image_filter_grammar::image_filter_grammar() | lit("y-gradient")[push_back(_val,construct())] | - (lit("agg-stack-blur")[_a = 1, _b = 1] - >> -( lit('(') >> radius_[_a = _1] - >> lit(',') - >> radius_[_b = _1] - >> lit(')')) - [push_back(_val,construct(_a,_b))]) - | lit("invert")[push_back(_val,construct())] + | + agg_blur_filter(_val) + | + hsla_filter(_val) ; + + agg_blur_filter = (lit("agg-stack-blur")[_a = 1, _b = 1] + >> -( lit('(') >> radius_[_a = _1] + >> lit(',') + >> radius_[_b = _1] + >> lit(')'))) + [push_back(_r1,construct(_a,_b))] + ; + + hsla_filter = (lit("hsla") >> lit('(') >> string_arg[_a = _1] >> lit(')')) + [push_back(_r1,construct(_a))] + ; + + string_arg = +~char_(')'); } template struct mapnik::image_filter_grammar >;