Implement debug symbolizer for Cairo. Update tests for debug symbolizer.
Debug symbolizer is useful, and used in a bunch of tests. This adds debug symbolizer support for Cairo to make it closer to the capabilities of AGG. Adding debug symbolizer for Cairo meant that red boxes appeared in many of the visual test outputs. This commit replaces them with the output, after visual inspection. They should now be closer to the output of the AGG test cases.
|
@ -113,6 +113,9 @@ public:
|
|||
void process(group_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
void process(debug_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans);
|
||||
inline bool process(rule::symbolizers const& /*syms*/,
|
||||
mapnik::feature_impl & /*feature*/,
|
||||
proj_transform const& /*prj_trans*/)
|
||||
|
|
|
@ -1085,6 +1085,75 @@ void cairo_renderer_base::process(group_symbolizer const& sym,
|
|||
});
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// special implementation of the box drawing so that it's pixel-aligned
|
||||
void render_debug_box(cairo_context &context, box2d<double> const& b)
|
||||
{
|
||||
cairo_save_restore guard(context);
|
||||
double minx = std::floor(b.minx()) + 0.5;
|
||||
double miny = std::floor(b.miny()) + 0.5;
|
||||
double maxx = std::floor(b.maxx()) + 0.5;
|
||||
double maxy = std::floor(b.maxy()) + 0.5;
|
||||
context.move_to(minx, miny);
|
||||
context.line_to(minx, maxy);
|
||||
context.line_to(maxx, maxy);
|
||||
context.line_to(maxx, miny);
|
||||
context.close_path();
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
void cairo_renderer_base::process(debug_symbolizer const& sym,
|
||||
mapnik::feature_impl & feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef label_collision_detector4 detector_type;
|
||||
cairo_save_restore guard(context_);
|
||||
|
||||
debug_symbolizer_mode_enum mode = get<debug_symbolizer_mode_enum>(sym, keys::mode, DEBUG_SYM_MODE_COLLISION);
|
||||
|
||||
context_.set_operator(src_over);
|
||||
context_.set_color(mapnik::color(255, 0, 0), 1.0);
|
||||
context_.set_line_join(MITER_JOIN);
|
||||
context_.set_line_cap(BUTT_CAP);
|
||||
context_.set_miter_limit(4.0);
|
||||
context_.set_line_width(1.0);
|
||||
|
||||
if (mode == DEBUG_SYM_MODE_COLLISION)
|
||||
{
|
||||
typename detector_type::query_iterator itr = common_.detector_->begin();
|
||||
typename detector_type::query_iterator end = common_.detector_->end();
|
||||
for ( ;itr!=end; ++itr)
|
||||
{
|
||||
render_debug_box(context_, itr->box);
|
||||
}
|
||||
}
|
||||
else if (mode == DEBUG_SYM_MODE_VERTEX)
|
||||
{
|
||||
for (auto const& geom : feature.paths())
|
||||
{
|
||||
double x;
|
||||
double y;
|
||||
double z = 0;
|
||||
geom.rewind(0);
|
||||
unsigned cmd = 1;
|
||||
while ((cmd = geom.vertex(&x, &y)) != mapnik::SEG_END)
|
||||
{
|
||||
if (cmd == SEG_CLOSE) continue;
|
||||
prj_trans.backward(x,y,z);
|
||||
common_.t_.forward(&x,&y);
|
||||
context_.move_to(std::floor(x) - 0.5, std::floor(y) + 0.5);
|
||||
context_.line_to(std::floor(x) + 1.5, std::floor(y) + 0.5);
|
||||
context_.move_to(std::floor(x) + 0.5, std::floor(y) - 0.5);
|
||||
context_.line_to(std::floor(x) + 0.5, std::floor(y) + 1.5);
|
||||
context_.stroke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template class cairo_renderer<cairo_surface_ptr>;
|
||||
template class cairo_renderer<cairo_ptr>;
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 8 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 6 KiB After Width: | Height: | Size: 6 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 2 KiB |