From 6815ac28699a1b5b5d983e615f4271fee33e94d6 Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Wed, 14 Feb 2018 16:49:31 +0100 Subject: [PATCH] use multiplication instead of << to avoid undefined behavour when LHS is a negative int (-fsanitize=undefined) --- deps/agg/include/agg_line_aa_basics.h | 46 +-- deps/agg/include/agg_renderer_outline_aa.h | 372 +++++++++--------- deps/agg/include/agg_renderer_outline_image.h | 265 +++++++------ 3 files changed, 341 insertions(+), 342 deletions(-) diff --git a/deps/agg/include/agg_line_aa_basics.h b/deps/agg/include/agg_line_aa_basics.h index 6726b9dce..d22711d8c 100644 --- a/deps/agg/include/agg_line_aa_basics.h +++ b/deps/agg/include/agg_line_aa_basics.h @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -21,7 +21,7 @@ namespace agg { - // See Implementation agg_line_aa_basics.cpp + // See Implementation agg_line_aa_basics.cpp //------------------------------------------------------------------------- enum line_subpixel_scale_e @@ -37,26 +37,26 @@ namespace agg enum line_mr_subpixel_scale_e { line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift - line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale - line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask + line_mr_subpixel_scale = 1 << line_mr_subpixel_shift, //----line_mr_subpixel_scale + line_mr_subpixel_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask }; //------------------------------------------------------------------line_mr - AGG_INLINE int line_mr(int x) - { - return x >> (line_subpixel_shift - line_mr_subpixel_shift); + AGG_INLINE int line_mr(int x) + { + return x >> (line_subpixel_shift - line_mr_subpixel_shift); } //-------------------------------------------------------------------line_hr - AGG_INLINE int line_hr(int x) - { - return x << (line_subpixel_shift - line_mr_subpixel_shift); + AGG_INLINE int line_hr(int x) + { + return x << (line_subpixel_shift - line_mr_subpixel_shift); } //---------------------------------------------------------------line_dbl_hr - AGG_INLINE int line_dbl_hr(int x) - { - return x << line_subpixel_shift; + AGG_INLINE int line_dbl_hr(int x) + { + return x * line_subpixel_scale; } //---------------------------------------------------------------line_coord @@ -83,7 +83,7 @@ namespace agg //--------------------------------------------------------------------- line_parameters() {} line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) : - x1(x1_), y1(y1_), x2(x2_), y2(y2_), + x1(x1_), y1(y1_), x2(x2_), y2(y2_), dx(std::abs(x2_ - x1_)), dy(std::abs(y2_ - y1_)), sx((x2_ > x1_) ? 1 : -1), @@ -133,7 +133,7 @@ namespace agg lp2.dx = std::abs(lp2.x2 - lp2.x1); lp2.dy = std::abs(lp2.y2 - lp2.y1); } - + //--------------------------------------------------------------------- int x1, y1, x2, y2, dx, dy, sx, sy; bool vertical; @@ -148,19 +148,19 @@ namespace agg - // See Implementation agg_line_aa_basics.cpp + // See Implementation agg_line_aa_basics.cpp //----------------------------------------------------------------bisectrix - void bisectrix(const line_parameters& l1, - const line_parameters& l2, + void bisectrix(const line_parameters& l1, + const line_parameters& l2, int* x, int* y); //-------------------------------------------fix_degenerate_bisectrix_start - void inline fix_degenerate_bisectrix_start(const line_parameters& lp, + void inline fix_degenerate_bisectrix_start(const line_parameters& lp, int* x, int* y) { - int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - + int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); if(d < line_subpixel_scale/2) { @@ -171,10 +171,10 @@ namespace agg //---------------------------------------------fix_degenerate_bisectrix_end - void inline fix_degenerate_bisectrix_end(const line_parameters& lp, + void inline fix_degenerate_bisectrix_end(const line_parameters& lp, int* x, int* y) { - int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - + int d = iround((double(*x - lp.x2) * double(lp.y2 - lp.y1) - double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len); if(d < line_subpixel_scale/2) { diff --git a/deps/agg/include/agg_renderer_outline_aa.h b/deps/agg/include/agg_renderer_outline_aa.h index a0c910b6d..b2d3dd42b 100644 --- a/deps/agg/include/agg_renderer_outline_aa.h +++ b/deps/agg/include/agg_renderer_outline_aa.h @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -36,11 +36,11 @@ namespace agg distance_interpolator0(int x1, int y1, int x2, int y2, int x, int y) : m_dx(line_mr(x2) - line_mr(x1)), m_dy(line_mr(y2) - line_mr(y1)), - m_dist((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy - + m_dist((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx) { - m_dx <<= line_mr_subpixel_shift; - m_dy <<= line_mr_subpixel_shift; + m_dx *= line_mr_subpixel_scale; + m_dy *= line_mr_subpixel_scale; } //--------------------------------------------------------------------- @@ -60,22 +60,22 @@ namespace agg public: //--------------------------------------------------------------------- distance_interpolator00() {} - distance_interpolator00(int xc, int yc, - int x1, int y1, int x2, int y2, + distance_interpolator00(int xc, int yc, + int x1, int y1, int x2, int y2, int x, int y) : m_dx1(line_mr(x1) - line_mr(xc)), m_dy1(line_mr(y1) - line_mr(yc)), m_dx2(line_mr(x2) - line_mr(xc)), m_dy2(line_mr(y2) - line_mr(yc)), - m_dist1((line_mr(x + line_subpixel_scale/2) - line_mr(x1)) * m_dy1 - + m_dist1((line_mr(x + line_subpixel_scale/2) - line_mr(x1)) * m_dy1 - (line_mr(y + line_subpixel_scale/2) - line_mr(y1)) * m_dx1), - m_dist2((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy2 - + m_dist2((line_mr(x + line_subpixel_scale/2) - line_mr(x2)) * m_dy2 - (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx2) { - m_dx1 <<= line_mr_subpixel_shift; - m_dy1 <<= line_mr_subpixel_shift; - m_dx2 <<= line_mr_subpixel_shift; - m_dy2 <<= line_mr_subpixel_shift; + m_dx1 *= line_mr_subpixel_scale; + m_dy1 *= line_mr_subpixel_scale; + m_dx2 *= line_mr_subpixel_scale; + m_dy2 *= line_mr_subpixel_scale; } //--------------------------------------------------------------------- @@ -102,11 +102,11 @@ namespace agg distance_interpolator1(int x1, int y1, int x2, int y2, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))) { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; + m_dx *= line_subpixel_scale; + m_dy *= line_subpixel_scale; } //--------------------------------------------------------------------- @@ -118,33 +118,33 @@ namespace agg //--------------------------------------------------------------------- void inc_x(int dy) { - m_dist += m_dy; - if(dy > 0) m_dist -= m_dx; - if(dy < 0) m_dist += m_dx; + m_dist += m_dy; + if(dy > 0) m_dist -= m_dx; + if(dy < 0) m_dist += m_dx; } //--------------------------------------------------------------------- void dec_x(int dy) { - m_dist -= m_dy; - if(dy > 0) m_dist -= m_dx; - if(dy < 0) m_dist += m_dx; + m_dist -= m_dy; + if(dy > 0) m_dist -= m_dx; + if(dy < 0) m_dist += m_dx; } //--------------------------------------------------------------------- void inc_y(int dx) { - m_dist -= m_dx; - if(dx > 0) m_dist += m_dy; - if(dx < 0) m_dist -= m_dy; + m_dist -= m_dx; + if(dx > 0) m_dist += m_dy; + if(dx < 0) m_dist -= m_dy; } void dec_y(int dx) //--------------------------------------------------------------------- { - m_dist += m_dx; - if(dx > 0) m_dist += m_dy; - if(dx < 0) m_dist -= m_dy; + m_dist += m_dx; + if(dx > 0) m_dist += m_dy; + if(dx < 0) m_dist -= m_dy; } //--------------------------------------------------------------------- @@ -176,16 +176,16 @@ namespace agg m_dx_start(line_mr(sx) - line_mr(x1)), m_dy_start(line_mr(sy) - line_mr(y1)), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start) { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; + m_dx *= line_subpixel_scale; + m_dy *= line_subpixel_scale; + m_dx_start *= line_mr_subpixel_scale; + m_dy_start *= line_mr_subpixel_scale; } distance_interpolator2(int x1, int y1, int x2, int y2, @@ -195,16 +195,16 @@ namespace agg m_dx_start(line_mr(ex) - line_mr(x2)), m_dy_start(line_mr(ey) - line_mr(y2)), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_start - + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_start) { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; + m_dx *= line_subpixel_scale; + m_dy *= line_subpixel_scale; + m_dx_start *= line_mr_subpixel_scale; + m_dy_start *= line_mr_subpixel_scale; } @@ -217,68 +217,68 @@ namespace agg //--------------------------------------------------------------------- void inc_x(int dy) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; } } //--------------------------------------------------------------------- void dec_x(int dy) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; } } //--------------------------------------------------------------------- void inc_y(int dx) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; } } //--------------------------------------------------------------------- void dec_y(int dx) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; } } @@ -317,7 +317,7 @@ namespace agg //--------------------------------------------------------------------- distance_interpolator3() {} distance_interpolator3(int x1, int y1, int x2, int y2, - int sx, int sy, int ex, int ey, + int sx, int sy, int ex, int ey, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), @@ -326,21 +326,21 @@ namespace agg m_dx_end(line_mr(ex) - line_mr(x2)), m_dy_end(line_mr(ey) - line_mr(y2)), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), - m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - + m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end) { - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - m_dx_end <<= line_mr_subpixel_shift; - m_dy_end <<= line_mr_subpixel_shift; + m_dx *= line_subpixel_scale; + m_dy *= line_subpixel_scale; + m_dx_start *= line_mr_subpixel_scale; + m_dy_start *= line_mr_subpixel_scale; + m_dx_end *= line_mr_subpixel_scale; + m_dy_end *= line_mr_subpixel_scale; } //--------------------------------------------------------------------- @@ -352,19 +352,19 @@ namespace agg //--------------------------------------------------------------------- void inc_x(int dy) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; m_dist_end += m_dy_end; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; m_dist_end += m_dx_end; } } @@ -372,19 +372,19 @@ namespace agg //--------------------------------------------------------------------- void dec_x(int dy) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; m_dist_end += m_dx_end; } } @@ -392,19 +392,19 @@ namespace agg //--------------------------------------------------------------------- void inc_y(int dx) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; + m_dist -= m_dx; + m_dist_start -= m_dx_start; m_dist_end -= m_dx_end; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; m_dist_end += m_dy_end; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } } @@ -412,19 +412,19 @@ namespace agg //--------------------------------------------------------------------- void dec_y(int dx) { - m_dist += m_dx; - m_dist_start += m_dx_start; + m_dist += m_dx; + m_dist_start += m_dx_start; m_dist_end += m_dx_end; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; + m_dist += m_dy; + m_dist_start += m_dy_start; m_dist_end += m_dy_end; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; + m_dist -= m_dy; + m_dist_start -= m_dy_start; m_dist_end -= m_dy_end; } } @@ -459,7 +459,7 @@ namespace agg - + //================================================line_interpolator_aa_base template class line_interpolator_aa_base { @@ -469,7 +469,7 @@ namespace agg //--------------------------------------------------------------------- enum max_half_width_e - { + { max_half_width = 64 }; @@ -478,7 +478,7 @@ namespace agg m_lp(&lp), m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : line_dbl_hr(lp.y2 - lp.y1), - lp.vertical ? std::abs(lp.y2 - lp.y1) : + lp.vertical ? std::abs(lp.y2 - lp.y1) : std::abs(lp.x2 - lp.x1) + 1), m_ren(ren), m_len((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len), @@ -493,9 +493,9 @@ namespace agg m_max_extent((m_width + line_subpixel_mask) >> line_subpixel_shift), m_step(0) { - agg::dda2_line_interpolator li(0, lp.vertical ? - (lp.dy << agg::line_subpixel_shift) : - (lp.dx << agg::line_subpixel_shift), + agg::dda2_line_interpolator li(0, lp.vertical ? + (lp.dy * agg::line_subpixel_scale) : + (lp.dx * agg::line_subpixel_scale), lp.len); unsigned i; @@ -546,7 +546,7 @@ namespace agg private: line_interpolator_aa_base(const line_interpolator_aa_base&); - const line_interpolator_aa_base& + const line_interpolator_aa_base& operator = (const line_interpolator_aa_base&); protected: @@ -584,7 +584,7 @@ namespace agg //--------------------------------------------------------------------- line_interpolator_aa0(renderer_type& ren, const line_parameters& lp) : line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, + m_di(lp.x1, lp.y1, lp.x2, lp.y2, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) { base_type::m_li.adjust_forward(); @@ -614,9 +614,9 @@ namespace agg *--p0 = (cover_type)base_type::m_ren.cover(dist); ++dy; } - base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), + base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_y - dy + 1, + unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } @@ -645,20 +645,20 @@ namespace agg *--p0 = (cover_type)base_type::m_ren.cover(dist); ++dx; } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, - unsigned(p1 - p0), + unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa0(const line_interpolator_aa0&); - const line_interpolator_aa0& + const line_interpolator_aa0& operator = (const line_interpolator_aa0&); //--------------------------------------------------------------------- - distance_interpolator1 m_di; + distance_interpolator1 m_di; }; @@ -676,7 +676,7 @@ namespace agg typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- - line_interpolator_aa1(renderer_type& ren, const line_parameters& lp, + line_interpolator_aa1(renderer_type& ren, const line_parameters& lp, int sx, int sy) : line_interpolator_aa_base(ren, lp), m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, @@ -700,7 +700,7 @@ namespace agg base_type::m_old_x = base_type::m_x; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; @@ -732,7 +732,7 @@ namespace agg base_type::m_old_y = base_type::m_y; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; @@ -779,7 +779,7 @@ namespace agg dist_start -= m_di.dx_start(); *p1 = 0; if(dist_start <= 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); } ++p1; @@ -793,15 +793,15 @@ namespace agg dist_start += m_di.dx_start(); *--p0 = 0; if(dist_start <= 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); } ++dy; } - base_type::m_ren.blend_solid_vspan(base_type::m_x, + base_type::m_ren.blend_solid_vspan(base_type::m_x, base_type::m_y - dy + 1, - unsigned(p1 - p0), + unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } @@ -831,7 +831,7 @@ namespace agg dist_start += m_di.dy_start(); *p1 = 0; if(dist_start <= 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); } ++p1; @@ -845,25 +845,25 @@ namespace agg dist_start -= m_di.dy_start(); *--p0 = 0; if(dist_start <= 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); } ++dx; } - base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, + base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, base_type::m_y, - unsigned(p1 - p0), + unsigned(p1 - p0), p0); return ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa1(const line_interpolator_aa1&); - const line_interpolator_aa1& + const line_interpolator_aa1& operator = (const line_interpolator_aa1&); //--------------------------------------------------------------------- - distance_interpolator2 m_di; + distance_interpolator2 m_di; }; @@ -887,10 +887,10 @@ namespace agg typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- - line_interpolator_aa2(renderer_type& ren, const line_parameters& lp, + line_interpolator_aa2(renderer_type& ren, const line_parameters& lp, int ex, int ey) : line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey, + m_di(lp.x1, lp.y1, lp.x2, lp.y2, ex, ey, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask, 0) { @@ -925,7 +925,7 @@ namespace agg dist_end -= m_di.dx_end(); *p1 = 0; if(dist_end > 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } @@ -940,15 +940,15 @@ namespace agg dist_end += m_di.dx_end(); *--p0 = 0; if(dist_end > 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), + base_type::m_y - dy + 1, + unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } @@ -980,7 +980,7 @@ namespace agg dist_end += m_di.dy_end(); *p1 = 0; if(dist_end > 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } @@ -995,26 +995,26 @@ namespace agg dist_end -= m_di.dy_end(); *--p0 = 0; if(dist_end > 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), + base_type::m_y, + unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa2(const line_interpolator_aa2&); - const line_interpolator_aa2& + const line_interpolator_aa2& operator = (const line_interpolator_aa2&); //--------------------------------------------------------------------- - distance_interpolator2 m_di; + distance_interpolator2 m_di; }; @@ -1036,10 +1036,10 @@ namespace agg typedef line_interpolator_aa_base base_type; //--------------------------------------------------------------------- - line_interpolator_aa3(renderer_type& ren, const line_parameters& lp, + line_interpolator_aa3(renderer_type& ren, const line_parameters& lp, int sx, int sy, int ex, int ey) : line_interpolator_aa_base(ren, lp), - m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, + m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask) { int dist1_start; @@ -1058,7 +1058,7 @@ namespace agg base_type::m_old_x = base_type::m_x; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; @@ -1089,7 +1089,7 @@ namespace agg base_type::m_old_y = base_type::m_y; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; @@ -1145,7 +1145,7 @@ namespace agg dist_end -= m_di.dx_end(); *p1 = 0; if(dist_end > 0 && dist_start <= 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } @@ -1162,15 +1162,15 @@ namespace agg dist_end += m_di.dx_end(); *--p0 = 0; if(dist_end > 0 && dist_start <= 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dy; } base_type::m_ren.blend_solid_vspan(base_type::m_x, - base_type::m_y - dy + 1, - unsigned(p1 - p0), + base_type::m_y - dy + 1, + unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } @@ -1208,7 +1208,7 @@ namespace agg dist_end += m_di.dy_end(); *p1 = 0; if(dist_end > 0 && dist_start <= 0) - { + { *p1 = (cover_type)base_type::m_ren.cover(dist); ++npix; } @@ -1225,26 +1225,26 @@ namespace agg dist_end -= m_di.dy_end(); *--p0 = 0; if(dist_end > 0 && dist_start <= 0) - { + { *p0 = (cover_type)base_type::m_ren.cover(dist); ++npix; } ++dx; } base_type::m_ren.blend_solid_hspan(base_type::m_x - dx + 1, - base_type::m_y, - unsigned(p1 - p0), + base_type::m_y, + unsigned(p1 - p0), p0); return npix && ++base_type::m_step < base_type::m_count; } private: line_interpolator_aa3(const line_interpolator_aa3&); - const line_interpolator_aa3& + const line_interpolator_aa3& operator = (const line_interpolator_aa3&); //--------------------------------------------------------------------- - distance_interpolator3 m_di; + distance_interpolator3 m_di; }; @@ -1252,8 +1252,8 @@ namespace agg //==========================================================line_profile_aa // - // See Implementation agg_line_profile_aa.cpp - // + // See Implementation agg_line_profile_aa.cpp + // class line_profile_aa { public: @@ -1272,9 +1272,9 @@ namespace agg aa_scale = 1 << aa_shift, aa_mask = aa_scale - 1 }; - + //--------------------------------------------------------------------- - line_profile_aa() : + line_profile_aa() : m_subpixel_width(0), m_min_width(1.0), m_smoother_width(1.0) @@ -1284,8 +1284,8 @@ namespace agg } //--------------------------------------------------------------------- - template - line_profile_aa(double w, const GammaF& gamma_function) : + template + line_profile_aa(double w, const GammaF& gamma_function) : m_subpixel_width(0), m_min_width(1.0), m_smoother_width(1.0) @@ -1300,7 +1300,7 @@ namespace agg //--------------------------------------------------------------------- template void gamma(const GammaF& gamma_function) - { + { int i; for(i = 0; i < aa_scale; i++) { @@ -1365,9 +1365,9 @@ namespace agg //--------------------------------------------------------------------- void profile(const line_profile_aa& prof) { m_profile = &prof; } const line_profile_aa& profile() const { return *m_profile; } - + // clang error: binding of reference to type 'agg::line_profile_aa' to a value of type - // 'const agg::line_profile_aa' drops qualifiers + // 'const agg::line_profile_aa' drops qualifiers //line_profile_aa& profile() { return *m_profile; } //--------------------------------------------------------------------- @@ -1408,14 +1408,14 @@ namespace agg //------------------------------------------------------------------------- template void semidot_hline(Cmp cmp, - int xc1, int yc1, int xc2, int yc2, + int xc1, int yc1, int xc2, int yc2, int x1, int y1, int x2) { cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; cover_type* p0 = covers; cover_type* p1 = covers; - int x = x1 << line_subpixel_shift; - int y = y1 << line_subpixel_shift; + int x = x1 * line_subpixel_scale; + int y = y1 * line_subpixel_scale; int w = subpixel_width(); distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y); x += line_subpixel_scale/2; @@ -1437,14 +1437,14 @@ namespace agg di.inc_x(); } while(++x1 <= x2); - m_ren->blend_solid_hspan(x0, y1, - unsigned(p1 - p0), - color(), + m_ren->blend_solid_hspan(x0, y1, + unsigned(p1 - p0), + color(), p0); } //------------------------------------------------------------------------- - template + template void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2) { if(m_clipping && clipping_flags(xc1, yc1, m_clip_box)) return; @@ -1478,16 +1478,16 @@ namespace agg } //------------------------------------------------------------------------- - void pie_hline(int xc, int yc, int xp1, int yp1, int xp2, int yp2, + void pie_hline(int xc, int yc, int xp1, int yp1, int xp2, int yp2, int xh1, int yh1, int xh2) { if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return; - + cover_type covers[line_interpolator_aa_base::max_half_width * 2 + 4]; cover_type* p0 = covers; cover_type* p1 = covers; - int x = xh1 << line_subpixel_shift; - int y = yh1 << line_subpixel_shift; + int x = xh1 * line_subpixel_scale; + int y = yh1 * line_subpixel_scale; int w = subpixel_width(); distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y); @@ -1510,9 +1510,9 @@ namespace agg di.inc_x(); } while(++xh1 <= xh2); - m_ren->blend_solid_hspan(xh0, yh1, - unsigned(p1 - p0), - color(), + m_ren->blend_solid_hspan(xh0, yh1, + unsigned(p1 - p0), + color(), p0); } @@ -1588,7 +1588,7 @@ namespace agg { if(flags) { - line_parameters lp2(x1, y1, x2, y2, + line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); line0_no_clip(lp2); } @@ -1643,11 +1643,11 @@ namespace agg { if(flags) { - line_parameters lp2(x1, y1, x2, y2, + line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { - sx = x1 + (y2 - y1); + sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else @@ -1710,11 +1710,11 @@ namespace agg { if(flags) { - line_parameters lp2(x1, y1, x2, y2, + line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 2) { - ex = x2 + (y2 - y1); + ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else @@ -1740,7 +1740,7 @@ namespace agg } //------------------------------------------------------------------------- - void line3_no_clip(const line_parameters& lp, + void line3_no_clip(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(lp.len > line_max_length) @@ -1768,7 +1768,7 @@ namespace agg } //------------------------------------------------------------------------- - void line3(const line_parameters& lp, + void line3(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(m_clipping) @@ -1782,11 +1782,11 @@ namespace agg { if(flags) { - line_parameters lp2(x1, y1, x2, y2, + line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { - sx = x1 + (y2 - y1); + sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else @@ -1799,7 +1799,7 @@ namespace agg } if(flags & 2) { - ex = x2 + (y2 - y1); + ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else @@ -1827,7 +1827,7 @@ namespace agg private: base_ren_type* m_ren; - const line_profile_aa* m_profile; + const line_profile_aa* m_profile; color_type m_color; rect_i m_clip_box; bool m_clipping; diff --git a/deps/agg/include/agg_renderer_outline_image.h b/deps/agg/include/agg_renderer_outline_image.h index 6a1b50ce4..6b4673977 100644 --- a/deps/agg/include/agg_renderer_outline_image.h +++ b/deps/agg/include/agg_renderer_outline_image.h @@ -2,8 +2,8 @@ // Anti-Grain Geometry - Version 2.4 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. +// Permission to copy, use, modify, sell and distribute this software +// is granted provided this copyright notice appears in all copies. // This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // @@ -32,7 +32,7 @@ namespace agg typedef typename Source::color_type color_type; line_image_scale(const Source& src, double height) : - m_source(src), + m_source(src), m_height(height), m_scale(src.height() / height) { @@ -41,8 +41,8 @@ namespace agg double width() const { return m_source.width(); } double height() const { return m_height; } - color_type pixel(int x, int y) const - { + color_type pixel(int x, int y) const + { double src_y = (y + 0.5) * m_scale - 0.5; int h = m_source.height() - 1; int y1 = ufloor(src_y); @@ -74,7 +74,7 @@ namespace agg line_image_pattern(const Filter& filter) : m_filter(&filter), m_dilation(filter.dilation() + 1), - m_dilation_hr(m_dilation << line_subpixel_shift), + m_dilation_hr(m_dilation * line_subpixel_scale), m_data(), m_width(0), m_height(0), @@ -86,11 +86,11 @@ namespace agg // Create //-------------------------------------------------------------------- - template + template line_image_pattern(const Filter& filter, const Source& src) : m_filter(&filter), m_dilation(filter.dilation() + 1), - m_dilation_hr(m_dilation << line_subpixel_shift), + m_dilation_hr(m_dilation * line_subpixel_scale), m_data(), m_width(0), m_height(0), @@ -114,8 +114,8 @@ namespace agg m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2)); - m_buf.attach(&m_data[0], m_width + m_dilation * 2, - m_height + m_dilation * 2, + m_buf.attach(&m_data[0], m_width + m_dilation * 2, + m_height + m_dilation * 2, m_width + m_dilation * 2); unsigned x, y; color_type* d1; @@ -170,8 +170,8 @@ namespace agg //-------------------------------------------------------------------- void pixel(color_type* p, int x, int y) const { - m_filter->pixel_high_res(m_buf.rows(), - p, + m_filter->pixel_high_res(m_buf.rows(), + p, x % m_width_hr + m_dilation_hr, y + m_offset_y_hr); } @@ -181,7 +181,7 @@ namespace agg private: line_image_pattern(const line_image_pattern&); - const line_image_pattern& + const line_image_pattern& operator = (const line_image_pattern&); protected: @@ -203,7 +203,7 @@ namespace agg //=================================================line_image_pattern_pow2 - template class line_image_pattern_pow2 : + template class line_image_pattern_pow2 : public line_image_pattern { public: @@ -216,19 +216,19 @@ namespace agg line_image_pattern(filter), m_mask(line_subpixel_mask) {} //-------------------------------------------------------------------- - template + template line_image_pattern_pow2(const Filter& filter, const Source& src) : line_image_pattern(filter), m_mask(line_subpixel_mask) { create(src); } - + //-------------------------------------------------------------------- template void create(const Source& src) { line_image_pattern::create(src); m_mask = 1; - while(m_mask < base_type::m_width) + while(m_mask < base_type::m_width) { m_mask <<= 1; m_mask |= 1; @@ -242,7 +242,7 @@ namespace agg void pixel(color_type* p, int x, int y) const { base_type::m_filter->pixel_high_res( - base_type::m_buf.rows(), + base_type::m_buf.rows(), p, (x & m_mask) + base_type::m_dilation_hr, y + base_type::m_offset_y_hr); @@ -250,13 +250,13 @@ namespace agg private: unsigned m_mask; }; - - - - - - - + + + + + + + //===================================================distance_interpolator4 class distance_interpolator4 { @@ -264,7 +264,7 @@ namespace agg //--------------------------------------------------------------------- distance_interpolator4() {} distance_interpolator4(int x1, int y1, int x2, int y2, - int sx, int sy, int ex, int ey, + int sx, int sy, int ex, int ey, int len, double scale, int x, int y) : m_dx(x2 - x1), m_dy(y2 - y1), @@ -273,88 +273,88 @@ namespace agg m_dx_end(line_mr(ex) - line_mr(x2)), m_dy_end(line_mr(ey) - line_mr(y2)), - m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - + m_dist(iround(double(x + line_subpixel_scale/2 - x2) * double(m_dy) - double(y + line_subpixel_scale/2 - y2) * double(m_dx))), - m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - + m_dist_start((line_mr(x + line_subpixel_scale/2) - line_mr(sx)) * m_dy_start - (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start), - m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - + m_dist_end((line_mr(x + line_subpixel_scale/2) - line_mr(ex)) * m_dy_end - (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end), m_len(uround(len / scale)) { double d = len * scale; - int dx = iround(((x2 - x1) << line_subpixel_shift) / d); - int dy = iround(((y2 - y1) << line_subpixel_shift) / d); + int dx = iround(((x2 - x1) * line_subpixel_scale) / d); + int dy = iround(((y2 - y1) * line_subpixel_scale) / d); m_dx_pict = -dy; m_dy_pict = dx; - m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - - (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> - line_subpixel_shift; + m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - + (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> + line_subpixel_shift; - m_dx <<= line_subpixel_shift; - m_dy <<= line_subpixel_shift; - m_dx_start <<= line_mr_subpixel_shift; - m_dy_start <<= line_mr_subpixel_shift; - m_dx_end <<= line_mr_subpixel_shift; - m_dy_end <<= line_mr_subpixel_shift; + m_dx *= line_subpixel_scale; + m_dy *= line_subpixel_scale; + m_dx_start *= line_mr_subpixel_scale; + m_dy_start *= line_mr_subpixel_scale; + m_dx_end *= line_mr_subpixel_scale; + m_dy_end *= line_mr_subpixel_scale; } //--------------------------------------------------------------------- - void inc_x() - { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; - m_dist_end += m_dy_end; + void inc_x() + { + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; + m_dist_end += m_dy_end; } //--------------------------------------------------------------------- - void dec_x() - { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; - m_dist_end -= m_dy_end; + void dec_x() + { + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; + m_dist_end -= m_dy_end; } //--------------------------------------------------------------------- - void inc_y() - { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; - m_dist_end -= m_dx_end; + void inc_y() + { + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; + m_dist_end -= m_dx_end; } //--------------------------------------------------------------------- - void dec_y() - { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; - m_dist_end += m_dx_end; + void dec_y() + { + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; + m_dist_end += m_dx_end; } //--------------------------------------------------------------------- void inc_x(int dy) { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; } } @@ -362,22 +362,22 @@ namespace agg //--------------------------------------------------------------------- void dec_x(int dy) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; if(dy > 0) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; } if(dy < 0) { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; } } @@ -385,22 +385,22 @@ namespace agg //--------------------------------------------------------------------- void inc_y(int dx) { - m_dist -= m_dx; - m_dist_start -= m_dx_start; - m_dist_pict -= m_dx_pict; + m_dist -= m_dx; + m_dist_start -= m_dx_start; + m_dist_pict -= m_dx_pict; m_dist_end -= m_dx_end; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; } } @@ -408,22 +408,22 @@ namespace agg //--------------------------------------------------------------------- void dec_y(int dx) { - m_dist += m_dx; - m_dist_start += m_dx_start; - m_dist_pict += m_dx_pict; + m_dist += m_dx; + m_dist_start += m_dx_start; + m_dist_pict += m_dx_pict; m_dist_end += m_dx_end; if(dx > 0) { - m_dist += m_dy; - m_dist_start += m_dy_start; - m_dist_pict += m_dy_pict; + m_dist += m_dy; + m_dist_start += m_dy_start; + m_dist_pict += m_dy_pict; m_dist_end += m_dy_end; } if(dx < 0) { - m_dist -= m_dy; - m_dist_start -= m_dy_start; - m_dist_pict -= m_dy_pict; + m_dist -= m_dy; + m_dist_start -= m_dy_start; + m_dist_pict -= m_dy_pict; m_dist_end -= m_dy_end; } } @@ -476,20 +476,19 @@ namespace agg //--------------------------------------------------------------------- enum max_half_width_e - { + { max_half_width = 64 }; //--------------------------------------------------------------------- line_interpolator_image(renderer_type& ren, const line_parameters& lp, - int sx, int sy, int ex, int ey, + int sx, int sy, int ex, int ey, int pattern_start, double scale_x) : m_lp(lp), m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : - line_dbl_hr(lp.y2 - lp.y1), - lp.vertical ? std::abs(lp.y2 - lp.y1) : - std::abs(lp.x2 - lp.x1) + 1), + line_dbl_hr(lp.y2 - lp.y1), + lp.vertical ? lp.dy : lp.dx + 1), m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask), m_ren(ren), @@ -505,9 +504,9 @@ namespace agg m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()), m_step(0) { - agg::dda2_line_interpolator li(0, lp.vertical ? - (lp.dy << agg::line_subpixel_shift) : - (lp.dx << agg::line_subpixel_shift), + agg::dda2_line_interpolator li(0, lp.vertical ? + (lp.dy * agg::line_subpixel_scale) : + (lp.dx * agg::line_subpixel_scale), lp.len); unsigned i; @@ -537,7 +536,7 @@ namespace agg m_old_x = m_x; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dx = 0; if(dist1_start < 0) ++npix; @@ -570,7 +569,7 @@ namespace agg m_old_y = m_y; - dist1_start = dist2_start = m_di.dist_start(); + dist1_start = dist2_start = m_di.dist_start(); int dy = 0; if(dist1_start < 0) ++npix; @@ -642,7 +641,7 @@ namespace agg dist_end -= m_di.dx_end(); p1->clear(); if(dist_end > 0 && dist_start <= 0) - { + { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p1, dist_pict, s2 - dist); ++npix; @@ -663,17 +662,17 @@ namespace agg --p0; p0->clear(); if(dist_end > 0 && dist_start <= 0) - { + { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p0, dist_pict, s2 + dist); ++npix; } ++dy; } - m_ren.blend_color_vspan(m_x, - m_y - dy + 1, - unsigned(p1 - p0), - p0); + m_ren.blend_color_vspan(m_x, + m_y - dy + 1, + unsigned(p1 - p0), + p0); return npix && ++m_step < m_count; } @@ -728,7 +727,7 @@ namespace agg dist_end += m_di.dy_end(); p1->clear(); if(dist_end > 0 && dist_start <= 0) - { + { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p1, dist_pict, s2 + dist); ++npix; @@ -749,16 +748,16 @@ namespace agg --p0; p0->clear(); if(dist_end > 0 && dist_start <= 0) - { + { if(m_lp.inc > 0) dist = -dist; m_ren.pixel(p0, dist_pict, s2 - dist); ++npix; } ++dx; } - m_ren.blend_color_hspan(m_x - dx + 1, - m_y, - unsigned(p1 - p0), + m_ren.blend_color_hspan(m_x - dx + 1, + m_y, + unsigned(p1 - p0), p0); return npix && ++m_step < m_count; } @@ -780,7 +779,7 @@ namespace agg protected: const line_parameters& m_lp; dda2_line_interpolator m_li; - distance_interpolator4 m_di; + distance_interpolator4 m_di; renderer_type& m_ren; int m_plen; int m_x; @@ -804,7 +803,7 @@ namespace agg //===================================================renderer_outline_image - template + template class renderer_outline_image { public: @@ -876,7 +875,7 @@ namespace agg static bool accurate_join_only() { return true; } //------------------------------------------------------------------------- - template + template void semidot(Cmp, int, int, int, int) { } @@ -902,7 +901,7 @@ namespace agg } //------------------------------------------------------------------------- - void line3_no_clip(const line_parameters& lp, + void line3_no_clip(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(lp.len > line_max_length) @@ -915,12 +914,12 @@ namespace agg line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1); return; } - + fix_degenerate_bisectrix_start(lp, &sx, &sy); fix_degenerate_bisectrix_end(lp, &ex, &ey); - line_interpolator_image li(*this, lp, - sx, sy, - ex, ey, + line_interpolator_image li(*this, lp, + sx, sy, + ex, ey, m_start, m_scale_x); if(li.vertical()) { @@ -934,7 +933,7 @@ namespace agg } //------------------------------------------------------------------------- - void line3(const line_parameters& lp, + void line3(const line_parameters& lp, int sx, int sy, int ex, int ey) { if(m_clipping) @@ -949,12 +948,12 @@ namespace agg { if(flags) { - line_parameters lp2(x1, y1, x2, y2, + line_parameters lp2(x1, y1, x2, y2, uround(calc_distance(x1, y1, x2, y2))); if(flags & 1) { m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x); - sx = x1 + (y2 - y1); + sx = x1 + (y2 - y1); sy = y1 - (x2 - x1); } else @@ -967,7 +966,7 @@ namespace agg } if(flags & 2) { - ex = x2 + (y2 - y1); + ex = x2 + (y2 - y1); ey = y2 - (x2 - x1); } else