diff --git a/src/gpu/geometry/GrAAConvexTessellator.cpp b/src/gpu/geometry/GrAAConvexTessellator.cpp index 7d89f36331..c561769c5a 100644 --- a/src/gpu/geometry/GrAAConvexTessellator.cpp +++ b/src/gpu/geometry/GrAAConvexTessellator.cpp @@ -20,19 +20,21 @@ // test more degenerate cases // The tolerance for fusing vertices and eliminating colinear lines (It is in device space). -static const SkScalar kClose = (SK_Scalar1 / 16); -static const SkScalar kCloseSqd = kClose * kClose; +static constexpr SkScalar kClose = (SK_Scalar1 / 16); +static constexpr SkScalar kCloseSqd = kClose * kClose; // tesselation tolerance values, in device space pixels -static const SkScalar kQuadTolerance = 0.2f; -static const SkScalar kCubicTolerance = 0.2f; -static const SkScalar kConicTolerance = 0.25f; +static constexpr SkScalar kQuadTolerance = 0.2f; +static constexpr SkScalar kCubicTolerance = 0.2f; +static constexpr SkScalar kQuadToleranceSqd = kQuadTolerance * kQuadTolerance; +static constexpr SkScalar kCubicToleranceSqd = kCubicTolerance * kCubicTolerance; +static constexpr SkScalar kConicTolerance = 0.25f; // dot product below which we use a round cap between curve segments -static const SkScalar kRoundCapThreshold = 0.8f; +static constexpr SkScalar kRoundCapThreshold = 0.8f; // dot product above which we consider two adjacent curves to be part of the "same" curve -static const SkScalar kCurveConnectionThreshold = 0.8f; +static constexpr SkScalar kCurveConnectionThreshold = 0.8f; static bool intersect(const SkPoint& p0, const SkPoint& n0, const SkPoint& p1, const SkPoint& n1, @@ -964,7 +966,7 @@ void GrAAConvexTessellator::quadTo(const SkPoint pts[3]) { fPointBuffer.setCount(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2], - kQuadTolerance, &target, maxCount); + kQuadToleranceSqd, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count - 1; i++) { this->lineTo(fPointBuffer[i], kCurve_CurveState); @@ -985,7 +987,7 @@ void GrAAConvexTessellator::cubicTo(const SkMatrix& m, const SkPoint srcPts[4]) fPointBuffer.setCount(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3], - kCubicTolerance, &target, maxCount); + kCubicToleranceSqd, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count - 1; i++) { this->lineTo(fPointBuffer[i], kCurve_CurveState); diff --git a/src/utils/SkShadowTessellator.cpp b/src/utils/SkShadowTessellator.cpp index 843712f727..e0bbc02db9 100644 --- a/src/utils/SkShadowTessellator.cpp +++ b/src/utils/SkShadowTessellator.cpp @@ -726,10 +726,12 @@ void SkBaseShadowTessellator::stitchConcaveRings(const SkTDArray& umbra // tesselation tolerance values, in device space pixels #if SK_SUPPORT_GPU -static const SkScalar kQuadTolerance = 0.2f; -static const SkScalar kCubicTolerance = 0.2f; +static constexpr SkScalar kQuadTolerance = 0.2f; +static constexpr SkScalar kCubicTolerance = 0.2f; +static constexpr SkScalar kQuadToleranceSqd = kQuadTolerance * kQuadTolerance; +static constexpr SkScalar kCubicToleranceSqd = kCubicTolerance * kCubicTolerance; #endif -static const SkScalar kConicTolerance = 0.25f; +static constexpr SkScalar kConicTolerance = 0.25f; // clamps the point to the nearest 16th of a pixel static void sanitize_point(const SkPoint& in, SkPoint* out) { @@ -783,7 +785,7 @@ void SkBaseShadowTessellator::handleQuad(const SkPoint pts[3]) { fPointBuffer.setCount(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateQuadraticPoints(pts[0], pts[1], pts[2], - kQuadTolerance, &target, maxCount); + kQuadToleranceSqd, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count; i++) { this->handleLine(fPointBuffer[i]); @@ -808,7 +810,7 @@ void SkBaseShadowTessellator::handleCubic(const SkMatrix& m, SkPoint pts[4]) { fPointBuffer.setCount(maxCount); SkPoint* target = fPointBuffer.begin(); int count = GrPathUtils::generateCubicPoints(pts[0], pts[1], pts[2], pts[3], - kCubicTolerance, &target, maxCount); + kCubicToleranceSqd, &target, maxCount); fPointBuffer.setCount(count); for (int i = 0; i < count; i++) { this->handleLine(fPointBuffer[i]);