diff --git a/include/mapnik/renderer_common/process_raster_symbolizer.hpp b/include/mapnik/renderer_common/process_raster_symbolizer.hpp index 507bcacf0..77798dcb8 100644 --- a/include/mapnik/renderer_common/process_raster_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_raster_symbolizer.hpp @@ -23,6 +23,9 @@ #ifndef MAPNIK_RENDERER_COMMON_PROCESS_RASTER_SYMBOLIZER_HPP #define MAPNIK_RENDERER_COMMON_PROCESS_RASTER_SYMBOLIZER_HPP +// mapnik +#include + // agg #include "agg_rendering_buffer.h" #include "agg_pixfmt_rgba.h" @@ -55,10 +58,8 @@ void render_raster_symbolizer(raster_symbolizer const &sym, int raster_height = end_y - start_y; if (raster_width > 0 && raster_height > 0) { - raster target(target_ext, raster_width, raster_height, source->get_filter_factor()); scaling_method_e scaling_method = get(sym, keys::scaling, feature, common.vars_, SCALING_NEAR); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common.vars_, src_over); - double opacity = get(sym,keys::opacity,feature, common.vars_, 1.0); bool premultiply_source = !source->premultiplied_alpha_; auto is_premultiplied = get_optional(sym, keys::premultiplied, feature, common.vars_); @@ -80,6 +81,7 @@ void render_raster_symbolizer(raster_symbolizer const &sym, { double offset_x = ext.minx() - start_x; double offset_y = ext.miny() - start_y; + raster target(target_ext, raster_width, raster_height, source->get_filter_factor()); unsigned mesh_size = static_cast(get(sym,keys::mesh_size,feature, common.vars_, 16)); reproject_and_scale_raster(target, *source, @@ -88,31 +90,46 @@ void render_raster_symbolizer(raster_symbolizer const &sym, offset_y, mesh_size, scaling_method); + composite(target.data_, comp_op, opacity, start_x, start_y); } else { - if (scaling_method == SCALING_BILINEAR8) + double image_ratio_x = ext.width() / source->data_.width(); + double image_ratio_y = ext.height() / source->data_.height(); + double eps = 1e-5; + if ( (std::fabs(image_ratio_x - 1) <= eps) && + (std::fabs(image_ratio_y - 1) <= eps) && + (std::fabs(start_x) <= eps) && + (std::fabs(start_y) <= eps) ) { - scale_image_bilinear8(target.data_, - source->data_, - 0.0, - 0.0); + composite(source->data_, comp_op, opacity, start_x, start_y); } else { - double image_ratio_x = ext.width() / source->data_.width(); - double image_ratio_y = ext.height() / source->data_.height(); - scale_image_agg(target.data_, - source->data_, - scaling_method, - image_ratio_x, - image_ratio_y, - 0.0, - 0.0, - source->get_filter_factor()); + raster target(target_ext, raster_width, raster_height, source->get_filter_factor()); + if (scaling_method == SCALING_BILINEAR8) + { + scale_image_bilinear8(target.data_, + source->data_, + 0.0, + 0.0); + } + else + { + double image_ratio_x = ext.width() / source->data_.width(); + double image_ratio_y = ext.height() / source->data_.height(); + scale_image_agg(target.data_, + source->data_, + scaling_method, + image_ratio_x, + image_ratio_y, + 0.0, + 0.0, + source->get_filter_factor()); + } + composite(target.data_, comp_op, opacity, start_x, start_y); } } - composite(target, comp_op, opacity, start_x, start_y); } } } diff --git a/src/agg/process_raster_symbolizer.cpp b/src/agg/process_raster_symbolizer.cpp index cd1023d71..e79664f3b 100644 --- a/src/agg/process_raster_symbolizer.cpp +++ b/src/agg/process_raster_symbolizer.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -53,11 +52,12 @@ void agg_renderer::process(raster_symbolizer const& sym, { render_raster_symbolizer( sym, feature, prj_trans, common_, - [&](raster &target, composite_mode_e comp_op, double opacity, + [&](image_data_32 & target, composite_mode_e comp_op, double opacity, int start_x, int start_y) { - composite(current_buffer_->data(), target.data_, + composite(current_buffer_->data(), target, comp_op, opacity, start_x, start_y, false); - }); + } + ); } template void agg_renderer::process(raster_symbolizer const&, diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index e2fe71777..33eb1db1e 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -761,14 +761,14 @@ void cairo_renderer_base::process(raster_symbolizer const& sym, proj_transform const& prj_trans) { cairo_save_restore guard(context_); - render_raster_symbolizer( sym, feature, prj_trans, common_, - [&](raster &target, composite_mode_e comp_op, double opacity, + [&](image_data_32 &target, composite_mode_e comp_op, double opacity, int start_x, int start_y) { context_.set_operator(comp_op); - context_.add_image(start_x, start_y, target.data_, opacity); - }); + context_.add_image(start_x, start_y, target, opacity); + } + ); } namespace detail {