Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
d7fa56b307
6 changed files with 101 additions and 92 deletions
|
@ -56,6 +56,7 @@ class MAPNIK_DECL grid_renderer : public feature_style_processor<grid_renderer<T
|
|||
{
|
||||
|
||||
public:
|
||||
typedef T buffer_type;
|
||||
typedef grid_renderer<T> processor_impl_type;
|
||||
grid_renderer(Map const& m, T & pixmap, double scale_factor=1.0, unsigned offset_x=0, unsigned offset_y=0);
|
||||
~grid_renderer();
|
||||
|
@ -110,7 +111,7 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
T & pixmap_;
|
||||
buffer_type & pixmap_;
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
double scale_factor_;
|
||||
|
|
|
@ -58,7 +58,7 @@ struct vector_markers_rasterizer_dispatch
|
|||
typedef typename SvgRenderer::renderer_base renderer_base;
|
||||
typedef typename renderer_base::pixfmt_type pixfmt_type;
|
||||
|
||||
vector_markers_rasterizer_dispatch(BufferType & image_buffer,
|
||||
vector_markers_rasterizer_dispatch(BufferType & render_buffer,
|
||||
SvgRenderer & svg_renderer,
|
||||
Rasterizer & ras,
|
||||
box2d<double> const& bbox,
|
||||
|
@ -66,7 +66,7 @@ struct vector_markers_rasterizer_dispatch
|
|||
markers_symbolizer const& sym,
|
||||
Detector & detector,
|
||||
double scale_factor)
|
||||
: buf_(image_buffer.raw_data(), image_buffer.width(), image_buffer.height(), image_buffer.width() * 4),
|
||||
: buf_(render_buffer),
|
||||
pixf_(buf_),
|
||||
renb_(pixf_),
|
||||
svg_renderer_(svg_renderer),
|
||||
|
@ -105,11 +105,12 @@ struct vector_markers_rasterizer_dispatch
|
|||
detector_.has_placement(transformed_bbox))
|
||||
{
|
||||
svg_renderer_.render(ras_, sl_, renb_, matrix, sym_.get_opacity(), bbox_);
|
||||
|
||||
if (!sym_.get_ignore_placement())
|
||||
{
|
||||
detector_.insert(transformed_bbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
markers_placement<T, label_collision_detector4> placement(path, bbox_, marker_trans_, detector_,
|
||||
|
@ -128,7 +129,7 @@ struct vector_markers_rasterizer_dispatch
|
|||
}
|
||||
private:
|
||||
agg::scanline_u8 sl_;
|
||||
agg::rendering_buffer buf_;
|
||||
BufferType & buf_;
|
||||
pixfmt_type pixf_;
|
||||
renderer_base renb_;
|
||||
SvgRenderer & svg_renderer_;
|
||||
|
@ -140,59 +141,6 @@ private:
|
|||
double scale_factor_;
|
||||
};
|
||||
|
||||
template <typename Rasterizer, typename RendererBuffer>
|
||||
void render_raster_marker(Rasterizer & ras, RendererBuffer & renb,
|
||||
agg::scanline_u8 & sl, image_data_32 const& src,
|
||||
agg::trans_affine const& marker_tr, double opacity)
|
||||
{
|
||||
double width = src.width();
|
||||
double height = src.height();
|
||||
double p[8];
|
||||
p[0] = 0; p[1] = 0;
|
||||
p[2] = width; p[3] = 0;
|
||||
p[4] = width; p[5] = height;
|
||||
p[6] = 0; p[7] = height;
|
||||
|
||||
marker_tr.transform(&p[0], &p[1]);
|
||||
marker_tr.transform(&p[2], &p[3]);
|
||||
marker_tr.transform(&p[4], &p[5]);
|
||||
marker_tr.transform(&p[6], &p[7]);
|
||||
|
||||
ras.move_to_d(p[0],p[1]);
|
||||
ras.line_to_d(p[2],p[3]);
|
||||
ras.line_to_d(p[4],p[5]);
|
||||
ras.line_to_d(p[6],p[7]);
|
||||
|
||||
typedef agg::rgba8 color_type;
|
||||
agg::span_allocator<color_type> sa;
|
||||
agg::image_filter_bilinear filter_kernel;
|
||||
agg::image_filter_lut filter(filter_kernel, false);
|
||||
|
||||
agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(),
|
||||
src.width(),
|
||||
src.height(),
|
||||
src.width()*4);
|
||||
agg::pixfmt_rgba32_pre pixf(marker_buf);
|
||||
|
||||
typedef agg::image_accessor_clone<agg::pixfmt_rgba32_pre> img_accessor_type;
|
||||
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
|
||||
typedef agg::span_image_filter_rgba_2x2<img_accessor_type,
|
||||
interpolator_type> span_gen_type;
|
||||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
typedef agg::renderer_scanline_aa_alpha<renderer_base,
|
||||
agg::span_allocator<agg::rgba8>,
|
||||
span_gen_type> renderer_type;
|
||||
img_accessor_type ia(pixf);
|
||||
interpolator_type interpolator(agg::trans_affine(p, 0, 0, width, height) );
|
||||
span_gen_type sg(ia, interpolator, filter);
|
||||
renderer_type rp(renb,sa, sg, unsigned(opacity*255));
|
||||
agg::render_scanlines(ras, sl, rp);
|
||||
}
|
||||
|
||||
template <typename BufferType, typename Rasterizer, typename Detector>
|
||||
struct raster_markers_rasterizer_dispatch
|
||||
{
|
||||
|
@ -200,17 +148,17 @@ struct raster_markers_rasterizer_dispatch
|
|||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, BufferType> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
|
||||
raster_markers_rasterizer_dispatch(BufferType & image_buffer,
|
||||
raster_markers_rasterizer_dispatch(BufferType & render_buffer,
|
||||
Rasterizer & ras,
|
||||
image_data_32 const& src,
|
||||
agg::trans_affine const& marker_trans,
|
||||
markers_symbolizer const& sym,
|
||||
Detector & detector,
|
||||
double scale_factor)
|
||||
: buf_(image_buffer.raw_data(), image_buffer.width(), image_buffer.height(), image_buffer.width() * 4),
|
||||
: buf_(render_buffer),
|
||||
pixf_(buf_),
|
||||
renb_(pixf_),
|
||||
ras_(ras),
|
||||
|
@ -248,12 +196,13 @@ struct raster_markers_rasterizer_dispatch
|
|||
if (sym_.get_allow_overlap() ||
|
||||
detector_.has_placement(transformed_bbox))
|
||||
{
|
||||
render_raster_marker(ras_, renb_, sl_, src_,
|
||||
matrix, sym_.get_opacity());
|
||||
render_raster_marker(matrix, sym_.get_opacity());
|
||||
if (!sym_.get_ignore_placement())
|
||||
{
|
||||
detector_.insert(transformed_bbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
markers_placement<T, label_collision_detector4> placement(path, bbox_, marker_trans_, detector_,
|
||||
|
@ -265,15 +214,55 @@ struct raster_markers_rasterizer_dispatch
|
|||
{
|
||||
agg::trans_affine matrix = marker_trans_;
|
||||
matrix.rotate(angle);
|
||||
matrix.translate(x,y);
|
||||
render_raster_marker(ras_, renb_, sl_, src_,
|
||||
matrix, sym_.get_opacity());
|
||||
matrix.translate(x, y);
|
||||
render_raster_marker(matrix, sym_.get_opacity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void render_raster_marker(agg::trans_affine const& marker_tr,
|
||||
double opacity)
|
||||
{
|
||||
double width = src_.width();
|
||||
double height = src_.height();
|
||||
double p[8];
|
||||
p[0] = 0; p[1] = 0;
|
||||
p[2] = width; p[3] = 0;
|
||||
p[4] = width; p[5] = height;
|
||||
p[6] = 0; p[7] = height;
|
||||
marker_tr.transform(&p[0], &p[1]);
|
||||
marker_tr.transform(&p[2], &p[3]);
|
||||
marker_tr.transform(&p[4], &p[5]);
|
||||
marker_tr.transform(&p[6], &p[7]);
|
||||
ras_.move_to_d(p[0],p[1]);
|
||||
ras_.line_to_d(p[2],p[3]);
|
||||
ras_.line_to_d(p[4],p[5]);
|
||||
ras_.line_to_d(p[6],p[7]);
|
||||
agg::span_allocator<color_type> sa;
|
||||
agg::image_filter_bilinear filter_kernel;
|
||||
agg::image_filter_lut filter(filter_kernel, false);
|
||||
agg::rendering_buffer marker_buf((unsigned char *)src_.getBytes(),
|
||||
src_.width(),
|
||||
src_.height(),
|
||||
src_.width()*4);
|
||||
agg::pixfmt_rgba32_pre pixf(marker_buf);
|
||||
typedef agg::image_accessor_clone<agg::pixfmt_rgba32_pre> img_accessor_type;
|
||||
typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
|
||||
typedef agg::span_image_filter_rgba_2x2<img_accessor_type,
|
||||
interpolator_type> span_gen_type;
|
||||
typedef agg::renderer_scanline_aa_alpha<renderer_base,
|
||||
agg::span_allocator<agg::rgba8>,
|
||||
span_gen_type> renderer_type;
|
||||
img_accessor_type ia(pixf);
|
||||
interpolator_type interpolator(agg::trans_affine(p, 0, 0, width, height) );
|
||||
span_gen_type sg(ia, interpolator, filter);
|
||||
renderer_type rp(renb_,sa, sg, unsigned(opacity*255));
|
||||
agg::render_scanlines(ras_, sl_, rp);
|
||||
}
|
||||
|
||||
private:
|
||||
agg::scanline_u8 sl_;
|
||||
agg::rendering_buffer buf_;
|
||||
BufferType & buf_;
|
||||
pixfmt_comp_type pixf_;
|
||||
renderer_base renb_;
|
||||
Rasterizer & ras_;
|
||||
|
|
|
@ -20,15 +20,15 @@
|
|||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// boost
|
||||
#include <boost/foreach.hpp>
|
||||
// mapnik
|
||||
#include <mapnik/graphics.hpp>
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
|
||||
// agg
|
||||
#include "agg_basics.h"
|
||||
#include "agg_rendering_buffer.h"
|
||||
|
@ -41,9 +41,12 @@
|
|||
#include "agg_conv_dash.h"
|
||||
#include "agg_renderer_outline_aa.h"
|
||||
#include "agg_rasterizer_outline_aa.h"
|
||||
|
||||
// boost
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
// stl
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
|
@ -71,6 +74,9 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
typedef boost::mpl::vector<clip_line_tag, transform_tag,
|
||||
offset_transform_tag, affine_transform_tag,
|
||||
smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
|
||||
pixfmt_comp_type pixf(buf);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
|
||||
|
@ -110,9 +116,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
rasterizer_type ras(ren);
|
||||
set_join_caps_aa(stroke_,ras);
|
||||
|
||||
typedef boost::mpl::vector<clip_line_tag, transform_tag,
|
||||
offset_transform_tag, affine_transform_tag,
|
||||
smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
vertex_converter<box2d<double>, rasterizer_type, line_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
converter(clipping_extent,ras,sym,t_,prj_trans,tr,scaled);
|
||||
|
@ -134,9 +137,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
}
|
||||
else
|
||||
{
|
||||
typedef boost::mpl::vector<clip_line_tag, transform_tag, offset_transform_tag,
|
||||
affine_transform_tag, smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
|
||||
vertex_converter<box2d<double>, rasterizer, line_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
converter(clipping_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
||||
|
|
|
@ -65,7 +65,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
typedef agg::order_rgba order_type;
|
||||
typedef agg::pixel32_type pixel_type;
|
||||
typedef agg::comp_op_adaptor_rgba_pre<color_type, order_type> blender_type; // comp blender
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
|
||||
typedef agg::rendering_buffer buf_type;
|
||||
typedef agg::pixfmt_custom_blend_rgba<blender_type, buf_type> pixfmt_comp_type;
|
||||
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
|
||||
typedef label_collision_detector4 detector_type;
|
||||
typedef boost::mpl::vector<clip_line_tag,clip_poly_tag,transform_tag,smooth_tag> conv_types;
|
||||
|
@ -93,7 +94,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
svg_attribute_type,
|
||||
renderer_type,
|
||||
pixfmt_comp_type > svg_renderer_type;
|
||||
typedef vector_markers_rasterizer_dispatch<buffer_type,
|
||||
typedef vector_markers_rasterizer_dispatch<buf_type,
|
||||
svg_renderer_type,
|
||||
rasterizer,
|
||||
detector_type > dispatch_type;
|
||||
|
@ -118,7 +119,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
coord2d center = bbox.center();
|
||||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||
agg::trans_affine marker_trans = recenter * tr;
|
||||
dispatch_type rasterizer_dispatch(*current_buffer_,svg_renderer,*ras_ptr,
|
||||
buf_type render_buffer(current_buffer_->raw_data(), width_, height_, width_ * 4);
|
||||
dispatch_type rasterizer_dispatch(render_buffer,svg_renderer,*ras_ptr,
|
||||
bbox, marker_trans, sym, *detector_, scale_factor_);
|
||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
|
@ -151,7 +153,8 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
svg_attribute_type attributes;
|
||||
bool result = push_explicit_style( (*stock_vector_marker)->attributes(), attributes, sym);
|
||||
svg_renderer_type svg_renderer(svg_path, result ? attributes : (*stock_vector_marker)->attributes());
|
||||
dispatch_type rasterizer_dispatch(*current_buffer_,svg_renderer,*ras_ptr,
|
||||
buf_type render_buffer(current_buffer_->raw_data(), width_, height_, width_ * 4);
|
||||
dispatch_type rasterizer_dispatch(render_buffer,svg_renderer,*ras_ptr,
|
||||
bbox, marker_trans, sym, *detector_, scale_factor_);
|
||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
|
@ -181,8 +184,9 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
|
|||
agg::trans_affine_translation recenter(-center.x, -center.y);
|
||||
agg::trans_affine marker_trans = recenter * tr;
|
||||
boost::optional<mapnik::image_ptr> marker = (*mark)->get_bitmap_data();
|
||||
typedef raster_markers_rasterizer_dispatch<buffer_type,rasterizer, detector_type> dispatch_type;
|
||||
dispatch_type rasterizer_dispatch(*current_buffer_,*ras_ptr, **marker,
|
||||
typedef raster_markers_rasterizer_dispatch<buf_type,rasterizer, detector_type> dispatch_type;
|
||||
buf_type render_buffer(current_buffer_->raw_data(), width_, height_, width_ * 4);
|
||||
dispatch_type rasterizer_dispatch(render_buffer,*ras_ptr, **marker,
|
||||
marker_trans, sym, *detector_, scale_factor_);
|
||||
vertex_converter<box2d<double>, dispatch_type, markers_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <mapnik/grid/grid_pixfmt.hpp>
|
||||
#include <mapnik/grid/grid_pixel.hpp>
|
||||
#include <mapnik/grid/grid.hpp>
|
||||
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
#include <mapnik/vertex_converters.hpp>
|
||||
|
||||
|
@ -49,16 +50,18 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
|
||||
typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
|
||||
typedef agg::renderer_base<mapnik::pixfmt_gray32> renderer_base;
|
||||
typedef agg::renderer_scanline_bin_solid<renderer_base> renderer_type;
|
||||
typedef boost::mpl::vector<clip_line_tag, transform_tag,
|
||||
offset_transform_tag, affine_transform_tag,
|
||||
smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
agg::scanline_bin sl;
|
||||
|
||||
grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
|
||||
mapnik::pixfmt_gray32 pixf(buf);
|
||||
|
||||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
renderer_base renb(pixf);
|
||||
renderer_type ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
|
||||
|
@ -67,13 +70,25 @@ void grid_renderer<T>::process(line_symbolizer const& sym,
|
|||
agg::trans_affine tr;
|
||||
evaluate_transform(tr, feature, sym.get_transform());
|
||||
|
||||
box2d<double> ext = query_extent_ * 1.1;
|
||||
box2d<double> clipping_extent = query_extent_;
|
||||
if (sym.clip())
|
||||
{
|
||||
double padding = (double)(query_extent_.width()/pixmap_.width());
|
||||
float half_stroke = stroke_.get_width()/2.0;
|
||||
if (half_stroke > 1)
|
||||
padding *= half_stroke;
|
||||
if (fabs(sym.offset()) > 0)
|
||||
padding *= fabs(sym.offset()) * 1.2;
|
||||
double x0 = query_extent_.minx();
|
||||
double y0 = query_extent_.miny();
|
||||
double x1 = query_extent_.maxx();
|
||||
double y1 = query_extent_.maxy();
|
||||
clipping_extent.init(x0 - padding, y0 - padding, x1 + padding , y1 + padding);
|
||||
}
|
||||
|
||||
typedef boost::mpl::vector<clip_line_tag,transform_tag, offset_transform_tag, affine_transform_tag, smooth_tag, dash_tag, stroke_tag> conv_types;
|
||||
vertex_converter<box2d<double>, grid_rasterizer, line_symbolizer,
|
||||
CoordTransform, proj_transform, agg::trans_affine, conv_types>
|
||||
converter(ext,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
||||
|
||||
converter(clipping_extent,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
|
||||
if (sym.clip()) converter.set<clip_line_tag>(); // optional clip (default: true)
|
||||
converter.set<transform_tag>(); // always transform
|
||||
if (fabs(sym.offset()) > 0.0) converter.set<offset_transform_tag>(); // parallel offset
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 16 KiB |
Loading…
Reference in a new issue