Found more situations where getRowSize should be used over multiplying the width by the pixel size.
This commit is contained in:
parent
b090882902
commit
bc28c12572
16 changed files with 35 additions and 26 deletions
|
@ -41,7 +41,7 @@ void render(mapnik::geometry_type & geom,
|
|||
mapnik::box2d<double> padded_extent = extent;
|
||||
padded_extent.pad(10);
|
||||
mapnik::view_transform tr(im.width(),im.height(),padded_extent,0,0);
|
||||
agg::rendering_buffer buf(im.getBytes(),im.width(),im.height(), im.width() * 4);
|
||||
agg::rendering_buffer buf(im.getBytes(),im.width(),im.height(), im.getRowSize());
|
||||
agg::pixfmt_rgba32_plain pixf(buf);
|
||||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
|
|
|
@ -81,7 +81,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
&& (std::fabs(0.0 - tr.shx) < agg::affine_epsilon)
|
||||
&& (std::fabs(1.0 - tr.sy) < agg::affine_epsilon))
|
||||
{
|
||||
agg::rendering_buffer src_buffer((unsigned char *)src.getBytes(),src.width(),src.height(),src.width() * 4);
|
||||
agg::rendering_buffer src_buffer((unsigned char *)src.getBytes(),src.width(),src.height(),src.getRowSize());
|
||||
pixfmt_pre pixf_mask(src_buffer);
|
||||
if (snap_to_pixels)
|
||||
{
|
||||
|
@ -125,7 +125,7 @@ void render_raster_marker(RendererType renb, RasterizerType & ras, image_rgba8 c
|
|||
agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(),
|
||||
src.width(),
|
||||
src.height(),
|
||||
src.width()*4);
|
||||
src.getRowSize());
|
||||
pixfmt_pre pixf(marker_buf);
|
||||
img_accessor_type ia(pixf);
|
||||
agg::trans_affine final_tr(p, 0, 0, width, height);
|
||||
|
|
|
@ -401,7 +401,7 @@ void apply_filter(Src & src, Filter const& filter)
|
|||
template <typename Src>
|
||||
void apply_filter(Src & src, agg_stack_blur const& op)
|
||||
{
|
||||
agg::rendering_buffer buf(src.getBytes(),src.width(),src.height(), src.width() * 4);
|
||||
agg::rendering_buffer buf(src.getBytes(),src.width(),src.height(), src.getRowSize());
|
||||
agg::pixfmt_rgba32_pre pixf(buf);
|
||||
agg::stack_blur_rgba32(pixf,op.rx,op.ry);
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ void agg_renderer<T0,T1>::render_marker(pixel_position const& pos,
|
|||
agg::rendering_buffer buf(current_buffer_->getBytes(),
|
||||
current_buffer_->width(),
|
||||
current_buffer_->height(),
|
||||
current_buffer_->width() * 4);
|
||||
current_buffer_->getRowSize());
|
||||
pixfmt_comp_type pixf(buf);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(comp_op));
|
||||
renderer_base renb(pixf);
|
||||
|
@ -416,7 +416,7 @@ void agg_renderer<T0,T1>::render_marker(pixel_position const& pos,
|
|||
agg::rendering_buffer marker_buf((unsigned char *)src.getBytes(),
|
||||
src.width(),
|
||||
src.height(),
|
||||
src.width()*4);
|
||||
src.getRowSize());
|
||||
agg::pixfmt_rgba32_pre marker_pixf(marker_buf);
|
||||
using img_accessor_type = agg::image_accessor_clone<agg::pixfmt_rgba32_pre>;
|
||||
using interpolator_type = agg::span_interpolator_linear<agg::trans_affine>;
|
||||
|
@ -456,7 +456,7 @@ void agg_renderer<T0,T1>::debug_draw_box(box2d<double> const& box,
|
|||
agg::rendering_buffer buf(current_buffer_->getBytes(),
|
||||
current_buffer_->width(),
|
||||
current_buffer_->height(),
|
||||
current_buffer_->width() * 4);
|
||||
current_buffer_->getRowSize());
|
||||
debug_draw_box(buf, box, x, y, angle);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ void agg_renderer<T0,T1>::process(building_symbolizer const& sym,
|
|||
using ren_base = agg::renderer_base<agg::pixfmt_rgba32_pre>;
|
||||
using renderer = agg::renderer_scanline_aa_solid<ren_base>;
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize());
|
||||
agg::pixfmt_rgba32_pre pixf(buf);
|
||||
ren_base renb(pixf);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ void agg_renderer<T0,T1>::process(dot_symbolizer const& sym,
|
|||
double opacity = get<double>(sym, keys::opacity, feature, common_.vars_, 1.0);
|
||||
color const& fill = get<mapnik::color>(sym, keys::fill, feature, common_.vars_, mapnik::color(128,128,128));
|
||||
ras_ptr->reset();
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(),current_buffer_->width() * 4);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(),current_buffer_->getRowSize());
|
||||
using blender_type = agg::comp_op_adaptor_rgba_pre<agg::rgba8, agg::order_rgba>;
|
||||
using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
|
||||
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
|
||||
|
|
|
@ -81,7 +81,7 @@ struct thunk_renderer<image_rgba8>
|
|||
renderer_type,
|
||||
pixfmt_comp_type>;
|
||||
ras_ptr_->reset();
|
||||
buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->width() * 4);
|
||||
buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->getRowSize());
|
||||
pixfmt_comp_type pixf(render_buffer);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(thunk.comp_op_));
|
||||
renderer_base renb(pixf);
|
||||
|
@ -102,7 +102,7 @@ struct thunk_renderer<image_rgba8>
|
|||
using renderer_base = agg::renderer_base<pixfmt_comp_type>;
|
||||
|
||||
ras_ptr_->reset();
|
||||
buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->width() * 4);
|
||||
buf_type render_buffer(buf_->getBytes(), buf_->width(), buf_->height(), buf_->getRowSize());
|
||||
pixfmt_comp_type pixf(render_buffer);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(thunk.comp_op_));
|
||||
renderer_base renb(pixf);
|
||||
|
|
|
@ -103,7 +103,7 @@ void agg_renderer<T0,T1>::process(line_pattern_symbolizer const& sym,
|
|||
value_double simplify_tolerance = get<value_double, keys::simplify_tolerance>(sym, feature, common_.vars_);
|
||||
value_double smooth = get<value_double, keys::smooth>(sym, feature, common_.vars_);
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize());
|
||||
pixfmt_type pixf(buf);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(get<composite_mode_e, keys::comp_op>(sym, feature, common_.vars_)));
|
||||
renderer_base ren_base(pixf);
|
||||
|
|
|
@ -109,7 +109,7 @@ void agg_renderer<T0,T1>::process(line_symbolizer const& sym,
|
|||
gamma_ = gamma;
|
||||
}
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize());
|
||||
|
||||
using color_type = agg::rgba8;
|
||||
using order_type = agg::order_rgba;
|
||||
|
|
|
@ -192,7 +192,7 @@ void agg_renderer<T0,T1>::process(markers_symbolizer const& sym,
|
|||
gamma_ = gamma;
|
||||
}
|
||||
|
||||
buf_type render_buffer(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), current_buffer_->width() * 4);
|
||||
buf_type render_buffer(current_buffer_->getBytes(), current_buffer_->width(), current_buffer_->height(), current_buffer_->getRowSize());
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
|
||||
auto renderer_context = std::tie(render_buffer,*ras_ptr,pixmap_);
|
||||
|
|
|
@ -92,7 +92,7 @@ void agg_renderer<T0,T1>::process(polygon_pattern_symbolizer const& sym,
|
|||
using path_type = transform_path_adapter<view_transform,clipped_geometry_type>;
|
||||
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(), current_buffer_->width(),
|
||||
current_buffer_->height(), current_buffer_->width() * 4);
|
||||
current_buffer_->height(), current_buffer_->getRowSize());
|
||||
ras_ptr->reset();
|
||||
value_double gamma = get<value_double, keys::gamma>(sym, feature, common_.vars_);
|
||||
gamma_method_enum gamma_method = get<gamma_method_enum, keys::gamma_method>(sym, feature, common_.vars_);
|
||||
|
|
|
@ -61,7 +61,7 @@ void agg_renderer<T0,T1>::process(polygon_symbolizer const& sym,
|
|||
}
|
||||
|
||||
box2d<double> clip_box = clipping_extent(common_);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->width() * 4);
|
||||
agg::rendering_buffer buf(current_buffer_->getBytes(),current_buffer_->width(),current_buffer_->height(), current_buffer_->getRowSize());
|
||||
|
||||
render_polygon_symbolizer<vertex_converter_type>(
|
||||
sym, feature, prj_trans, common_, clip_box, *ras_ptr,
|
||||
|
|
|
@ -139,7 +139,7 @@ struct rendering_buffer
|
|||
uint8_t const* buf() const { return data_.getBytes(); }
|
||||
unsigned width() const { return data_.width();}
|
||||
unsigned height() const { return data_.height();}
|
||||
int stride() const { return data_.width() * sizeof(pixel_type);}
|
||||
int stride() const { return data_.getRowSize();}
|
||||
uint8_t const* row_ptr(int, int y, unsigned) {return row_ptr(y);}
|
||||
uint8_t const* row_ptr(int y) const { return reinterpret_cast<uint8_t const*>(data_.getRow(y)); }
|
||||
row_data row (int y) const { return row_data(0, data_.width() - 1, row_ptr(y)); }
|
||||
|
@ -161,7 +161,7 @@ MAPNIK_DECL void composite(image_rgba8 & dst, image_rgba8 const& src, composite_
|
|||
using pixfmt_type = agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer>;
|
||||
using renderer_type = agg::renderer_base<pixfmt_type>;
|
||||
|
||||
agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.width() * 4);
|
||||
agg::rendering_buffer dst_buffer(dst.getBytes(),dst.width(),dst.height(),dst.getRowSize());
|
||||
const_rendering_buffer src_buffer(src);
|
||||
pixfmt_type pixf(dst_buffer);
|
||||
pixf.comp_op(static_cast<agg::comp_op_e>(mode));
|
||||
|
|
|
@ -480,7 +480,7 @@ bool premultiply_visitor::operator()<image_rgba8> (image_rgba8 & data)
|
|||
{
|
||||
if (!data.get_premultiplied())
|
||||
{
|
||||
agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.width() * 4);
|
||||
agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.getRowSize());
|
||||
agg::pixfmt_rgba32 pixf(buffer);
|
||||
pixf.premultiply();
|
||||
data.set_premultiplied(true);
|
||||
|
@ -504,7 +504,7 @@ bool demultiply_visitor::operator()<image_rgba8> (image_rgba8 & data)
|
|||
{
|
||||
if (data.get_premultiplied())
|
||||
{
|
||||
agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.width() * 4);
|
||||
agg::rendering_buffer buffer(data.getBytes(),data.width(),data.height(),data.getRowSize());
|
||||
agg::pixfmt_rgba32_pre pixf(buffer);
|
||||
pixf.demultiply();
|
||||
data.set_premultiplied(false);
|
||||
|
@ -1253,6 +1253,15 @@ template MAPNIK_DECL uint8_t get_pixel(image_any const&, std::size_t, std::size_
|
|||
template MAPNIK_DECL int8_t get_pixel(image_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL float get_pixel(image_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL double get_pixel(image_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL color get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL uint32_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL int32_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL uint16_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL int16_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL uint8_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL int8_t get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL float get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
template MAPNIK_DECL double get_pixel(image_view_any const&, std::size_t, std::size_t);
|
||||
|
||||
|
||||
// Temporary remove these later!
|
||||
|
@ -1452,7 +1461,7 @@ struct visitor_compare
|
|||
template <>
|
||||
MAPNIK_DECL unsigned compare<image_any>(image_any const& im1, image_any const& im2, double threshold, bool alpha)
|
||||
{
|
||||
util::apply_visitor(detail::visitor_compare(im2, threshold, alpha), im1);
|
||||
return util::apply_visitor(detail::visitor_compare(im2, threshold, alpha), im1);
|
||||
}
|
||||
|
||||
} // end ns
|
||||
|
|
|
@ -55,7 +55,7 @@ std::shared_ptr<image_rgba8> render_pattern<image_rgba8>(rasterizer & ras,
|
|||
mtx = tr * mtx;
|
||||
|
||||
std::shared_ptr<mapnik::image_rgba8> image = std::make_shared<mapnik::image_rgba8>(bbox.width(), bbox.height());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4);
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize());
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
@ -98,7 +98,7 @@ std::shared_ptr<image_gray8> render_pattern<image_gray8>(rasterizer & ras,
|
|||
mtx = tr * mtx;
|
||||
|
||||
std::shared_ptr<mapnik::image_gray8> image = std::make_shared<mapnik::image_gray8>(bbox.width(), bbox.height());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize());
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
@ -132,7 +132,7 @@ std::shared_ptr<image_gray16> render_pattern<image_gray16>(rasterizer & ras,
|
|||
mtx = tr * mtx;
|
||||
|
||||
std::shared_ptr<mapnik::image_gray16> image = std::make_shared<mapnik::image_gray16>(bbox.width(), bbox.height());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 2);
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize());
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
@ -166,7 +166,7 @@ std::shared_ptr<image_gray32f> render_pattern<image_gray32f>(rasterizer & ras,
|
|||
mtx = tr * mtx;
|
||||
|
||||
std::shared_ptr<mapnik::image_gray32f> image = std::make_shared<mapnik::image_gray32f>(bbox.width(), bbox.height());
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->width() * 4);
|
||||
agg::rendering_buffer buf(image->getBytes(), image->width(), image->height(), image->getRowSize());
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ int main (int argc,char** argv)
|
|||
}
|
||||
// 10 pixel buffer to avoid edge clipping of 100% svg's
|
||||
mapnik::image_rgba8 im(w+0,h+0);
|
||||
agg::rendering_buffer buf(im.getBytes(), im.width(), im.height(), im.width() * 4);
|
||||
agg::rendering_buffer buf(im.getBytes(), im.width(), im.height(), im.getRowSize());
|
||||
pixfmt pixf(buf);
|
||||
renderer_base renb(pixf);
|
||||
|
||||
|
|
Loading…
Reference in a new issue