diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 40719e866..7309622fc 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -37,7 +37,7 @@ #include #include #include - +#include // stl #include @@ -146,22 +146,6 @@ public: { return common_.vars_; } - - inline box2d clipping_extent() const - { - if (common_.t_.offset() > 0) - { - box2d box = common_.query_extent_; - double scale = static_cast(common_.query_extent_.width())/static_cast(common_.width_); - // 3 is used here because at least 3 was needed for the 'style-level-compositing-tiled-0,1' visual test to pass - // TODO - add more tests to hone in on a more robust # - scale *= common_.t_.offset()*3; - box.pad(scale); - return box; - } - return common_.query_extent_; - } - protected: template void debug_draw_box(R& buf, box2d const& extent, @@ -182,8 +166,6 @@ private: void setup(Map const& m); }; -std::shared_ptr render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr); - } // namespace mapnik #endif // MAPNIK_AGG_RENDERER_HPP diff --git a/include/mapnik/renderer_common/clipping_extent.hpp b/include/mapnik/renderer_common/clipping_extent.hpp new file mode 100644 index 000000000..b8dd70bfa --- /dev/null +++ b/include/mapnik/renderer_common/clipping_extent.hpp @@ -0,0 +1,49 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 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_CLIPPING_EXTENT_HPP +#define MAPNIK_CLIPPING_EXTENT_HPP + + +#include + +namespace mapnik { + +template +box2d clipping_extent(T const& common) +{ + if (common.t_.offset() > 0) + { + box2d box = common.query_extent_; + double scale = static_cast(common.query_extent_.width())/static_cast(common.width_); + // 3 is used here because at least 3 was needed for the 'style-level-compositing-tiled-0,1' visual test to pass + // TODO - add more tests to hone in on a more robust # + scale *= common.t_.offset() * 3; + box.pad(scale); + return box; + } + return common.query_extent_; +} + +} // namespace mapnik + +#endif // MAPNIK_CLIPPING_EXTENT_HPP diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 92caa3964..21d31a7fe 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -502,39 +502,6 @@ void agg_renderer::draw_geo_extent(box2d const& extent, mapnik::c } } -std::shared_ptr render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr) -{ - using pixfmt = agg::pixfmt_rgba32_pre; - using renderer_base = agg::renderer_base; - using renderer_solid = agg::renderer_scanline_aa_solid; - agg::scanline_u8 sl; - - //double width = marker.width(); - //double height = marker.height(); - - mapnik::box2d const& bbox = (*marker.get_vector_data())->bounding_box() * tr; - mapnik::coord c = bbox.center(); - agg::trans_affine mtx = agg::trans_affine_translation(-c.x,-c.y); - mtx.translate(0.5 * bbox.width(), 0.5 * bbox.height()); - mtx = tr * mtx; - - std::shared_ptr image = std::make_shared(bbox.width(), bbox.height()); - agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4); - pixfmt pixf(buf); - renderer_base renb(pixf); - - mapnik::svg::vertex_stl_adapter stl_storage((*marker.get_vector_data())->source()); - mapnik::svg::svg_path_adapter svg_path(stl_storage); - mapnik::svg::svg_renderer_agg, - renderer_solid, - agg::pixfmt_rgba32_pre > svg_renderer(svg_path, - (*marker.get_vector_data())->attributes()); - - svg_renderer.render(ras, sl, renb, mtx, 1.0, bbox); - return image; -} - template class agg_renderer; template void agg_renderer::debug_draw_box( agg::rendering_buffer& buf, diff --git a/src/agg/process_group_symbolizer.cpp b/src/agg/process_group_symbolizer.cpp index 64b48bb7d..dc8d5e031 100644 --- a/src/agg/process_group_symbolizer.cpp +++ b/src/agg/process_group_symbolizer.cpp @@ -106,7 +106,7 @@ void agg_renderer::process(group_symbolizer const& sym, proj_transform const& prj_trans) { render_group_symbolizer( - sym, feature, common_.vars_, prj_trans, clipping_extent(), common_, + sym, feature, common_.vars_, prj_trans, clipping_extent(common_), common_, [&](render_thunk_list const& thunks, pixel_position const& render_offset) { thunk_renderer ren(*this, current_buffer_, common_, render_offset); diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index f0609fd97..31f97a7f2 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -140,7 +140,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, auto transform = get_optional(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); if (clip) { double padding = (double)(common_.query_extent_.width()/pixmap_.width()); diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 581b12196..afc8daf72 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -130,7 +130,7 @@ void agg_renderer::process(line_symbolizer const& sym, auto transform = get_optional(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); bool clip = get(sym, keys::clip, feature, common_.vars_, false); double width = get(sym, keys::stroke_width, feature, common_.vars_, 1.0); diff --git a/src/agg/process_markers_symbolizer.cpp b/src/agg/process_markers_symbolizer.cpp index 1298e997d..6e21200d1 100644 --- a/src/agg/process_markers_symbolizer.cpp +++ b/src/agg/process_markers_symbolizer.cpp @@ -90,7 +90,7 @@ void agg_renderer::process(markers_symbolizer const& sym, } buf_type render_buffer(current_buffer_->raw_data(), current_buffer_->width(), current_buffer_->height(), current_buffer_->width() * 4); - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); auto renderer_context = std::tie(render_buffer,*ras_ptr,pixmap_); using context_type = decltype(renderer_context); diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index bc0ceb89c..ed27a4f86 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -98,7 +98,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, double simplify_tolerance = get(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0); double smooth = get(sym, keys::smooth, feature, common_.vars_, false); - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); using color = agg::rgba8; using order = agg::order_rgba; diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 532596520..b02a269aa 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -64,7 +64,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, gamma_ = gamma; } - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); agg::rendering_buffer buf(current_buffer_->raw_data(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4); render_polygon_symbolizer( diff --git a/src/agg/process_shield_symbolizer.cpp b/src/agg/process_shield_symbolizer.cpp index 4d5f038e1..6e2680a94 100644 --- a/src/agg/process_shield_symbolizer.cpp +++ b/src/agg/process_shield_symbolizer.cpp @@ -36,7 +36,7 @@ void agg_renderer::process(shield_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, diff --git a/src/agg/process_text_symbolizer.cpp b/src/agg/process_text_symbolizer.cpp index 0994e9708..a808b9943 100644 --- a/src/agg/process_text_symbolizer.cpp +++ b/src/agg/process_text_symbolizer.cpp @@ -36,7 +36,7 @@ void agg_renderer::process(text_symbolizer const& sym, proj_transform const& prj_trans) { - box2d clip_box = clipping_extent(); + box2d clip_box = clipping_extent(common_); text_symbolizer_helper helper( sym, feature, common_.vars_, prj_trans, common_.width_, common_.height_, diff --git a/src/cairo/cairo_renderer.cpp b/src/cairo/cairo_renderer.cpp index a8f7d2439..c6003ed21 100644 --- a/src/cairo/cairo_renderer.cpp +++ b/src/cairo/cairo_renderer.cpp @@ -713,7 +713,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, unsigned offset_x=0; unsigned offset_y=0; - box2d const& clip_box = common_.query_extent_;//clipping_extent(); + box2d const& clip_box = clipping_extent(common_); pattern_alignment_enum alignment = get(sym, keys::alignment, feature, common_.vars_, GLOBAL_ALIGNMENT); if (alignment == LOCAL_ALIGNMENT) {