/***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2006 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 * *****************************************************************************/ //$Id$ // mapnik #include #include #include #include #include #include #include #include #include // agg #define AGG_RENDERING_BUFFER row_ptr_cache #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" #include "agg_rasterizer_scanline_aa.h" #include "agg_basics.h" #include "agg_scanline_p.h" #include "agg_scanline_u.h" #include "agg_renderer_scanline.h" #include "agg_path_storage.h" #include "agg_span_allocator.h" #include "agg_span_pattern_rgba.h" #include "agg_image_accessors.h" #include "agg_conv_stroke.h" #include "agg_conv_dash.h" #include "agg_conv_contour.h" #include "agg_conv_clip_polyline.h" #include "agg_vcgen_stroke.h" #include "agg_conv_adaptor_vcgen.h" #include "agg_conv_smooth_poly1.h" #include "agg_conv_marker.h" #include "agg_vcgen_markers_term.h" #include "agg_renderer_outline_aa.h" #include "agg_rasterizer_outline_aa.h" #include "agg_rasterizer_outline.h" #include "agg_renderer_outline_image.h" #include "agg_span_allocator.h" #include "agg_span_pattern_rgba.h" #include "agg_renderer_scanline.h" #include "agg_pattern_filters_rgba.h" #include "agg_renderer_outline_image.h" #include "agg_vpgen_clip_polyline.h" #include "agg_arrowhead.h" // boost #include // stl #ifdef MAPNIK_DEBUG #include #endif #include namespace mapnik { class pattern_source : private boost::noncopyable { public: pattern_source(image_data_32 const& pattern) : pattern_(pattern) {} unsigned int width() const { return pattern_.width(); } unsigned int height() const { return pattern_.height(); } agg::rgba8 pixel(int x, int y) const { unsigned c = pattern_(x,y); return agg::rgba8(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff, (c >> 24) & 0xff); } private: image_data_32 const& pattern_; }; template agg_renderer::agg_renderer(Map const& m, T & pixmap, double scale_factor, unsigned offset_x, unsigned offset_y) : feature_style_processor(m, scale_factor), pixmap_(pixmap), width_(pixmap_.width()), height_(pixmap_.height()), scale_factor_(scale_factor), t_(m.width(),m.height(),m.get_current_extent(),offset_x,offset_y), font_engine_(), font_manager_(font_engine_), detector_(box2d(-m.buffer_size(), -m.buffer_size(), m.width() + m.buffer_size() ,m.height() + m.buffer_size())), ras_ptr(new rasterizer) { boost::optional const& bg = m.background(); if (bg) pixmap_.set_background(*bg); boost::optional const& image_filename = m.background_image(); if (image_filename) { boost::optional bg_marker = mapnik::marker_cache::instance()->find(*image_filename,true); if (bg_marker && (*bg_marker)->is_bitmap()) { mapnik::image_ptr bg_image = *(*bg_marker)->get_bitmap_data(); int w = bg_image->width(); int h = bg_image->height(); if ( w > 0 && h > 0) { // repeat background-image both vertically and horizontally unsigned x_steps = unsigned(std::ceil(width_/double(w))); unsigned y_steps = unsigned(std::ceil(height_/double(h))); for (unsigned x=0;x agg_renderer::~agg_renderer() {} template void agg_renderer::start_map_processing(Map const& map) { #ifdef MAPNIK_DEBUG std::clog << "start map processing bbox=" << map.get_current_extent() << "\n"; #endif ras_ptr->clip_box(0,0,width_,height_); } template void agg_renderer::end_map_processing(Map const& ) { #ifdef MAPNIK_DEBUG std::clog << "end map processing\n"; #endif } template void agg_renderer::start_layer_processing(layer const& lay) { #ifdef MAPNIK_DEBUG std::clog << "start layer processing : " << lay.name() << "\n"; std::clog << "datasource = " << lay.datasource().get() << "\n"; #endif if (lay.clear_label_cache()) { detector_.clear(); } } template void agg_renderer::end_layer_processing(layer const&) { #ifdef MAPNIK_DEBUG std::clog << "end layer processing\n"; #endif } template class agg_renderer; }