use multiplication instead of << to avoid undefined behavour when LHS is a negative int (-fsanitize=undefined)
This commit is contained in:
parent
17a98767b4
commit
6815ac2869
3 changed files with 341 additions and 342 deletions
2
deps/agg/include/agg_line_aa_basics.h
vendored
2
deps/agg/include/agg_line_aa_basics.h
vendored
|
@ -56,7 +56,7 @@ namespace agg
|
||||||
//---------------------------------------------------------------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
|
||||||
|
|
56
deps/agg/include/agg_renderer_outline_aa.h
vendored
56
deps/agg/include/agg_renderer_outline_aa.h
vendored
|
@ -39,8 +39,8 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -72,10 +72,10 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -105,8 +105,8 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -182,10 +182,10 @@ namespace agg
|
||||||
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,
|
||||||
|
@ -201,10 +201,10 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -335,12 +335,12 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -494,8 +494,8 @@ namespace agg
|
||||||
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;
|
||||||
|
@ -1414,8 +1414,8 @@ namespace agg
|
||||||
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;
|
||||||
|
@ -1486,8 +1486,8 @@ namespace agg
|
||||||
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);
|
||||||
|
|
31
deps/agg/include/agg_renderer_outline_image.h
vendored
31
deps/agg/include/agg_renderer_outline_image.h
vendored
|
@ -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),
|
||||||
|
@ -90,7 +90,7 @@ namespace agg
|
||||||
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),
|
||||||
|
@ -284,20 +284,20 @@ namespace agg
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -487,9 +487,8 @@ namespace agg
|
||||||
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),
|
||||||
|
@ -506,8 +505,8 @@ namespace agg
|
||||||
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;
|
||||||
|
|
Loading…
Reference in a new issue