renderers can now report to image if any features have been rendered via im.painted(), and im.background now uses boost optional to allow easy detection of whether a background has been set - closes #875
This commit is contained in:
parent
6752760c9a
commit
0ec7ef6d46
7 changed files with 59 additions and 10 deletions
|
@ -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_;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#ifndef GRAPHICS_HPP
|
||||
#define GRAPHICS_HPP
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/color.hpp>
|
||||
#include <mapnik/gamma.hpp>
|
||||
|
@ -42,6 +43,9 @@
|
|||
#include <cairomm/surface.h>
|
||||
#endif
|
||||
|
||||
// boost
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
namespace mapnik
|
||||
{
|
||||
|
||||
|
@ -140,8 +144,9 @@ class MAPNIK_DECL image_32
|
|||
private:
|
||||
unsigned width_;
|
||||
unsigned height_;
|
||||
color background_;
|
||||
boost::optional<color> background_;
|
||||
image_data_32 data_;
|
||||
bool painted_;
|
||||
public:
|
||||
image_32(int width,int height);
|
||||
image_32(image_32 const& rhs);
|
||||
|
@ -150,9 +155,19 @@ public:
|
|||
#endif
|
||||
~image_32();
|
||||
|
||||
void set_background(color const& background);
|
||||
void painted(bool painted)
|
||||
{
|
||||
painted_ = painted;
|
||||
}
|
||||
|
||||
const color& get_background() const;
|
||||
bool painted() const
|
||||
{
|
||||
return painted_;
|
||||
}
|
||||
|
||||
boost::optional<color> const& get_background() const;
|
||||
|
||||
void set_background(const color& c);
|
||||
|
||||
void set_grayscale_to_alpha();
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ private:
|
|||
data_type data_;
|
||||
std::set<std::string> 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)
|
||||
{
|
||||
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -424,6 +424,8 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
feat_processed = true;
|
||||
#endif
|
||||
|
||||
p.painted(true);
|
||||
|
||||
do_else=false;
|
||||
do_also=true;
|
||||
rule::symbolizers const& symbols = r->get_symbolizers();
|
||||
|
@ -455,6 +457,8 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
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,
|
||||
// process one by one.
|
||||
|
@ -477,6 +481,8 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
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,
|
||||
// process one by one.
|
||||
|
|
|
@ -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<Cairo::ImageSurface> rhs)
|
||||
|
@ -53,6 +55,7 @@ image_32::image_32(Cairo::RefPtr<Cairo::ImageSurface> 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<color> const& image_32::get_background() const
|
||||
{
|
||||
return background_;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue