diff --git a/include/mapnik/agg_helpers.hpp b/include/mapnik/agg_helpers.hpp new file mode 100644 index 000000000..5b221c9aa --- /dev/null +++ b/include/mapnik/agg_helpers.hpp @@ -0,0 +1,57 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2012 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_AGG_HELPERS_HPP +#define MAPNIK_AGG_HELPERS_HPP + +#include "agg_gamma_functions.h" + +namespace mapnik { + +template +void set_gamma_method(T0 const& obj, T1 & ras_ptr) +{ + switch (obj.get_gamma_method()) + { + case GAMMA_POWER: + ras_ptr->gamma(agg::gamma_power(obj.get_gamma())); + break; + case GAMMA_LINEAR: + ras_ptr->gamma(agg::gamma_linear(0.0, obj.get_gamma())); + break; + case GAMMA_NONE: + ras_ptr->gamma(agg::gamma_none()); + break; + case GAMMA_THRESHOLD: + ras_ptr->gamma(agg::gamma_threshold(obj.get_gamma())); + break; + case GAMMA_MULTIPLY: + ras_ptr->gamma(agg::gamma_multiply(obj.get_gamma())); + break; + default: + ras_ptr->gamma(agg::gamma_power(obj.get_gamma())); + } +} + +} + +#endif //MAPNIK_AGG_HELPERS_HPP diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 193e53f43..b4f37be67 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -23,6 +23,7 @@ // mapnik #include +#include #include #include @@ -71,7 +72,6 @@ void agg_renderer::process(line_symbolizer const& sym, typedef agg::rasterizer_outline_aa rasterizer_type; agg::line_profile_aa profile; - //agg::line_profile_aa profile(stroke_.get_width() * scale_factor_, agg::gamma_none()); profile.width(stroke_.get_width() * scale_factor_); ren_base base_ren(pixf); renderer_type ren(base_ren, profile); @@ -102,26 +102,10 @@ void agg_renderer::process(line_symbolizer const& sym, ren_base renb(pixf); renderer ren(renb); ras_ptr->reset(); - switch (stroke_.get_gamma_method()) - { - case GAMMA_POWER: - ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma())); - break; - case GAMMA_LINEAR: - ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma())); - break; - case GAMMA_NONE: - ras_ptr->gamma(agg::gamma_none()); - break; - case GAMMA_THRESHOLD: - ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma())); - break; - case GAMMA_MULTIPLY: - ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma())); - break; - default: - ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma())); - } + + set_gamma_method(stroke_, ras_ptr); + + //metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;inum_geometries();++i) @@ -129,12 +113,13 @@ void agg_renderer::process(line_symbolizer const& sym, geometry_type & geom = feature->get_geometry(i); if (geom.num_points() > 1) { - clipped_geometry_type clipped(geom); - clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); - path_type path(t_,clipped,prj_trans); if (stroke_.has_dash()) { + clipped_geometry_type clipped(geom); + clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); + path_type path(t_,clipped,prj_trans); + agg::conv_dash dash(path); dash_array const& d = stroke_.get_dash_array(); dash_array::const_iterator itr = d.begin(); @@ -172,6 +157,10 @@ void agg_renderer::process(line_symbolizer const& sym, } else { + clipped_geometry_type clipped(geom); + clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); + path_type path(t_,clipped,prj_trans); + agg::conv_stroke stroke(path); line_join_e join=stroke_.get_line_join(); if ( join == MITER_JOIN) diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 670fea9b6..1d6fbde1f 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -23,6 +23,7 @@ // mapnik #include +#include #include #include #include @@ -72,27 +73,8 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::scanline_u8 sl; ras_ptr->reset(); - switch (sym.get_gamma_method()) - { - case GAMMA_POWER: - ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); - break; - case GAMMA_LINEAR: - ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); - break; - case GAMMA_NONE: - ras_ptr->gamma(agg::gamma_none()); - break; - case GAMMA_THRESHOLD: - ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma())); - break; - case GAMMA_MULTIPLY: - ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma())); - break; - default: - ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); - } - + set_gamma_method(sym,ras_ptr); + std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature); boost::optional marker; if ( !filename.empty() ) diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index bcd1a7431..5baa68642 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -23,6 +23,7 @@ // mapnik #include +#include #include #include @@ -65,27 +66,9 @@ void agg_renderer::process(polygon_symbolizer const& sym, renderer ren(renb); ras_ptr->reset(); - switch (sym.get_gamma_method()) - { - case GAMMA_POWER: - ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); - break; - case GAMMA_LINEAR: - ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); - break; - case GAMMA_NONE: - ras_ptr->gamma(agg::gamma_none()); - break; - case GAMMA_THRESHOLD: - ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma())); - break; - case GAMMA_MULTIPLY: - ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma())); - break; - default: - ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); - } + set_gamma_method(sym,ras_ptr); + //metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;inum_geometries();++i) {