headers/libs/agg Fix PVS 33

* Fix successive assignment of 'da'

	* also trailing whitespace removal

Change-Id: Ic127150c18c042839d4104ccc5830adf19550399
Reviewed-on: https://review.haiku-os.org/c/954
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Rob Gill
2019-01-29 04:04:01 +00:00
committed by waddlesplash
parent d1f885b435
commit 434c347111
+55 -56
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.
// //
@@ -81,28 +81,28 @@ namespace agg
double approximation_scale() const { return m_approx_scale; } double approximation_scale() const { return m_approx_scale; }
void calc_cap(VertexConsumer& out_vertices, void calc_cap(VertexConsumer& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
double len); double len);
void calc_join(VertexConsumer& out_vertices, void calc_join(VertexConsumer& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
const vertex_dist& v2, const vertex_dist& v2,
double len1, double len1,
double len2); double len2);
private: private:
void calc_arc(VertexConsumer& out_vertices, void calc_arc(VertexConsumer& out_vertices,
double x, double y, double x, double y,
double dx1, double dy1, double dx1, double dy1,
double dx2, double dy2); double dx2, double dy2);
void calc_miter(VertexConsumer& out_vertices, void calc_miter(VertexConsumer& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
const vertex_dist& v2, const vertex_dist& v2,
double dx1, double dy1, double dx1, double dy1,
double dx2, double dy2, double dx2, double dy2,
line_join_e lj, line_join_e lj,
double ml); double ml);
@@ -134,8 +134,8 @@ namespace agg
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
template<class VC> void math_stroke<VC>::width(double w) template<class VC> void math_stroke<VC>::width(double w)
{ {
m_width = w * 0.5; m_width = w * 0.5;
if(m_width < 0) if(m_width < 0)
{ {
m_width_abs = -m_width; m_width_abs = -m_width;
@@ -150,23 +150,22 @@ namespace agg
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
template<class VC> void math_stroke<VC>::miter_limit_theta(double t) template<class VC> void math_stroke<VC>::miter_limit_theta(double t)
{ {
m_miter_limit = 1.0 / sin(t * 0.5) ; m_miter_limit = 1.0 / sin(t * 0.5) ;
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
template<class VC> template<class VC>
void math_stroke<VC>::calc_arc(VC& out_vertices, void math_stroke<VC>::calc_arc(VC& out_vertices,
double x, double y, double x, double y,
double dx1, double dy1, double dx1, double dy1,
double dx2, double dy2) double dx2, double dy2)
{ {
double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign); double a1 = atan2(dy1 * m_width_sign, dx1 * m_width_sign);
double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign); double a2 = atan2(dy2 * m_width_sign, dx2 * m_width_sign);
double da = a1 - a2; double da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
int i, n; int i, n;
da = acos(m_width_abs / (m_width_abs + 0.125 / m_approx_scale)) * 2;
out_vertices.add(coord_type(x + dx1, y + dy1)); out_vertices.add(coord_type(x + dx1, y + dy1));
if(m_width_sign > 0) if(m_width_sign > 0)
@@ -177,7 +176,7 @@ namespace agg
a1 += da; a1 += da;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
out_vertices.add(coord_type(x + cos(a1) * m_width, out_vertices.add(coord_type(x + cos(a1) * m_width,
y + sin(a1) * m_width)); y + sin(a1) * m_width));
a1 += da; a1 += da;
} }
@@ -190,7 +189,7 @@ namespace agg
a1 -= da; a1 -= da;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
out_vertices.add(coord_type(x + cos(a1) * m_width, out_vertices.add(coord_type(x + cos(a1) * m_width,
y + sin(a1) * m_width)); y + sin(a1) * m_width));
a1 -= da; a1 -= da;
} }
@@ -199,12 +198,12 @@ namespace agg
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
template<class VC> template<class VC>
void math_stroke<VC>::calc_miter(VC& out_vertices, void math_stroke<VC>::calc_miter(VC& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
const vertex_dist& v2, const vertex_dist& v2,
double dx1, double dy1, double dx1, double dy1,
double dx2, double dy2, double dx2, double dy2,
line_join_e lj, line_join_e lj,
double ml) double ml)
@@ -234,8 +233,8 @@ namespace agg
else else
{ {
// Calculation of the intersection failed, most probably // Calculation of the intersection failed, most probably
// the three points lie one straight line. // the three points lie one straight line.
// First check if v0 and v2 lie on the opposite sides of vector: // First check if v0 and v2 lie on the opposite sides of vector:
// (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular // (v1.x, v1.y) -> (v1.x+dx1, v1.y-dy1), that is, the perpendicular
// to the line determined by vertices v0 and v1. // to the line determined by vertices v0 and v1.
// This condition determines whether the next line segments continues // This condition determines whether the next line segments continues
@@ -246,7 +245,7 @@ namespace agg
if(((x2 - v0.x)*dy1 - (v0.y - y2)*dx1 < 0.0) != if(((x2 - v0.x)*dy1 - (v0.y - y2)*dx1 < 0.0) !=
((x2 - v2.x)*dy1 - (v2.y - y2)*dx1 < 0.0)) ((x2 - v2.x)*dy1 - (v2.y - y2)*dx1 < 0.0))
{ {
// This case means that the next segment continues // This case means that the next segment continues
// the previous one (straight line) // the previous one (straight line)
//----------------- //-----------------
out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1)); out_vertices.add(coord_type(v1.x + dx1, v1.y - dy1));
@@ -261,7 +260,7 @@ namespace agg
switch(lj) switch(lj)
{ {
case miter_join_revert: case miter_join_revert:
// For the compatibility with SVG, PDF, etc, // For the compatibility with SVG, PDF, etc,
// we use a simple bevel join instead of // we use a simple bevel join instead of
// "smart" bevel // "smart" bevel
//------------------- //-------------------
@@ -277,9 +276,9 @@ namespace agg
// If no miter-revert, calculate new dx1, dy1, dx2, dy2 // If no miter-revert, calculate new dx1, dy1, dx2, dy2
//---------------- //----------------
ml *= m_width_sign; ml *= m_width_sign;
out_vertices.add(coord_type(v1.x + dx1 + dy1 * ml, out_vertices.add(coord_type(v1.x + dx1 + dy1 * ml,
v1.y - dy1 + dx1 * ml)); v1.y - dy1 + dx1 * ml));
out_vertices.add(coord_type(v1.x + dx2 - dy2 * ml, out_vertices.add(coord_type(v1.x + dx2 - dy2 * ml,
v1.y - dy2 - dx2 * ml)); v1.y - dy2 - dx2 * ml));
break; break;
} }
@@ -287,10 +286,10 @@ namespace agg
} }
//--------------------------------------------------------stroke_calc_cap //--------------------------------------------------------stroke_calc_cap
template<class VC> template<class VC>
void math_stroke<VC>::calc_cap(VC& out_vertices, void math_stroke<VC>::calc_cap(VC& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
double len) double len)
{ {
out_vertices.remove_all(); out_vertices.remove_all();
@@ -328,7 +327,7 @@ namespace agg
a1 += da; a1 += da;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
out_vertices.add(coord_type(v0.x + cos(a1) * m_width, out_vertices.add(coord_type(v0.x + cos(a1) * m_width,
v0.y + sin(a1) * m_width)); v0.y + sin(a1) * m_width));
a1 += da; a1 += da;
} }
@@ -339,7 +338,7 @@ namespace agg
a1 -= da; a1 -= da;
for(i = 0; i < n; i++) for(i = 0; i < n; i++)
{ {
out_vertices.add(coord_type(v0.x + cos(a1) * m_width, out_vertices.add(coord_type(v0.x + cos(a1) * m_width,
v0.y + sin(a1) * m_width)); v0.y + sin(a1) * m_width));
a1 -= da; a1 -= da;
} }
@@ -349,12 +348,12 @@ namespace agg
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
template<class VC> template<class VC>
void math_stroke<VC>::calc_join(VC& out_vertices, void math_stroke<VC>::calc_join(VC& out_vertices,
const vertex_dist& v0, const vertex_dist& v0,
const vertex_dist& v1, const vertex_dist& v1,
const vertex_dist& v2, const vertex_dist& v2,
double len1, double len1,
double len2) double len2)
{ {
double dx1, dy1, dx2, dy2; double dx1, dy1, dx2, dy2;
@@ -388,8 +387,8 @@ namespace agg
case inner_miter: case inner_miter:
calc_miter(out_vertices, calc_miter(out_vertices,
v0, v1, v2, dx1, dy1, dx2, dy2, v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert, miter_join_revert,
limit); limit);
break; break;
@@ -400,8 +399,8 @@ namespace agg
if(d < len1 * len1 && d < len2 * len2) if(d < len1 * len1 && d < len2 * len2)
{ {
calc_miter(out_vertices, calc_miter(out_vertices,
v0, v1, v2, dx1, dy1, dx2, dy2, v0, v1, v2, dx1, dy1, dx2, dy2,
miter_join_revert, miter_join_revert,
limit); limit);
} }
else else
@@ -432,21 +431,21 @@ namespace agg
line_join_e lj = m_line_join; line_join_e lj = m_line_join;
if(m_line_join == round_join || m_line_join == bevel_join) if(m_line_join == round_join || m_line_join == bevel_join)
{ {
// This is an optimization that reduces the number of points // This is an optimization that reduces the number of points
// in cases of almost collonear segments. If there's no // in cases of almost collonear segments. If there's no
// visible difference between bevel and miter joins we'd rather // visible difference between bevel and miter joins we'd rather
// use miter join because it adds only one point instead of two. // use miter join because it adds only one point instead of two.
// //
// Here we calculate the middle point between the bevel points // Here we calculate the middle point between the bevel points
// and then, the distance between v1 and this middle point. // and then, the distance between v1 and this middle point.
// At outer joins this distance always less than stroke width, // At outer joins this distance always less than stroke width,
// because it's actually the height of an isosceles triangle of // because it's actually the height of an isosceles triangle of
// v1 and its two bevel points. If the difference between this // v1 and its two bevel points. If the difference between this
// width and this value is small (no visible bevel) we can switch // width and this value is small (no visible bevel) we can switch
// to the miter join. // to the miter join.
// //
// The constant in the expression makes the result approximately // The constant in the expression makes the result approximately
// the same as in round joins and caps. One can safely comment // the same as in round joins and caps. One can safely comment
// out this "if". // out this "if".
//------------------- //-------------------
double dx = (dx1 + dx2) / 2; double dx = (dx1 + dx2) / 2;
@@ -463,9 +462,9 @@ namespace agg
case miter_join: case miter_join:
case miter_join_revert: case miter_join_revert:
case miter_join_round: case miter_join_round:
calc_miter(out_vertices, calc_miter(out_vertices,
v0, v1, v2, dx1, dy1, dx2, dy2, v0, v1, v2, dx1, dy1, dx2, dy2,
lj, lj,
m_miter_limit); m_miter_limit);
break; break;