Merge branch 'master' of github.com:mapnik/mapnik into jh-min-repeat-distance
|
@ -53,6 +53,6 @@ before_script:
|
|||
script:
|
||||
- if [[ ${BENCHMARK} != False ]]; then make bench; fi;
|
||||
# install some exotic fonts to ensure we don't crash registering them
|
||||
- sudo apt-get install ttf-wqy-microhei
|
||||
- source localize.sh
|
||||
- python -c "import mapnik;mapnik.logger.set_severity(mapnik.severity_type.Debug);mapnik.register_fonts('/usr/share/fonts/');mapnik.register_fonts('/usr/share/fonts/');print '\n'.join(list(mapnik.FontEngine.instance().face_names()))"
|
||||
#- sudo apt-get install ttf-wqy-microhei
|
||||
#- source localize.sh
|
||||
#- python -c "import mapnik;mapnik.logger.set_severity(mapnik.severity_type.Debug);mapnik.register_fonts('/usr/share/fonts/');mapnik.register_fonts('/usr/share/fonts/');print '\n'.join(list(mapnik.FontEngine.instance().face_names()))"
|
||||
|
|
|
@ -533,9 +533,11 @@ void render_cairo(mapnik::Map const& map, double scaling_factor, QPixmap & pix)
|
|||
#ifdef HAVE_CAIRO
|
||||
mapnik::cairo_surface_ptr image_surface(cairo_image_surface_create(CAIRO_FORMAT_ARGB32,map.width(),map.height()),
|
||||
mapnik::cairo_surface_closer());
|
||||
mapnik::cairo_renderer<mapnik::cairo_surface_ptr> renderer(map, image_surface, scaling_factor);
|
||||
mapnik::cairo_ptr cairo = mapnik::create_context(image_surface);
|
||||
if (cairo)
|
||||
{
|
||||
mapnik::auto_cpu_timer t(std::clog, "rendering took: ");
|
||||
mapnik::cairo_renderer<mapnik::cairo_ptr> renderer(map, cairo, scaling_factor);
|
||||
renderer.apply();
|
||||
}
|
||||
image_32 buf(image_surface);
|
||||
|
|
|
@ -36,8 +36,9 @@ namespace mapnik
|
|||
class pattern_source : private mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
pattern_source(image_data_32 const& pattern)
|
||||
: pattern_(pattern) {}
|
||||
pattern_source(image_data_32 const& pattern, double opacity = 1.0)
|
||||
: pattern_(pattern),
|
||||
opacity_(opacity) {}
|
||||
|
||||
unsigned int width() const
|
||||
{
|
||||
|
@ -50,13 +51,14 @@ public:
|
|||
agg::rgba8 pixel(int x, int y) const
|
||||
{
|
||||
unsigned c = pattern_(x,y);
|
||||
return agg::rgba8(c & 0xff,
|
||||
(c >> 8) & 0xff,
|
||||
(c >> 16) & 0xff,
|
||||
(c >> 24) & 0xff);
|
||||
return agg::rgba8(static_cast<unsigned>((c & 0xff) * opacity_),
|
||||
static_cast<unsigned>(((c >> 8) & 0xff) * opacity_),
|
||||
static_cast<unsigned>(((c >> 16) & 0xff) * opacity_),
|
||||
static_cast<unsigned>(((c >> 24) & 0xff) * opacity_));
|
||||
}
|
||||
private:
|
||||
image_data_32 const& pattern_;
|
||||
double opacity_;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ private:
|
|||
class cairo_pattern : private mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
cairo_pattern(image_data_32 const& data)
|
||||
explicit cairo_pattern(image_data_32 const& data, double opacity = 1.0)
|
||||
{
|
||||
int pixels = data.width() * data.height();
|
||||
const unsigned int *in_ptr = data.getData();
|
||||
|
@ -135,10 +135,10 @@ public:
|
|||
while (in_ptr < in_end)
|
||||
{
|
||||
unsigned int in = *in_ptr++;
|
||||
unsigned int r = (in >> 0) & 0xff;
|
||||
unsigned int g = (in >> 8) & 0xff;
|
||||
unsigned int b = (in >> 16) & 0xff;
|
||||
unsigned int a = (in >> 24) & 0xff;
|
||||
unsigned int r = static_cast<unsigned>(((in >> 0) & 0xff) * opacity);
|
||||
unsigned int g = static_cast<unsigned>(((in >> 8) & 0xff) * opacity);
|
||||
unsigned int b = static_cast<unsigned>(((in >> 16) & 0xff) * opacity);
|
||||
unsigned int a = static_cast<unsigned>(((in >> 24) & 0xff) * opacity);
|
||||
|
||||
//r = r * a / 255;
|
||||
//g = g * a / 255;
|
||||
|
|
|
@ -50,39 +50,6 @@
|
|||
#include "agg_renderer_outline_image.h"
|
||||
#include "agg_conv_clip_polyline.h"
|
||||
|
||||
// boost
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
class pattern_source : private mapnik::noncopyable
|
||||
{
|
||||
public:
|
||||
pattern_source(mapnik::image_data_32 const& pattern)
|
||||
: pattern_(pattern) {}
|
||||
|
||||
inline unsigned int width() const
|
||||
{
|
||||
return pattern_.width();
|
||||
}
|
||||
inline unsigned int height() const
|
||||
{
|
||||
return pattern_.height();
|
||||
}
|
||||
inline agg::rgba8 pixel(int x, int y) const
|
||||
{
|
||||
unsigned c = pattern_(x,y);
|
||||
return agg::rgba8_pre(c & 0xff,
|
||||
(c >> 8) & 0xff,
|
||||
(c >> 16) & 0xff,
|
||||
(c >> 24) & 0xff);
|
||||
}
|
||||
private:
|
||||
mapnik::image_data_32 const& pattern_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T0, typename T1>
|
||||
|
@ -117,7 +84,7 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
|
||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||
if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr, opacity);
|
||||
pat = render_pattern(*ras_ptr, **marker_ptr, image_tr, 1.0);
|
||||
}
|
||||
|
||||
if (!pat) return;
|
||||
|
@ -133,7 +100,7 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
renderer_base ren_base(pixf);
|
||||
agg::pattern_filter_bilinear_rgba8 filter;
|
||||
|
||||
pattern_source source(*(*pat));
|
||||
pattern_source source(*(*pat), opacity);
|
||||
pattern_type pattern (filter,source);
|
||||
renderer_type ren(ren_base, pattern);
|
||||
rasterizer_type ras(ren);
|
||||
|
|
|
@ -226,6 +226,7 @@ void cairo_renderer<T>::render_marker(pixel_position const& pos,
|
|||
}
|
||||
|
||||
template class cairo_renderer<cairo_ptr>;
|
||||
|
||||
}
|
||||
|
||||
#endif // HAVE_CAIRO
|
||||
|
|
|
@ -73,7 +73,7 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
double opacity = get<value_double>(sym, keys::opacity, feature, common_.vars_,1.0);
|
||||
if ((*marker)->is_bitmap())
|
||||
{
|
||||
pattern = std::make_unique<cairo_pattern>(**((*marker)->get_bitmap_data()));
|
||||
pattern = std::make_unique<cairo_pattern>(**((*marker)->get_bitmap_data()), opacity);
|
||||
context_.set_line_width(height);
|
||||
}
|
||||
else
|
||||
|
@ -82,8 +82,8 @@ void cairo_renderer<T>::process(line_pattern_symbolizer const& sym,
|
|||
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
|
||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||
if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform);
|
||||
image = render_pattern(ras, **marker, image_tr, opacity);
|
||||
pattern = std::make_unique<cairo_pattern>(*image);
|
||||
image = render_pattern(ras, **marker, image_tr, 1.0);
|
||||
pattern = std::make_unique<cairo_pattern>(*image, opacity);
|
||||
width = image->width();
|
||||
height = image->height();
|
||||
context_.set_line_width(height);
|
||||
|
|
|
@ -47,7 +47,7 @@ void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
bool clip = get<bool>(sym, keys::clip, feature, common_.vars_, false);
|
||||
double simplify_tolerance = get<double>(sym, keys::simplify_tolerance, feature, common_.vars_, 0.0);
|
||||
double smooth = get<double>(sym, keys::smooth, feature, common_.vars_, 0.0);
|
||||
|
||||
double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0);
|
||||
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
|
||||
auto image_transform = get_optional<transform_type>(sym, keys::image_transform);
|
||||
if (image_transform) evaluate_transform(image_tr, feature, common_.vars_, *image_transform);
|
||||
|
@ -83,7 +83,7 @@ void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
if ((*marker)->is_bitmap())
|
||||
{
|
||||
cairo_pattern pattern(**((*marker)->get_bitmap_data()));
|
||||
cairo_pattern pattern(**((*marker)->get_bitmap_data()), opacity);
|
||||
pattern.set_extend(CAIRO_EXTEND_REPEAT);
|
||||
pattern.set_origin(offset_x, offset_y);
|
||||
context_.set_pattern(pattern);
|
||||
|
@ -91,9 +91,8 @@ void cairo_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
else
|
||||
{
|
||||
mapnik::rasterizer ras;
|
||||
double opacity = get<double>(sym,keys::opacity, feature, common_.vars_, 1.0);
|
||||
image_ptr image = render_pattern(ras, **marker, image_tr, opacity);
|
||||
cairo_pattern pattern(*image);
|
||||
image_ptr image = render_pattern(ras, **marker, image_tr, 1.0); //
|
||||
cairo_pattern pattern(*image, opacity);
|
||||
pattern.set_extend(CAIRO_EXTEND_REPEAT);
|
||||
pattern.set_origin(offset_x, offset_y);
|
||||
context_.set_pattern(pattern);
|
||||
|
|
Before Width: | Height: | Size: 7.8 KiB After Width: | Height: | Size: 7.8 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |