diff --git a/benchmark/build.py b/benchmark/build.py index 3b5ff20da..4c62f1825 100644 --- a/benchmark/build.py +++ b/benchmark/build.py @@ -34,7 +34,7 @@ benchmarks = [ #"test_to_double.cpp", #"test_to_int.cpp", #"test_utf_encoding.cpp" - #"test_polygon_clipping.cpp", + "test_polygon_clipping.cpp", #"test_polygon_clipping_rendering.cpp", "test_proj_transform1.cpp", "test_expression_parse.cpp", diff --git a/benchmark/data/polygon_clipping_agg.png b/benchmark/data/polygon_clipping_agg.png index 34709aba3..6c38b39f7 100644 Binary files a/benchmark/data/polygon_clipping_agg.png and b/benchmark/data/polygon_clipping_agg.png differ diff --git a/benchmark/data/polygon_clipping_boost.png b/benchmark/data/polygon_clipping_boost.png index 34709aba3..6c38b39f7 100644 Binary files a/benchmark/data/polygon_clipping_boost.png and b/benchmark/data/polygon_clipping_boost.png differ diff --git a/benchmark/data/polygon_clipping_clipper.png b/benchmark/data/polygon_clipping_clipper.png index a52fd50d9..8d1b11e9c 100644 Binary files a/benchmark/data/polygon_clipping_clipper.png and b/benchmark/data/polygon_clipping_clipper.png differ diff --git a/benchmark/test_polygon_clipping.cpp b/benchmark/test_polygon_clipping.cpp index 9b6184b0c..ac2f34094 100644 --- a/benchmark/test_polygon_clipping.cpp +++ b/benchmark/test_polygon_clipping.cpp @@ -29,14 +29,16 @@ // stl #include +#include -void render(mapnik::geometry_type & geom, +void render(mapnik::geometry_type const& geom, mapnik::box2d const& extent, std::string const& name) { - using path_type = mapnik::transform_path_adapter; + using path_type = mapnik::transform_path_adapter; using ren_base = agg::renderer_base; using renderer = agg::renderer_scanline_aa_solid; + mapnik::vertex_adapter va(geom); mapnik::image_32 im(256,256); im.set_background(mapnik::color("white")); mapnik::box2d padded_extent = extent; @@ -49,13 +51,11 @@ void render(mapnik::geometry_type & geom, ren.color(agg::rgba8(127,127,127,255)); agg::rasterizer_scanline_aa<> ras; mapnik::proj_transform prj_trans(mapnik::projection("+init=epsg:4326"),mapnik::projection("+init=epsg:4326")); - geom.rewind(0); - path_type path(tr,geom,prj_trans); + path_type path(tr,va,prj_trans); ras.add_path(path); agg::scanline_u8 sl; agg::render_scanlines(ras, sl, ren); mapnik::save_to_file(im.data(),name); - geom.rewind(0); } class test1 : public benchmark::test_case @@ -64,7 +64,7 @@ class test1 : public benchmark::test_case mapnik::box2d extent_; std::string expected_; public: - using conv_clip = agg::conv_clip_polygon; + using conv_clip = agg::conv_clip_polygon; test1(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d const& extent) @@ -85,8 +85,9 @@ public: std::clog << "paths.size() != 1\n"; return false; } - mapnik::geometry_type & geom = paths[0]; - conv_clip clipped(geom); + mapnik::geometry_type const& geom = paths[0]; + mapnik::vertex_adapter va(geom); + conv_clip clipped(va); clipped.clip_box( extent_.minx(), extent_.miny(), @@ -100,12 +101,13 @@ public: } std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - if (!mapnik::util::exists(expect)) + auto env = mapnik::envelope(geom); + if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) { std::clog << "generating expected image: " << expect << "\n"; - render(geom2,geom.envelope(),expect); + render(geom2,env,expect); } - render(geom2,geom.envelope(),actual); + render(geom2,env,actual); return benchmark::compare_images(actual,expect); } bool operator()() const @@ -117,9 +119,10 @@ public: } for (unsigned i=0;i extent_; std::string expected_; public: - using poly_clipper = agg::conv_clipper; + using poly_clipper = agg::conv_clipper; test2(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d const& extent) @@ -167,8 +170,9 @@ public: std::clog << "paths.size() != 1\n"; return false; } - mapnik::geometry_type & geom = paths[0]; - poly_clipper clipped(geom,ps, + mapnik::geometry_type const& geom = paths[0]; + mapnik::vertex_adapter va(geom); + poly_clipper clipped(va,ps, agg::clipper_and, agg::clipper_non_zero, agg::clipper_non_zero, @@ -182,12 +186,13 @@ public: } std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - if (!mapnik::util::exists(expect)) + auto env = mapnik::envelope(geom); + if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) { std::clog << "generating expected image: " << expect << "\n"; - render(geom2,geom.envelope(),expect); + render(geom2,env,expect); } - render(geom2,geom.envelope(),actual); + render(geom2,env,actual); return benchmark::compare_images(actual,expect); } bool operator()() const @@ -205,9 +210,10 @@ public: ps.close_polygon(); for (unsigned i=0;i extent_; std::string expected_; public: - using poly_clipper = mapnik::polygon_clipper; + using poly_clipper = mapnik::polygon_clipper; test3(mapnik::parameters const& params, std::string const& wkt_in, mapnik::box2d const& extent) @@ -249,8 +255,9 @@ public: std::clog << "paths.size() != 1\n"; return false; } - mapnik::geometry_type & geom = paths[0]; - poly_clipper clipped(extent_, geom); + mapnik::geometry_type const& geom = paths[0]; + mapnik::vertex_adapter va(geom); + poly_clipper clipped(extent_, va); unsigned cmd; double x,y; mapnik::geometry_type geom2(mapnik::geometry_type::types::Polygon); @@ -259,12 +266,13 @@ public: } std::string expect = expected_+".png"; std::string actual = expected_+"_actual.png"; - if (!mapnik::util::exists(expect)) + auto env = mapnik::envelope(geom); + if (!mapnik::util::exists(expect) || (std::getenv("UPDATE") != nullptr)) { std::clog << "generating expected image: " << expect << "\n"; - render(geom2,geom.envelope(),expect); + render(geom2,env,expect); } - render(geom2,geom.envelope(),actual); + render(geom2,env,actual); return benchmark::compare_images(actual,expect); } bool operator()() const @@ -276,9 +284,10 @@ public: } for (unsigned i=0;i