mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 728661 - Remove CalcVectorAngle and use AngleOfVector instead. r=jwatt
This commit is contained in:
parent
0dae4c03ad
commit
dcb4c35ec9
@ -535,7 +535,8 @@ SVGPathData::ToFlattenedPath(const gfxMatrix& aMatrix) const
|
||||
return ctx->GetFlattenedPath();
|
||||
}
|
||||
|
||||
static float AngleOfVector(gfxPoint v)
|
||||
static double
|
||||
AngleOfVector(const gfxPoint& aVector)
|
||||
{
|
||||
// C99 says about atan2 "A domain error may occur if both arguments are
|
||||
// zero" and "On a domain error, the function returns an implementation-
|
||||
@ -543,18 +544,13 @@ static float AngleOfVector(gfxPoint v)
|
||||
// seems to commonly be zero, but it could just as easily be a NaN value.
|
||||
// We specifically want zero in this case, hence the check:
|
||||
|
||||
return (v != gfxPoint(0.0f, 0.0f)) ? atan2(v.y, v.x) : 0.0f;
|
||||
return (aVector != gfxPoint(0.0, 0.0)) ? atan2(aVector.y, aVector.x) : 0.0;
|
||||
}
|
||||
|
||||
// TODO replace callers with calls to AngleOfVector
|
||||
static double
|
||||
CalcVectorAngle(double ux, double uy, double vx, double vy)
|
||||
static float
|
||||
AngleOfVectorF(const gfxPoint& aVector)
|
||||
{
|
||||
double ta = atan2(uy, ux);
|
||||
double tb = atan2(vy, vx);
|
||||
if (tb >= ta)
|
||||
return tb-ta;
|
||||
return 2 * M_PI - (ta-tb);
|
||||
return static_cast<float>(AngleOfVector(aVector));
|
||||
}
|
||||
|
||||
void
|
||||
@ -588,7 +584,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
{
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CLOSEPATH:
|
||||
segEnd = pathStart;
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_MOVETO_ABS:
|
||||
@ -601,7 +597,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
pathStart = segEnd;
|
||||
// If authors are going to specify multiple consecutive moveto commands
|
||||
// with markers, me might as well make the angle do something useful:
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
@ -612,7 +608,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
} else {
|
||||
segEnd = segStart + gfxPoint(mData[i], mData[i+1]);
|
||||
}
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
i += 2;
|
||||
break;
|
||||
|
||||
@ -636,8 +632,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
if (cp2 == segEnd) {
|
||||
cp2 = cp1;
|
||||
}
|
||||
segStartAngle = AngleOfVector(cp1 - segStart);
|
||||
segEndAngle = AngleOfVector(segEnd - cp2);
|
||||
segStartAngle = AngleOfVectorF(cp1 - segStart);
|
||||
segEndAngle = AngleOfVectorF(segEnd - cp2);
|
||||
i += 6;
|
||||
break;
|
||||
}
|
||||
@ -654,8 +650,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
segEnd = segStart + gfxPoint(mData[i+2], mData[i+3]);
|
||||
}
|
||||
prevCP = cp1;
|
||||
segStartAngle = AngleOfVector(cp1 - segStart);
|
||||
segEndAngle = AngleOfVector(segEnd - cp1);
|
||||
segStartAngle = AngleOfVectorF(cp1 - segStart);
|
||||
segEndAngle = AngleOfVectorF(segEnd - cp1);
|
||||
i += 4;
|
||||
break;
|
||||
}
|
||||
@ -695,7 +691,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
|
||||
if (rx == 0.0 || ry == 0.0) {
|
||||
// F.6.6 step 1 - straight line or coincidental points
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
i += 7;
|
||||
break;
|
||||
}
|
||||
@ -736,9 +732,10 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
double cyp = -root * ry * x1p / rx;
|
||||
|
||||
double theta, delta;
|
||||
theta = CalcVectorAngle(1.0, 0.0, (x1p-cxp)/rx, (y1p-cyp)/ry); // F.6.5.5
|
||||
delta = CalcVectorAngle((x1p-cxp)/rx, (y1p-cyp)/ry,
|
||||
(-x1p-cxp)/rx, (-y1p-cyp)/ry); // F.6.5.6
|
||||
theta = AngleOfVector(gfxPoint((x1p-cxp)/rx, (y1p-cyp)/ry) - // F.6.5.5
|
||||
gfxPoint(1.0, 0.0));
|
||||
delta = AngleOfVector(gfxPoint((-x1p-cxp)/rx, (-y1p-cyp)/ry) - // F.6.5.6
|
||||
gfxPoint((x1p-cxp)/rx, (y1p-cyp)/ry));
|
||||
if (!sweepFlag && delta > 0)
|
||||
delta -= 2.0 * M_PI;
|
||||
else if (sweepFlag && delta < 0)
|
||||
@ -757,8 +754,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
ty2 = -ty2;
|
||||
}
|
||||
|
||||
segStartAngle = atan2(ty1, tx1);
|
||||
segEndAngle = atan2(ty2, tx2);
|
||||
segStartAngle = static_cast<float>(atan2(ty1, tx1));
|
||||
segEndAngle = static_cast<float>(atan2(ty2, tx2));
|
||||
i += 7;
|
||||
break;
|
||||
}
|
||||
@ -770,7 +767,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
} else {
|
||||
segEnd = segStart + gfxPoint(mData[i++], 0.0f);
|
||||
}
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_LINETO_VERTICAL_ABS:
|
||||
@ -780,7 +777,7 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
} else {
|
||||
segEnd = segStart + gfxPoint(0.0f, mData[i++]);
|
||||
}
|
||||
segStartAngle = segEndAngle = AngleOfVector(segEnd - segStart);
|
||||
segStartAngle = segEndAngle = AngleOfVectorF(segEnd - segStart);
|
||||
break;
|
||||
|
||||
case nsIDOMSVGPathSeg::PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
|
||||
@ -803,8 +800,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
if (cp2 == segEnd) {
|
||||
cp2 = cp1;
|
||||
}
|
||||
segStartAngle = AngleOfVector(cp1 - segStart);
|
||||
segEndAngle = AngleOfVector(segEnd - cp2);
|
||||
segStartAngle = AngleOfVectorF(cp1 - segStart);
|
||||
segEndAngle = AngleOfVectorF(segEnd - cp2);
|
||||
i += 4;
|
||||
break;
|
||||
}
|
||||
@ -821,8 +818,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
segEnd = segStart + gfxPoint(mData[i], mData[i+1]);
|
||||
}
|
||||
prevCP = cp1;
|
||||
segStartAngle = AngleOfVector(cp1 - segStart);
|
||||
segEndAngle = AngleOfVector(segEnd - cp1);
|
||||
segStartAngle = AngleOfVectorF(cp1 - segStart);
|
||||
segEndAngle = AngleOfVectorF(segEnd - cp1);
|
||||
i += 2;
|
||||
break;
|
||||
}
|
||||
@ -852,7 +849,8 @@ SVGPathData::GetMarkerPositioningData(nsTArray<nsSVGMark> *aMarks) const
|
||||
}
|
||||
|
||||
// Add the mark at the end of this segment, and set its position:
|
||||
if (!aMarks->AppendElement(nsSVGMark(segEnd.x, segEnd.y, 0))) {
|
||||
if (!aMarks->AppendElement(nsSVGMark(static_cast<float>(segEnd.x),
|
||||
static_cast<float>(segEnd.y), 0))) {
|
||||
aMarks->Clear(); // OOM, so try to free some
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user