From e6a32f22cf2e697598a7c6347eb9b6d82acfb41a Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 16 Sep 2014 14:35:04 +0200 Subject: [PATCH 1/2] fix image painted --- include/mapnik/agg_renderer.hpp | 2 ++ include/mapnik/cairo/cairo_renderer.hpp | 6 ++++++ include/mapnik/feature_style_processor_impl.hpp | 2 +- include/mapnik/grid/grid_renderer.hpp | 8 ++++++++ src/agg/agg_renderer.cpp | 6 ++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index 4af527db9..627ee61f9 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -132,6 +132,8 @@ public: } void painted(bool painted); + bool painted(); + inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; diff --git a/include/mapnik/cairo/cairo_renderer.hpp b/include/mapnik/cairo/cairo_renderer.hpp index 0abfc7294..fe9f81914 100644 --- a/include/mapnik/cairo/cairo_renderer.hpp +++ b/include/mapnik/cairo/cairo_renderer.hpp @@ -140,6 +140,12 @@ public: // cairo renderer doesn't support processing of multiple symbolizers. return false; } + + bool painted() + { + return true; + } + void painted(bool /*painted*/) { // nothing to do diff --git a/include/mapnik/feature_style_processor_impl.hpp b/include/mapnik/feature_style_processor_impl.hpp index 78a97cd4c..f061346d2 100644 --- a/include/mapnik/feature_style_processor_impl.hpp +++ b/include/mapnik/feature_style_processor_impl.hpp @@ -707,7 +707,7 @@ void feature_style_processor::render_style( } } } - p.painted(was_painted); + p.painted(p.painted() | was_painted); p.end_style_processing(*style); } diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index 27b09a2fe..d3325444c 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -119,14 +119,22 @@ public: // grid renderer doesn't support processing of multiple symbolizers. return false; } + + bool painted() + { + pixmap_.painted(); + } + void painted(bool painted) { pixmap_.painted(painted); } + inline eAttributeCollectionPolicy attribute_collection_policy() const { return DEFAULT; } + inline double scale_factor() const { return common_.scale_factor_; diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 56f9be003..123f4ea11 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -437,6 +437,12 @@ void agg_renderer::render_marker(pixel_position const& pos, } } +template +bool agg_renderer::painted() +{ + return pixmap_.painted(); +} + template void agg_renderer::painted(bool painted) { From dc57f7251c8a51bf949333285423ad1036e5e2ec Mon Sep 17 00:00:00 2001 From: Jiri Drbalek Date: Tue, 16 Sep 2014 18:42:50 +0200 Subject: [PATCH 2/2] add c++ test image painted --- tests/cpp_tests/image_painted_test.cpp | 85 ++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 tests/cpp_tests/image_painted_test.cpp diff --git a/tests/cpp_tests/image_painted_test.cpp b/tests/cpp_tests/image_painted_test.cpp new file mode 100644 index 000000000..57cfded73 --- /dev/null +++ b/tests/cpp_tests/image_painted_test.cpp @@ -0,0 +1,85 @@ +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +int main(int argc, char** argv) +{ + std::vector args; + for (int i = 1; i < argc; ++i) + { + args.push_back(argv[i]); + } + bool quiet = std::find(args.begin(), args.end(), "-q") != args.end(); + + using namespace mapnik; + + try + { + datasource_cache::instance().register_datasources("plugins/input/"); + + Map m(256, 256); + + feature_type_style lines_style; + { + rule r; + line_symbolizer line_sym; + r.append(std::move(line_sym)); + lines_style.add_rule(std::move(r)); + } + m.insert_style("lines", std::move(lines_style)); + + feature_type_style markers_style; + { + rule r; + r.set_filter(parse_expression("False")); + markers_symbolizer mark_sym; + r.append(std::move(mark_sym)); + markers_style.add_rule(std::move(r)); + } + m.insert_style("markers", std::move(markers_style)); + + parameters p; + p["type"] = "csv"; + p["separator"] = "|"; + p["inline"] = "wkt\nLINESTRING(-10 0, 0 20, 10 0, 15 5)"; + + layer lyr("layer"); + lyr.set_datasource(datasource_cache::instance().create(p)); + lyr.add_style("lines"); + lyr.add_style("markers"); + m.add_layer(lyr); + + m.zoom_all(); + + image_32 image(m.width(), m.height()); + agg_renderer ren(m, image); + ren.apply(); + + BOOST_TEST_EQ(image.painted(), true); + } + catch (std::exception const & ex) + { + std::clog << "C++ image painted problem: " << ex.what() << std::endl; + BOOST_TEST(false); + } + + if (::boost::detail::test_errors()) + { + return ::boost::report_errors(); + } + else + { + if (quiet) std::clog << "\x1b[1;32m.\x1b[0m"; + else std::clog << "C++ image painted: \x1b[1;32m✓ \x1b[0m\n"; + ::boost::detail::report_errors_remind().called_report_errors_function = true; + } +}