diff --git a/include/mapnik/agg_renderer.hpp b/include/mapnik/agg_renderer.hpp index e5d93799c..08a48d44a 100644 --- a/include/mapnik/agg_renderer.hpp +++ b/include/mapnik/agg_renderer.hpp @@ -109,6 +109,10 @@ public: // agg renderer doesn't support processing of multiple symbolizers. return false; }; + void painted(bool painted) + { + pixmap_.painted(painted); + } private: T & pixmap_; diff --git a/include/mapnik/cairo_renderer.hpp b/include/mapnik/cairo_renderer.hpp index d140c6495..60a79b144 100644 --- a/include/mapnik/cairo_renderer.hpp +++ b/include/mapnik/cairo_renderer.hpp @@ -125,6 +125,11 @@ public: // cairo renderer doesn't support processing of multiple symbolizers. return false; }; + void painted(bool /*painted*/) + { + // nothing to do + } + protected: void render_marker(const int x, const int y, marker &marker, const agg::trans_affine & mtx, double opacity=1.0); diff --git a/include/mapnik/graphics.hpp b/include/mapnik/graphics.hpp index 3fc49aea5..421e29287 100644 --- a/include/mapnik/graphics.hpp +++ b/include/mapnik/graphics.hpp @@ -24,6 +24,7 @@ #ifndef GRAPHICS_HPP #define GRAPHICS_HPP + // mapnik #include #include @@ -42,6 +43,9 @@ #include #endif +// boost +#include + namespace mapnik { @@ -140,8 +144,9 @@ class MAPNIK_DECL image_32 private: unsigned width_; unsigned height_; - color background_; + boost::optional background_; image_data_32 data_; + bool painted_; public: image_32(int width,int height); image_32(image_32 const& rhs); @@ -149,10 +154,20 @@ public: image_32(Cairo::RefPtr rhs); #endif ~image_32(); - - void set_background(color const& background); - const color& get_background() const; + void painted(bool painted) + { + painted_ = painted; + } + + bool painted() const + { + return painted_; + } + + boost::optional const& get_background() const; + + void set_background(const color& c); void set_grayscale_to_alpha(); diff --git a/include/mapnik/grid/grid.hpp b/include/mapnik/grid/grid.hpp index 9e7fd897e..bf644bb22 100644 --- a/include/mapnik/grid/grid.hpp +++ b/include/mapnik/grid/grid.hpp @@ -65,6 +65,7 @@ private: data_type data_; std::set names_; unsigned int resolution_; + bool painted_; public: @@ -94,6 +95,16 @@ public: ~hit_grid() {} + void painted(bool painted) + { + painted_ = painted; + } + + bool painted() const + { + return painted_; + } + void add_feature(mapnik::Feature const& feature) { diff --git a/include/mapnik/grid/grid_renderer.hpp b/include/mapnik/grid/grid_renderer.hpp index 6f15cd13b..54b0bae29 100644 --- a/include/mapnik/grid/grid_renderer.hpp +++ b/include/mapnik/grid/grid_renderer.hpp @@ -108,6 +108,10 @@ public: // grid renderer doesn't support processing of multiple symbolizers. return false; }; + void painted(bool painted) + { + pixmap_.painted(painted); + } private: T & pixmap_; diff --git a/src/feature_style_processor.cpp b/src/feature_style_processor.cpp index 63e1a64e0..5afdb5d3e 100644 --- a/src/feature_style_processor.cpp +++ b/src/feature_style_processor.cpp @@ -423,6 +423,8 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces #if defined(RENDERING_STATS) feat_processed = true; #endif + + p.painted(true); do_else=false; do_also=true; @@ -454,6 +456,8 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces #if defined(RENDERING_STATS) feat_processed = true; #endif + + p.painted(true); rule::symbolizers const& symbols = r->get_symbolizers(); // if the underlying renderer is not able to process the complete set of symbolizers, @@ -476,6 +480,8 @@ void feature_style_processor::apply_to_layer(layer const& lay, Proces #if defined(RENDERING_STATS) feat_processed = true; #endif + + p.painted(true); rule::symbolizers const& symbols = r->get_symbolizers(); // if the underlying renderer is not able to process the complete set of symbolizers, diff --git a/src/graphics.cpp b/src/graphics.cpp index b42b9dc85..46f30d3c7 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -40,12 +40,14 @@ namespace mapnik image_32::image_32(int width,int height) :width_(width), height_(height), - data_(width,height) {} + data_(width,height), + painted_(false) {} image_32::image_32(const image_32& rhs) :width_(rhs.width_), height_(rhs.height_), - data_(rhs.data_) {} + data_(rhs.data_), + painted_(rhs.painted_) {} #ifdef HAVE_CAIRO image_32::image_32(Cairo::RefPtr rhs) @@ -53,6 +55,7 @@ image_32::image_32(Cairo::RefPtr rhs) height_(rhs->get_height()), data_(rhs->get_width(),rhs->get_height()) { + painted_ = true; if (rhs->get_format() != Cairo::FORMAT_ARGB32) { std::cerr << "Unable to convert this Cairo format\n"; @@ -159,14 +162,15 @@ void image_32::set_alpha(float opacity) } -void image_32::set_background(const color& background) +void image_32::set_background(const color& c) { - background_=background; - data_.set(background_.rgba()); + background_=c; + data_.set(background_->rgba()); } -const color& image_32::get_background() const +boost::optional const& image_32::get_background() const { return background_; } + }