refactor clipping_extent into separate header for sharing
This commit is contained in:
parent
dd05521289
commit
a8991cd600
12 changed files with 59 additions and 61 deletions
|
@ -37,7 +37,7 @@
|
|||
#include <mapnik/symbolizer_enumerations.hpp>
|
||||
#include <mapnik/renderer_common.hpp>
|
||||
#include <mapnik/image_data.hpp>
|
||||
|
||||
#include <mapnik/renderer_common/clipping_extent.hpp>
|
||||
// stl
|
||||
#include <memory>
|
||||
|
||||
|
@ -146,22 +146,6 @@ public:
|
|||
{
|
||||
return common_.vars_;
|
||||
}
|
||||
|
||||
inline box2d<double> clipping_extent() const
|
||||
{
|
||||
if (common_.t_.offset() > 0)
|
||||
{
|
||||
box2d<double> box = common_.query_extent_;
|
||||
double scale = static_cast<double>(common_.query_extent_.width())/static_cast<double>(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 <typename R>
|
||||
void debug_draw_box(R& buf, box2d<double> const& extent,
|
||||
|
@ -182,8 +166,6 @@ private:
|
|||
void setup(Map const& m);
|
||||
};
|
||||
|
||||
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr);
|
||||
|
||||
} // namespace mapnik
|
||||
|
||||
#endif // MAPNIK_AGG_RENDERER_HPP
|
||||
|
|
49
include/mapnik/renderer_common/clipping_extent.hpp
Normal file
49
include/mapnik/renderer_common/clipping_extent.hpp
Normal file
|
@ -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 <mapnik/box2d.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T>
|
||||
box2d<double> clipping_extent(T const& common)
|
||||
{
|
||||
if (common.t_.offset() > 0)
|
||||
{
|
||||
box2d<double> box = common.query_extent_;
|
||||
double scale = static_cast<double>(common.query_extent_.width())/static_cast<double>(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
|
|
@ -502,39 +502,6 @@ void agg_renderer<T0,T1>::draw_geo_extent(box2d<double> const& extent, mapnik::c
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<image_data_32> render_pattern(rasterizer & ras, marker const& marker, agg::trans_affine const& tr)
|
||||
{
|
||||
using pixfmt = agg::pixfmt_rgba32_pre;
|
||||
using renderer_base = agg::renderer_base<pixfmt>;
|
||||
using renderer_solid = agg::renderer_scanline_aa_solid<renderer_base>;
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
//double width = marker.width();
|
||||
//double height = marker.height();
|
||||
|
||||
mapnik::box2d<double> const& bbox = (*marker.get_vector_data())->bounding_box() * tr;
|
||||
mapnik::coord<double,2> 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<mapnik::image_data_32> image = std::make_shared<mapnik::image_data_32>(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<mapnik::svg::svg_path_storage> stl_storage((*marker.get_vector_data())->source());
|
||||
mapnik::svg::svg_path_adapter svg_path(stl_storage);
|
||||
mapnik::svg::svg_renderer_agg<mapnik::svg::svg_path_adapter,
|
||||
agg::pod_bvector<mapnik::svg::path_attributes>,
|
||||
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<image_32>;
|
||||
template void agg_renderer<image_32>::debug_draw_box<agg::rendering_buffer>(
|
||||
agg::rendering_buffer& buf,
|
||||
|
|
|
@ -106,7 +106,7 @@ void agg_renderer<T0,T1>::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);
|
||||
|
|
|
@ -140,7 +140,7 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
if (clip)
|
||||
{
|
||||
double padding = (double)(common_.query_extent_.width()/pixmap_.width());
|
||||
|
|
|
@ -130,7 +130,7 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
|
|||
auto transform = get_optional<transform_type>(sym, keys::geometry_transform);
|
||||
if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
bool clip = get<value_bool>(sym, keys::clip, feature, common_.vars_, false);
|
||||
double width = get<value_double>(sym, keys::stroke_width, feature, common_.vars_, 1.0);
|
||||
|
|
|
@ -90,7 +90,7 @@ void agg_renderer<T0,T1>::process(markers_symbolizer const& sym,
|
|||
}
|
||||
|
||||
buf_type render_buffer(current_buffer_->raw_data(), current_buffer_->width(), current_buffer_->height(), current_buffer_->width() * 4);
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
auto renderer_context = std::tie(render_buffer,*ras_ptr,pixmap_);
|
||||
using context_type = decltype(renderer_context);
|
||||
|
|
|
@ -98,7 +98,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
|
|||
double simplify_tolerance = get<value_double>(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0);
|
||||
double smooth = get<value_double>(sym, keys::smooth, feature, common_.vars_, false);
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
using color = agg::rgba8;
|
||||
using order = agg::order_rgba;
|
||||
|
|
|
@ -64,7 +64,7 @@ void agg_renderer<T0,T1>::process(polygon_symbolizer const& sym,
|
|||
gamma_ = gamma;
|
||||
}
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> 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<vertex_converter_type>(
|
||||
|
|
|
@ -36,7 +36,7 @@ void agg_renderer<T0,T1>::process(shield_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
text_symbolizer_helper helper(
|
||||
sym, feature, common_.vars_, prj_trans,
|
||||
common_.width_, common_.height_,
|
||||
|
|
|
@ -36,7 +36,7 @@ void agg_renderer<T0,T1>::process(text_symbolizer const& sym,
|
|||
proj_transform const& prj_trans)
|
||||
{
|
||||
|
||||
box2d<double> clip_box = clipping_extent();
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
text_symbolizer_helper helper(
|
||||
sym, feature, common_.vars_, prj_trans,
|
||||
common_.width_, common_.height_,
|
||||
|
|
|
@ -713,7 +713,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
unsigned offset_x=0;
|
||||
unsigned offset_y=0;
|
||||
box2d<double> const& clip_box = common_.query_extent_;//clipping_extent();
|
||||
box2d<double> const& clip_box = clipping_extent(common_);
|
||||
pattern_alignment_enum alignment = get<pattern_alignment_enum>(sym, keys::alignment, feature, common_.vars_, GLOBAL_ALIGNMENT);
|
||||
if (alignment == LOCAL_ALIGNMENT)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue