use multiplication instead of << to avoid undefined behavour when LHS is a negative int (-fsanitize=undefined)

This commit is contained in:
Artem Pavlenko 2018-02-14 16:49:31 +01:00
parent 17a98767b4
commit 6815ac2869
3 changed files with 341 additions and 342 deletions

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // warranty, and with no claim as to its suitability for any purpose.
// //
@ -21,7 +21,7 @@
namespace agg namespace agg
{ {
// See Implementation agg_line_aa_basics.cpp // See Implementation agg_line_aa_basics.cpp
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
enum line_subpixel_scale_e enum line_subpixel_scale_e
@ -37,26 +37,26 @@ namespace agg
enum line_mr_subpixel_scale_e enum line_mr_subpixel_scale_e
{ {
line_mr_subpixel_shift = 4, //----line_mr_subpixel_shift 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_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_mask = line_mr_subpixel_scale - 1 //----line_mr_subpixel_mask
}; };
//------------------------------------------------------------------line_mr //------------------------------------------------------------------line_mr
AGG_INLINE int line_mr(int x) AGG_INLINE int line_mr(int x)
{ {
return x >> (line_subpixel_shift - line_mr_subpixel_shift); return x >> (line_subpixel_shift - line_mr_subpixel_shift);
} }
//-------------------------------------------------------------------line_hr //-------------------------------------------------------------------line_hr
AGG_INLINE int line_hr(int x) AGG_INLINE int line_hr(int x)
{ {
return x << (line_subpixel_shift - line_mr_subpixel_shift); return x << (line_subpixel_shift - line_mr_subpixel_shift);
} }
//---------------------------------------------------------------line_dbl_hr //---------------------------------------------------------------line_dbl_hr
AGG_INLINE int line_dbl_hr(int x) AGG_INLINE int line_dbl_hr(int x)
{ {
return x << line_subpixel_shift; return x * line_subpixel_scale;
} }
//---------------------------------------------------------------line_coord //---------------------------------------------------------------line_coord
@ -83,7 +83,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
line_parameters() {} line_parameters() {}
line_parameters(int x1_, int y1_, int x2_, int y2_, int len_) : 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_)), dx(std::abs(x2_ - x1_)),
dy(std::abs(y2_ - y1_)), dy(std::abs(y2_ - y1_)),
sx((x2_ > x1_) ? 1 : -1), sx((x2_ > x1_) ? 1 : -1),
@ -133,7 +133,7 @@ namespace agg
lp2.dx = std::abs(lp2.x2 - lp2.x1); lp2.dx = std::abs(lp2.x2 - lp2.x1);
lp2.dy = std::abs(lp2.y2 - lp2.y1); lp2.dy = std::abs(lp2.y2 - lp2.y1);
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
int x1, y1, x2, y2, dx, dy, sx, sy; int x1, y1, x2, y2, dx, dy, sx, sy;
bool vertical; bool vertical;
@ -148,19 +148,19 @@ namespace agg
// See Implementation agg_line_aa_basics.cpp // See Implementation agg_line_aa_basics.cpp
//----------------------------------------------------------------bisectrix //----------------------------------------------------------------bisectrix
void bisectrix(const line_parameters& l1, void bisectrix(const line_parameters& l1,
const line_parameters& l2, const line_parameters& l2,
int* x, int* y); int* x, int* y);
//-------------------------------------------fix_degenerate_bisectrix_start //-------------------------------------------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* 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); double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
if(d < line_subpixel_scale/2) if(d < line_subpixel_scale/2)
{ {
@ -171,10 +171,10 @@ namespace agg
//---------------------------------------------fix_degenerate_bisectrix_end //---------------------------------------------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* 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); double(*y - lp.y2) * double(lp.x2 - lp.x1)) / lp.len);
if(d < line_subpixel_scale/2) if(d < line_subpixel_scale/2)
{ {

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // 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) : distance_interpolator0(int x1, int y1, int x2, int y2, int x, int y) :
m_dx(line_mr(x2) - line_mr(x1)), m_dx(line_mr(x2) - line_mr(x1)),
m_dy(line_mr(y2) - line_mr(y1)), 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) (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx)
{ {
m_dx <<= line_mr_subpixel_shift; m_dx *= line_mr_subpixel_scale;
m_dy <<= line_mr_subpixel_shift; m_dy *= line_mr_subpixel_scale;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -60,22 +60,22 @@ namespace agg
public: public:
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator00() {} distance_interpolator00() {}
distance_interpolator00(int xc, int yc, distance_interpolator00(int xc, int yc,
int x1, int y1, int x2, int y2, int x1, int y1, int x2, int y2,
int x, int y) : int x, int y) :
m_dx1(line_mr(x1) - line_mr(xc)), m_dx1(line_mr(x1) - line_mr(xc)),
m_dy1(line_mr(y1) - line_mr(yc)), m_dy1(line_mr(y1) - line_mr(yc)),
m_dx2(line_mr(x2) - line_mr(xc)), m_dx2(line_mr(x2) - line_mr(xc)),
m_dy2(line_mr(y2) - line_mr(yc)), 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), (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) (line_mr(y + line_subpixel_scale/2) - line_mr(y2)) * m_dx2)
{ {
m_dx1 <<= line_mr_subpixel_shift; m_dx1 *= line_mr_subpixel_scale;
m_dy1 <<= line_mr_subpixel_shift; m_dy1 *= line_mr_subpixel_scale;
m_dx2 <<= line_mr_subpixel_shift; m_dx2 *= line_mr_subpixel_scale;
m_dy2 <<= line_mr_subpixel_shift; 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) : distance_interpolator1(int x1, int y1, int x2, int y2, int x, int y) :
m_dx(x2 - x1), m_dx(x2 - x1),
m_dy(y2 - y1), 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))) double(y + line_subpixel_scale/2 - y2) * double(m_dx)))
{ {
m_dx <<= line_subpixel_shift; m_dx *= line_subpixel_scale;
m_dy <<= line_subpixel_shift; m_dy *= line_subpixel_scale;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -118,33 +118,33 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_x(int dy) void inc_x(int dy)
{ {
m_dist += m_dy; m_dist += m_dy;
if(dy > 0) m_dist -= m_dx; if(dy > 0) m_dist -= m_dx;
if(dy < 0) m_dist += m_dx; if(dy < 0) m_dist += m_dx;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_x(int dy) void dec_x(int dy)
{ {
m_dist -= m_dy; m_dist -= m_dy;
if(dy > 0) m_dist -= m_dx; if(dy > 0) m_dist -= m_dx;
if(dy < 0) m_dist += m_dx; if(dy < 0) m_dist += m_dx;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_y(int dx) void inc_y(int dx)
{ {
m_dist -= m_dx; m_dist -= m_dx;
if(dx > 0) m_dist += m_dy; if(dx > 0) m_dist += m_dy;
if(dx < 0) m_dist -= m_dy; if(dx < 0) m_dist -= m_dy;
} }
void dec_y(int dx) void dec_y(int dx)
//--------------------------------------------------------------------- //---------------------------------------------------------------------
{ {
m_dist += m_dx; m_dist += m_dx;
if(dx > 0) m_dist += m_dy; if(dx > 0) m_dist += m_dy;
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_dx_start(line_mr(sx) - line_mr(x1)),
m_dy_start(line_mr(sy) - line_mr(y1)), 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))), 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) (line_mr(y + line_subpixel_scale/2) - line_mr(sy)) * m_dx_start)
{ {
m_dx <<= line_subpixel_shift; m_dx *= line_subpixel_scale;
m_dy <<= line_subpixel_shift; m_dy *= line_subpixel_scale;
m_dx_start <<= line_mr_subpixel_shift; m_dx_start *= line_mr_subpixel_scale;
m_dy_start <<= line_mr_subpixel_shift; m_dy_start *= line_mr_subpixel_scale;
} }
distance_interpolator2(int x1, int y1, int x2, int y2, 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_dx_start(line_mr(ex) - line_mr(x2)),
m_dy_start(line_mr(ey) - line_mr(y2)), 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))), 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) (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_start)
{ {
m_dx <<= line_subpixel_shift; m_dx *= line_subpixel_scale;
m_dy <<= line_subpixel_shift; m_dy *= line_subpixel_scale;
m_dx_start <<= line_mr_subpixel_shift; m_dx_start *= line_mr_subpixel_scale;
m_dy_start <<= line_mr_subpixel_shift; m_dy_start *= line_mr_subpixel_scale;
} }
@ -217,68 +217,68 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_x(int dy) void inc_x(int dy)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
} }
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_x(int dy) void dec_x(int dy)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
} }
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_y(int dx) void inc_y(int dx)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
} }
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_y(int dx) void dec_y(int dx)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
} }
} }
@ -317,7 +317,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator3() {} distance_interpolator3() {}
distance_interpolator3(int x1, int y1, int x2, int y2, 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) : int x, int y) :
m_dx(x2 - x1), m_dx(x2 - x1),
m_dy(y2 - y1), m_dy(y2 - y1),
@ -326,21 +326,21 @@ namespace agg
m_dx_end(line_mr(ex) - line_mr(x2)), m_dx_end(line_mr(ex) - line_mr(x2)),
m_dy_end(line_mr(ey) - line_mr(y2)), 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))), 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), (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) (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end)
{ {
m_dx <<= line_subpixel_shift; m_dx *= line_subpixel_scale;
m_dy <<= line_subpixel_shift; m_dy *= line_subpixel_scale;
m_dx_start <<= line_mr_subpixel_shift; m_dx_start *= line_mr_subpixel_scale;
m_dy_start <<= line_mr_subpixel_shift; m_dy_start *= line_mr_subpixel_scale;
m_dx_end <<= line_mr_subpixel_shift; m_dx_end *= line_mr_subpixel_scale;
m_dy_end <<= line_mr_subpixel_shift; m_dy_end *= line_mr_subpixel_scale;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -352,19 +352,19 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_x(int dy) void inc_x(int dy)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
} }
} }
@ -372,19 +372,19 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_x(int dy) void dec_x(int dy)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
} }
} }
@ -392,19 +392,19 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_y(int dx) void inc_y(int dx)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
} }
} }
@ -412,19 +412,19 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_y(int dx) void dec_y(int dx)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
} }
} }
@ -459,7 +459,7 @@ namespace agg
//================================================line_interpolator_aa_base //================================================line_interpolator_aa_base
template<class Renderer> class line_interpolator_aa_base template<class Renderer> class line_interpolator_aa_base
{ {
@ -469,7 +469,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
enum max_half_width_e enum max_half_width_e
{ {
max_half_width = 64 max_half_width = 64
}; };
@ -478,7 +478,7 @@ namespace agg
m_lp(&lp), m_lp(&lp),
m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) :
line_dbl_hr(lp.y2 - lp.y1), 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), std::abs(lp.x2 - lp.x1) + 1),
m_ren(ren), m_ren(ren),
m_len((lp.vertical == (lp.inc > 0)) ? -lp.len : lp.len), 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_max_extent((m_width + line_subpixel_mask) >> line_subpixel_shift),
m_step(0) m_step(0)
{ {
agg::dda2_line_interpolator li(0, lp.vertical ? agg::dda2_line_interpolator li(0, lp.vertical ?
(lp.dy << agg::line_subpixel_shift) : (lp.dy * agg::line_subpixel_scale) :
(lp.dx << agg::line_subpixel_shift), (lp.dx * agg::line_subpixel_scale),
lp.len); lp.len);
unsigned i; unsigned i;
@ -546,7 +546,7 @@ namespace agg
private: private:
line_interpolator_aa_base(const line_interpolator_aa_base<Renderer>&); line_interpolator_aa_base(const line_interpolator_aa_base<Renderer>&);
const line_interpolator_aa_base<Renderer>& const line_interpolator_aa_base<Renderer>&
operator = (const line_interpolator_aa_base<Renderer>&); operator = (const line_interpolator_aa_base<Renderer>&);
protected: protected:
@ -584,7 +584,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
line_interpolator_aa0(renderer_type& ren, const line_parameters& lp) : line_interpolator_aa0(renderer_type& ren, const line_parameters& lp) :
line_interpolator_aa_base<Renderer>(ren, lp), line_interpolator_aa_base<Renderer>(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) lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask)
{ {
base_type::m_li.adjust_forward(); base_type::m_li.adjust_forward();
@ -614,9 +614,9 @@ namespace agg
*--p0 = (cover_type)base_type::m_ren.cover(dist); *--p0 = (cover_type)base_type::m_ren.cover(dist);
++dy; ++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, base_type::m_y - dy + 1,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return ++base_type::m_step < base_type::m_count; return ++base_type::m_step < base_type::m_count;
} }
@ -645,20 +645,20 @@ namespace agg
*--p0 = (cover_type)base_type::m_ren.cover(dist); *--p0 = (cover_type)base_type::m_ren.cover(dist);
++dx; ++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, base_type::m_y,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return ++base_type::m_step < base_type::m_count; return ++base_type::m_step < base_type::m_count;
} }
private: private:
line_interpolator_aa0(const line_interpolator_aa0<Renderer>&); line_interpolator_aa0(const line_interpolator_aa0<Renderer>&);
const line_interpolator_aa0<Renderer>& const line_interpolator_aa0<Renderer>&
operator = (const line_interpolator_aa0<Renderer>&); operator = (const line_interpolator_aa0<Renderer>&);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator1 m_di; distance_interpolator1 m_di;
}; };
@ -676,7 +676,7 @@ namespace agg
typedef line_interpolator_aa_base<Renderer> base_type; typedef line_interpolator_aa_base<Renderer> 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) : int sx, int sy) :
line_interpolator_aa_base<Renderer>(ren, lp), line_interpolator_aa_base<Renderer>(ren, lp),
m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, 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; 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; int dx = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -732,7 +732,7 @@ namespace agg
base_type::m_old_y = base_type::m_y; 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; int dy = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -779,7 +779,7 @@ namespace agg
dist_start -= m_di.dx_start(); dist_start -= m_di.dx_start();
*p1 = 0; *p1 = 0;
if(dist_start <= 0) if(dist_start <= 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
} }
++p1; ++p1;
@ -793,15 +793,15 @@ namespace agg
dist_start += m_di.dx_start(); dist_start += m_di.dx_start();
*--p0 = 0; *--p0 = 0;
if(dist_start <= 0) if(dist_start <= 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
} }
++dy; ++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, base_type::m_y - dy + 1,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return ++base_type::m_step < base_type::m_count; return ++base_type::m_step < base_type::m_count;
} }
@ -831,7 +831,7 @@ namespace agg
dist_start += m_di.dy_start(); dist_start += m_di.dy_start();
*p1 = 0; *p1 = 0;
if(dist_start <= 0) if(dist_start <= 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
} }
++p1; ++p1;
@ -845,25 +845,25 @@ namespace agg
dist_start -= m_di.dy_start(); dist_start -= m_di.dy_start();
*--p0 = 0; *--p0 = 0;
if(dist_start <= 0) if(dist_start <= 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
} }
++dx; ++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, base_type::m_y,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return ++base_type::m_step < base_type::m_count; return ++base_type::m_step < base_type::m_count;
} }
private: private:
line_interpolator_aa1(const line_interpolator_aa1<Renderer>&); line_interpolator_aa1(const line_interpolator_aa1<Renderer>&);
const line_interpolator_aa1<Renderer>& const line_interpolator_aa1<Renderer>&
operator = (const line_interpolator_aa1<Renderer>&); operator = (const line_interpolator_aa1<Renderer>&);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator2 m_di; distance_interpolator2 m_di;
}; };
@ -887,10 +887,10 @@ namespace agg
typedef line_interpolator_aa_base<Renderer> base_type; typedef line_interpolator_aa_base<Renderer> 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) : int ex, int ey) :
line_interpolator_aa_base<Renderer>(ren, lp), line_interpolator_aa_base<Renderer>(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, lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask,
0) 0)
{ {
@ -925,7 +925,7 @@ namespace agg
dist_end -= m_di.dx_end(); dist_end -= m_di.dx_end();
*p1 = 0; *p1 = 0;
if(dist_end > 0) if(dist_end > 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
@ -940,15 +940,15 @@ namespace agg
dist_end += m_di.dx_end(); dist_end += m_di.dx_end();
*--p0 = 0; *--p0 = 0;
if(dist_end > 0) if(dist_end > 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
++dy; ++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, base_type::m_y - dy + 1,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++base_type::m_step < base_type::m_count; return npix && ++base_type::m_step < base_type::m_count;
} }
@ -980,7 +980,7 @@ namespace agg
dist_end += m_di.dy_end(); dist_end += m_di.dy_end();
*p1 = 0; *p1 = 0;
if(dist_end > 0) if(dist_end > 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
@ -995,26 +995,26 @@ namespace agg
dist_end -= m_di.dy_end(); dist_end -= m_di.dy_end();
*--p0 = 0; *--p0 = 0;
if(dist_end > 0) if(dist_end > 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
++dx; ++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, base_type::m_y,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++base_type::m_step < base_type::m_count; return npix && ++base_type::m_step < base_type::m_count;
} }
private: private:
line_interpolator_aa2(const line_interpolator_aa2<Renderer>&); line_interpolator_aa2(const line_interpolator_aa2<Renderer>&);
const line_interpolator_aa2<Renderer>& const line_interpolator_aa2<Renderer>&
operator = (const line_interpolator_aa2<Renderer>&); operator = (const line_interpolator_aa2<Renderer>&);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator2 m_di; distance_interpolator2 m_di;
}; };
@ -1036,10 +1036,10 @@ namespace agg
typedef line_interpolator_aa_base<Renderer> base_type; typedef line_interpolator_aa_base<Renderer> 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) : int sx, int sy, int ex, int ey) :
line_interpolator_aa_base<Renderer>(ren, lp), line_interpolator_aa_base<Renderer>(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) lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask)
{ {
int dist1_start; int dist1_start;
@ -1058,7 +1058,7 @@ namespace agg
base_type::m_old_x = base_type::m_x; 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; int dx = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -1089,7 +1089,7 @@ namespace agg
base_type::m_old_y = base_type::m_y; 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; int dy = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -1145,7 +1145,7 @@ namespace agg
dist_end -= m_di.dx_end(); dist_end -= m_di.dx_end();
*p1 = 0; *p1 = 0;
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
@ -1162,15 +1162,15 @@ namespace agg
dist_end += m_di.dx_end(); dist_end += m_di.dx_end();
*--p0 = 0; *--p0 = 0;
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
++dy; ++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, base_type::m_y - dy + 1,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++base_type::m_step < base_type::m_count; return npix && ++base_type::m_step < base_type::m_count;
} }
@ -1208,7 +1208,7 @@ namespace agg
dist_end += m_di.dy_end(); dist_end += m_di.dy_end();
*p1 = 0; *p1 = 0;
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
*p1 = (cover_type)base_type::m_ren.cover(dist); *p1 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
@ -1225,26 +1225,26 @@ namespace agg
dist_end -= m_di.dy_end(); dist_end -= m_di.dy_end();
*--p0 = 0; *--p0 = 0;
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
*p0 = (cover_type)base_type::m_ren.cover(dist); *p0 = (cover_type)base_type::m_ren.cover(dist);
++npix; ++npix;
} }
++dx; ++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, base_type::m_y,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++base_type::m_step < base_type::m_count; return npix && ++base_type::m_step < base_type::m_count;
} }
private: private:
line_interpolator_aa3(const line_interpolator_aa3<Renderer>&); line_interpolator_aa3(const line_interpolator_aa3<Renderer>&);
const line_interpolator_aa3<Renderer>& const line_interpolator_aa3<Renderer>&
operator = (const line_interpolator_aa3<Renderer>&); operator = (const line_interpolator_aa3<Renderer>&);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator3 m_di; distance_interpolator3 m_di;
}; };
@ -1252,8 +1252,8 @@ namespace agg
//==========================================================line_profile_aa //==========================================================line_profile_aa
// //
// See Implementation agg_line_profile_aa.cpp // See Implementation agg_line_profile_aa.cpp
// //
class line_profile_aa class line_profile_aa
{ {
public: public:
@ -1272,9 +1272,9 @@ namespace agg
aa_scale = 1 << aa_shift, aa_scale = 1 << aa_shift,
aa_mask = aa_scale - 1 aa_mask = aa_scale - 1
}; };
//--------------------------------------------------------------------- //---------------------------------------------------------------------
line_profile_aa() : line_profile_aa() :
m_subpixel_width(0), m_subpixel_width(0),
m_min_width(1.0), m_min_width(1.0),
m_smoother_width(1.0) m_smoother_width(1.0)
@ -1284,8 +1284,8 @@ namespace agg
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
template<class GammaF> template<class GammaF>
line_profile_aa(double w, const GammaF& gamma_function) : line_profile_aa(double w, const GammaF& gamma_function) :
m_subpixel_width(0), m_subpixel_width(0),
m_min_width(1.0), m_min_width(1.0),
m_smoother_width(1.0) m_smoother_width(1.0)
@ -1300,7 +1300,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
template<class GammaF> void gamma(const GammaF& gamma_function) template<class GammaF> void gamma(const GammaF& gamma_function)
{ {
int i; int i;
for(i = 0; i < aa_scale; i++) for(i = 0; i < aa_scale; i++)
{ {
@ -1365,9 +1365,9 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void profile(const line_profile_aa& prof) { m_profile = &prof; } void profile(const line_profile_aa& prof) { m_profile = &prof; }
const line_profile_aa& profile() const { return *m_profile; } 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 // 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; } //line_profile_aa& profile() { return *m_profile; }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
@ -1408,14 +1408,14 @@ namespace agg
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template<class Cmp> template<class Cmp>
void semidot_hline(Cmp cmp, 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) int x1, int y1, int x2)
{ {
cover_type covers[line_interpolator_aa_base<self_type>::max_half_width * 2 + 4]; cover_type covers[line_interpolator_aa_base<self_type>::max_half_width * 2 + 4];
cover_type* p0 = covers; cover_type* p0 = covers;
cover_type* p1 = covers; cover_type* p1 = covers;
int x = x1 << line_subpixel_shift; int x = x1 * line_subpixel_scale;
int y = y1 << line_subpixel_shift; int y = y1 * line_subpixel_scale;
int w = subpixel_width(); int w = subpixel_width();
distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y); distance_interpolator0 di(xc1, yc1, xc2, yc2, x, y);
x += line_subpixel_scale/2; x += line_subpixel_scale/2;
@ -1437,14 +1437,14 @@ namespace agg
di.inc_x(); di.inc_x();
} }
while(++x1 <= x2); while(++x1 <= x2);
m_ren->blend_solid_hspan(x0, y1, m_ren->blend_solid_hspan(x0, y1,
unsigned(p1 - p0), unsigned(p1 - p0),
color(), color(),
p0); p0);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template<class Cmp> template<class Cmp>
void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2) void semidot(Cmp cmp, int xc1, int yc1, int xc2, int yc2)
{ {
if(m_clipping && clipping_flags(xc1, yc1, m_clip_box)) return; 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) int xh1, int yh1, int xh2)
{ {
if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return; if(m_clipping && clipping_flags(xc, yc, m_clip_box)) return;
cover_type covers[line_interpolator_aa_base<self_type>::max_half_width * 2 + 4]; cover_type covers[line_interpolator_aa_base<self_type>::max_half_width * 2 + 4];
cover_type* p0 = covers; cover_type* p0 = covers;
cover_type* p1 = covers; cover_type* p1 = covers;
int x = xh1 << line_subpixel_shift; int x = xh1 * line_subpixel_scale;
int y = yh1 << line_subpixel_shift; int y = yh1 * line_subpixel_scale;
int w = subpixel_width(); int w = subpixel_width();
distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y); distance_interpolator00 di(xc, yc, xp1, yp1, xp2, yp2, x, y);
@ -1510,9 +1510,9 @@ namespace agg
di.inc_x(); di.inc_x();
} }
while(++xh1 <= xh2); while(++xh1 <= xh2);
m_ren->blend_solid_hspan(xh0, yh1, m_ren->blend_solid_hspan(xh0, yh1,
unsigned(p1 - p0), unsigned(p1 - p0),
color(), color(),
p0); p0);
} }
@ -1588,7 +1588,7 @@ namespace agg
{ {
if(flags) if(flags)
{ {
line_parameters lp2(x1, y1, x2, y2, line_parameters lp2(x1, y1, x2, y2,
uround(calc_distance(x1, y1, x2, y2))); uround(calc_distance(x1, y1, x2, y2)));
line0_no_clip(lp2); line0_no_clip(lp2);
} }
@ -1643,11 +1643,11 @@ namespace agg
{ {
if(flags) if(flags)
{ {
line_parameters lp2(x1, y1, x2, y2, line_parameters lp2(x1, y1, x2, y2,
uround(calc_distance(x1, y1, x2, y2))); uround(calc_distance(x1, y1, x2, y2)));
if(flags & 1) if(flags & 1)
{ {
sx = x1 + (y2 - y1); sx = x1 + (y2 - y1);
sy = y1 - (x2 - x1); sy = y1 - (x2 - x1);
} }
else else
@ -1710,11 +1710,11 @@ namespace agg
{ {
if(flags) if(flags)
{ {
line_parameters lp2(x1, y1, x2, y2, line_parameters lp2(x1, y1, x2, y2,
uround(calc_distance(x1, y1, x2, y2))); uround(calc_distance(x1, y1, x2, y2)));
if(flags & 2) if(flags & 2)
{ {
ex = x2 + (y2 - y1); ex = x2 + (y2 - y1);
ey = y2 - (x2 - x1); ey = y2 - (x2 - x1);
} }
else 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) int sx, int sy, int ex, int ey)
{ {
if(lp.len > line_max_length) 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) int sx, int sy, int ex, int ey)
{ {
if(m_clipping) if(m_clipping)
@ -1782,11 +1782,11 @@ namespace agg
{ {
if(flags) if(flags)
{ {
line_parameters lp2(x1, y1, x2, y2, line_parameters lp2(x1, y1, x2, y2,
uround(calc_distance(x1, y1, x2, y2))); uround(calc_distance(x1, y1, x2, y2)));
if(flags & 1) if(flags & 1)
{ {
sx = x1 + (y2 - y1); sx = x1 + (y2 - y1);
sy = y1 - (x2 - x1); sy = y1 - (x2 - x1);
} }
else else
@ -1799,7 +1799,7 @@ namespace agg
} }
if(flags & 2) if(flags & 2)
{ {
ex = x2 + (y2 - y1); ex = x2 + (y2 - y1);
ey = y2 - (x2 - x1); ey = y2 - (x2 - x1);
} }
else else
@ -1827,7 +1827,7 @@ namespace agg
private: private:
base_ren_type* m_ren; base_ren_type* m_ren;
const line_profile_aa* m_profile; const line_profile_aa* m_profile;
color_type m_color; color_type m_color;
rect_i m_clip_box; rect_i m_clip_box;
bool m_clipping; bool m_clipping;

View file

@ -2,8 +2,8 @@
// Anti-Grain Geometry - Version 2.4 // Anti-Grain Geometry - Version 2.4
// Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com) // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
// //
// Permission to copy, use, modify, sell and distribute this software // Permission to copy, use, modify, sell and distribute this software
// is granted provided this copyright notice appears in all copies. // is granted provided this copyright notice appears in all copies.
// This software is provided "as is" without express or implied // This software is provided "as is" without express or implied
// warranty, and with no claim as to its suitability for any purpose. // 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; typedef typename Source::color_type color_type;
line_image_scale(const Source& src, double height) : line_image_scale(const Source& src, double height) :
m_source(src), m_source(src),
m_height(height), m_height(height),
m_scale(src.height() / height) m_scale(src.height() / height)
{ {
@ -41,8 +41,8 @@ namespace agg
double width() const { return m_source.width(); } double width() const { return m_source.width(); }
double height() const { return m_height; } 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; double src_y = (y + 0.5) * m_scale - 0.5;
int h = m_source.height() - 1; int h = m_source.height() - 1;
int y1 = ufloor(src_y); int y1 = ufloor(src_y);
@ -74,7 +74,7 @@ namespace agg
line_image_pattern(const Filter& filter) : line_image_pattern(const Filter& filter) :
m_filter(&filter), m_filter(&filter),
m_dilation(filter.dilation() + 1), m_dilation(filter.dilation() + 1),
m_dilation_hr(m_dilation << line_subpixel_shift), m_dilation_hr(m_dilation * line_subpixel_scale),
m_data(), m_data(),
m_width(0), m_width(0),
m_height(0), m_height(0),
@ -86,11 +86,11 @@ namespace agg
// Create // Create
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class Source> template<class Source>
line_image_pattern(const Filter& filter, const Source& src) : line_image_pattern(const Filter& filter, const Source& src) :
m_filter(&filter), m_filter(&filter),
m_dilation(filter.dilation() + 1), m_dilation(filter.dilation() + 1),
m_dilation_hr(m_dilation << line_subpixel_shift), m_dilation_hr(m_dilation * line_subpixel_scale),
m_data(), m_data(),
m_width(0), m_width(0),
m_height(0), m_height(0),
@ -114,8 +114,8 @@ namespace agg
m_data.resize((m_width + m_dilation * 2) * (m_height + m_dilation * 2)); 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_buf.attach(&m_data[0], m_width + m_dilation * 2,
m_height + m_dilation * 2, m_height + m_dilation * 2,
m_width + m_dilation * 2); m_width + m_dilation * 2);
unsigned x, y; unsigned x, y;
color_type* d1; color_type* d1;
@ -170,8 +170,8 @@ namespace agg
//-------------------------------------------------------------------- //--------------------------------------------------------------------
void pixel(color_type* p, int x, int y) const void pixel(color_type* p, int x, int y) const
{ {
m_filter->pixel_high_res(m_buf.rows(), m_filter->pixel_high_res(m_buf.rows(),
p, p,
x % m_width_hr + m_dilation_hr, x % m_width_hr + m_dilation_hr,
y + m_offset_y_hr); y + m_offset_y_hr);
} }
@ -181,7 +181,7 @@ namespace agg
private: private:
line_image_pattern(const line_image_pattern<filter_type>&); line_image_pattern(const line_image_pattern<filter_type>&);
const line_image_pattern<filter_type>& const line_image_pattern<filter_type>&
operator = (const line_image_pattern<filter_type>&); operator = (const line_image_pattern<filter_type>&);
protected: protected:
@ -203,7 +203,7 @@ namespace agg
//=================================================line_image_pattern_pow2 //=================================================line_image_pattern_pow2
template<class Filter> class line_image_pattern_pow2 : template<class Filter> class line_image_pattern_pow2 :
public line_image_pattern<Filter> public line_image_pattern<Filter>
{ {
public: public:
@ -216,19 +216,19 @@ namespace agg
line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask) {} line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask) {}
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class Source> template<class Source>
line_image_pattern_pow2(const Filter& filter, const Source& src) : line_image_pattern_pow2(const Filter& filter, const Source& src) :
line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask) line_image_pattern<Filter>(filter), m_mask(line_subpixel_mask)
{ {
create(src); create(src);
} }
//-------------------------------------------------------------------- //--------------------------------------------------------------------
template<class Source> void create(const Source& src) template<class Source> void create(const Source& src)
{ {
line_image_pattern<Filter>::create(src); line_image_pattern<Filter>::create(src);
m_mask = 1; m_mask = 1;
while(m_mask < base_type::m_width) while(m_mask < base_type::m_width)
{ {
m_mask <<= 1; m_mask <<= 1;
m_mask |= 1; m_mask |= 1;
@ -242,7 +242,7 @@ namespace agg
void pixel(color_type* p, int x, int y) const void pixel(color_type* p, int x, int y) const
{ {
base_type::m_filter->pixel_high_res( base_type::m_filter->pixel_high_res(
base_type::m_buf.rows(), base_type::m_buf.rows(),
p, p,
(x & m_mask) + base_type::m_dilation_hr, (x & m_mask) + base_type::m_dilation_hr,
y + base_type::m_offset_y_hr); y + base_type::m_offset_y_hr);
@ -250,13 +250,13 @@ namespace agg
private: private:
unsigned m_mask; unsigned m_mask;
}; };
//===================================================distance_interpolator4 //===================================================distance_interpolator4
class distance_interpolator4 class distance_interpolator4
{ {
@ -264,7 +264,7 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
distance_interpolator4() {} distance_interpolator4() {}
distance_interpolator4(int x1, int y1, int x2, int y2, 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) : int len, double scale, int x, int y) :
m_dx(x2 - x1), m_dx(x2 - x1),
m_dy(y2 - y1), m_dy(y2 - y1),
@ -273,88 +273,88 @@ namespace agg
m_dx_end(line_mr(ex) - line_mr(x2)), m_dx_end(line_mr(ex) - line_mr(x2)),
m_dy_end(line_mr(ey) - line_mr(y2)), 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))), 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), (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), (line_mr(y + line_subpixel_scale/2) - line_mr(ey)) * m_dx_end),
m_len(uround(len / scale)) m_len(uround(len / scale))
{ {
double d = len * scale; double d = len * scale;
int dx = iround(((x2 - x1) << line_subpixel_shift) / d); int dx = iround(((x2 - x1) * line_subpixel_scale) / d);
int dy = iround(((y2 - y1) << line_subpixel_shift) / d); int dy = iround(((y2 - y1) * line_subpixel_scale) / d);
m_dx_pict = -dy; m_dx_pict = -dy;
m_dy_pict = dx; m_dy_pict = dx;
m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict - m_dist_pict = ((x + line_subpixel_scale/2 - (x1 - dy)) * m_dy_pict -
(y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >> (y + line_subpixel_scale/2 - (y1 + dx)) * m_dx_pict) >>
line_subpixel_shift; line_subpixel_shift;
m_dx <<= line_subpixel_shift; m_dx *= line_subpixel_scale;
m_dy <<= line_subpixel_shift; m_dy *= line_subpixel_scale;
m_dx_start <<= line_mr_subpixel_shift; m_dx_start *= line_mr_subpixel_scale;
m_dy_start <<= line_mr_subpixel_shift; m_dy_start *= line_mr_subpixel_scale;
m_dx_end <<= line_mr_subpixel_shift; m_dx_end *= line_mr_subpixel_scale;
m_dy_end <<= line_mr_subpixel_shift; m_dy_end *= line_mr_subpixel_scale;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_x() void inc_x()
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict; m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_x() void dec_x()
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict; m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_y() void inc_y()
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict; m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_y() void dec_y()
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict; m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
} }
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_x(int dy) void inc_x(int dy)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict; m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict; m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict; m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
} }
} }
@ -362,22 +362,22 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_x(int dy) void dec_x(int dy)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict; m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
if(dy > 0) if(dy > 0)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict; m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
} }
if(dy < 0) if(dy < 0)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict; m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
} }
} }
@ -385,22 +385,22 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void inc_y(int dx) void inc_y(int dx)
{ {
m_dist -= m_dx; m_dist -= m_dx;
m_dist_start -= m_dx_start; m_dist_start -= m_dx_start;
m_dist_pict -= m_dx_pict; m_dist_pict -= m_dx_pict;
m_dist_end -= m_dx_end; m_dist_end -= m_dx_end;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict; m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict; m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
} }
} }
@ -408,22 +408,22 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
void dec_y(int dx) void dec_y(int dx)
{ {
m_dist += m_dx; m_dist += m_dx;
m_dist_start += m_dx_start; m_dist_start += m_dx_start;
m_dist_pict += m_dx_pict; m_dist_pict += m_dx_pict;
m_dist_end += m_dx_end; m_dist_end += m_dx_end;
if(dx > 0) if(dx > 0)
{ {
m_dist += m_dy; m_dist += m_dy;
m_dist_start += m_dy_start; m_dist_start += m_dy_start;
m_dist_pict += m_dy_pict; m_dist_pict += m_dy_pict;
m_dist_end += m_dy_end; m_dist_end += m_dy_end;
} }
if(dx < 0) if(dx < 0)
{ {
m_dist -= m_dy; m_dist -= m_dy;
m_dist_start -= m_dy_start; m_dist_start -= m_dy_start;
m_dist_pict -= m_dy_pict; m_dist_pict -= m_dy_pict;
m_dist_end -= m_dy_end; m_dist_end -= m_dy_end;
} }
} }
@ -476,20 +476,19 @@ namespace agg
//--------------------------------------------------------------------- //---------------------------------------------------------------------
enum max_half_width_e enum max_half_width_e
{ {
max_half_width = 64 max_half_width = 64
}; };
//--------------------------------------------------------------------- //---------------------------------------------------------------------
line_interpolator_image(renderer_type& ren, const line_parameters& lp, 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, int pattern_start,
double scale_x) : double scale_x) :
m_lp(lp), m_lp(lp),
m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) : m_li(lp.vertical ? line_dbl_hr(lp.x2 - lp.x1) :
line_dbl_hr(lp.y2 - lp.y1), line_dbl_hr(lp.y2 - lp.y1),
lp.vertical ? std::abs(lp.y2 - lp.y1) : lp.vertical ? lp.dy : lp.dx + 1),
std::abs(lp.x2 - lp.x1) + 1),
m_di(lp.x1, lp.y1, lp.x2, lp.y2, sx, sy, ex, ey, lp.len, scale_x, 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), lp.x1 & ~line_subpixel_mask, lp.y1 & ~line_subpixel_mask),
m_ren(ren), m_ren(ren),
@ -505,9 +504,9 @@ namespace agg
m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()), m_start(pattern_start + (m_max_extent + 2) * ren.pattern_width()),
m_step(0) m_step(0)
{ {
agg::dda2_line_interpolator li(0, lp.vertical ? agg::dda2_line_interpolator li(0, lp.vertical ?
(lp.dy << agg::line_subpixel_shift) : (lp.dy * agg::line_subpixel_scale) :
(lp.dx << agg::line_subpixel_shift), (lp.dx * agg::line_subpixel_scale),
lp.len); lp.len);
unsigned i; unsigned i;
@ -537,7 +536,7 @@ namespace agg
m_old_x = m_x; m_old_x = m_x;
dist1_start = dist2_start = m_di.dist_start(); dist1_start = dist2_start = m_di.dist_start();
int dx = 0; int dx = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -570,7 +569,7 @@ namespace agg
m_old_y = m_y; m_old_y = m_y;
dist1_start = dist2_start = m_di.dist_start(); dist1_start = dist2_start = m_di.dist_start();
int dy = 0; int dy = 0;
if(dist1_start < 0) ++npix; if(dist1_start < 0) ++npix;
@ -642,7 +641,7 @@ namespace agg
dist_end -= m_di.dx_end(); dist_end -= m_di.dx_end();
p1->clear(); p1->clear();
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
if(m_lp.inc > 0) dist = -dist; if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p1, dist_pict, s2 - dist); m_ren.pixel(p1, dist_pict, s2 - dist);
++npix; ++npix;
@ -663,17 +662,17 @@ namespace agg
--p0; --p0;
p0->clear(); p0->clear();
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
if(m_lp.inc > 0) dist = -dist; if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p0, dist_pict, s2 + dist); m_ren.pixel(p0, dist_pict, s2 + dist);
++npix; ++npix;
} }
++dy; ++dy;
} }
m_ren.blend_color_vspan(m_x, m_ren.blend_color_vspan(m_x,
m_y - dy + 1, m_y - dy + 1,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++m_step < m_count; return npix && ++m_step < m_count;
} }
@ -728,7 +727,7 @@ namespace agg
dist_end += m_di.dy_end(); dist_end += m_di.dy_end();
p1->clear(); p1->clear();
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
if(m_lp.inc > 0) dist = -dist; if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p1, dist_pict, s2 + dist); m_ren.pixel(p1, dist_pict, s2 + dist);
++npix; ++npix;
@ -749,16 +748,16 @@ namespace agg
--p0; --p0;
p0->clear(); p0->clear();
if(dist_end > 0 && dist_start <= 0) if(dist_end > 0 && dist_start <= 0)
{ {
if(m_lp.inc > 0) dist = -dist; if(m_lp.inc > 0) dist = -dist;
m_ren.pixel(p0, dist_pict, s2 - dist); m_ren.pixel(p0, dist_pict, s2 - dist);
++npix; ++npix;
} }
++dx; ++dx;
} }
m_ren.blend_color_hspan(m_x - dx + 1, m_ren.blend_color_hspan(m_x - dx + 1,
m_y, m_y,
unsigned(p1 - p0), unsigned(p1 - p0),
p0); p0);
return npix && ++m_step < m_count; return npix && ++m_step < m_count;
} }
@ -780,7 +779,7 @@ namespace agg
protected: protected:
const line_parameters& m_lp; const line_parameters& m_lp;
dda2_line_interpolator m_li; dda2_line_interpolator m_li;
distance_interpolator4 m_di; distance_interpolator4 m_di;
renderer_type& m_ren; renderer_type& m_ren;
int m_plen; int m_plen;
int m_x; int m_x;
@ -804,7 +803,7 @@ namespace agg
//===================================================renderer_outline_image //===================================================renderer_outline_image
template<class BaseRenderer, class ImagePattern> template<class BaseRenderer, class ImagePattern>
class renderer_outline_image class renderer_outline_image
{ {
public: public:
@ -876,7 +875,7 @@ namespace agg
static bool accurate_join_only() { return true; } static bool accurate_join_only() { return true; }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template<class Cmp> template<class Cmp>
void semidot(Cmp, int, int, int, int) 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) int sx, int sy, int ex, int ey)
{ {
if(lp.len > line_max_length) 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); line3_no_clip(lp2, mx, my, (lp.x2 + ex) >> 1, (lp.y2 + ey) >> 1);
return; return;
} }
fix_degenerate_bisectrix_start(lp, &sx, &sy); fix_degenerate_bisectrix_start(lp, &sx, &sy);
fix_degenerate_bisectrix_end(lp, &ex, &ey); fix_degenerate_bisectrix_end(lp, &ex, &ey);
line_interpolator_image<self_type> li(*this, lp, line_interpolator_image<self_type> li(*this, lp,
sx, sy, sx, sy,
ex, ey, ex, ey,
m_start, m_scale_x); m_start, m_scale_x);
if(li.vertical()) 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) int sx, int sy, int ex, int ey)
{ {
if(m_clipping) if(m_clipping)
@ -949,12 +948,12 @@ namespace agg
{ {
if(flags) if(flags)
{ {
line_parameters lp2(x1, y1, x2, y2, line_parameters lp2(x1, y1, x2, y2,
uround(calc_distance(x1, y1, x2, y2))); uround(calc_distance(x1, y1, x2, y2)));
if(flags & 1) if(flags & 1)
{ {
m_start += uround(calc_distance(lp.x1, lp.y1, x1, y1) / m_scale_x); 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); sy = y1 - (x2 - x1);
} }
else else
@ -967,7 +966,7 @@ namespace agg
} }
if(flags & 2) if(flags & 2)
{ {
ex = x2 + (y2 - y1); ex = x2 + (y2 - y1);
ey = y2 - (x2 - x1); ey = y2 - (x2 - x1);
} }
else else