@@ -9,50 +9,44 @@ namespace impeller {
99namespace {
1010
1111// Don't allow linearized segments to be off by more than 1/4th of a pixel from
12- // the true curve.
12+ // the true curve. This value should be scaled by the max basis of the
13+ // X and Y directions.
1314constexpr static Scalar kPrecision = 4 ;
1415
15- static inline Scalar length (Point n) {
16+ constexpr Scalar length (Point n) {
1617 Point nn = n * n;
1718 return std::sqrt (nn.x + nn.y );
1819}
1920
20- static inline Point Max (Point a, Point b) {
21- return Point{
22- a.x > b.x ? a.x : b.x , //
23- a.y > b.y ? a.y : b.y //
24- };
25- }
26-
2721} // namespace
2822
29- Scalar ComputeCubicSubdivisions (Scalar intolerance ,
23+ Scalar ComputeCubicSubdivisions (Scalar scale_factor ,
3024 Point p0,
3125 Point p1,
3226 Point p2,
3327 Point p3) {
34- Scalar k = intolerance * .75f * kPrecision ;
28+ Scalar k = scale_factor * .75f * kPrecision ;
3529 Point a = (p0 - p1 * 2 + p2).Abs ();
3630 Point b = (p1 - p2 * 2 + p3).Abs ();
37- return std::sqrt (k * length (Max (a, b)));
31+ return std::sqrt (k * length (a. Max (b)));
3832}
3933
40- Scalar ComputeQuadradicSubdivisions (Scalar intolerance ,
34+ Scalar ComputeQuadradicSubdivisions (Scalar scale_factor ,
4135 Point p0,
4236 Point p1,
4337 Point p2) {
44- Scalar k = intolerance * .25f * kPrecision ;
38+ Scalar k = scale_factor * .25f * kPrecision ;
4539 return std::sqrt (k * length (p0 - p1 * 2 + p2));
4640}
4741
48- Scalar ComputeQuadradicSubdivisions (Scalar intolerance ,
42+ Scalar ComputeQuadradicSubdivisions (Scalar scale_factor ,
4943 const QuadraticPathComponent& quad) {
50- return ComputeQuadradicSubdivisions (intolerance , quad.p1 , quad.cp , quad.p2 );
44+ return ComputeQuadradicSubdivisions (scale_factor , quad.p1 , quad.cp , quad.p2 );
5145}
5246
53- Scalar ComputeCubicSubdivisions (float intolerance ,
47+ Scalar ComputeCubicSubdivisions (float scale_factor ,
5448 const CubicPathComponent& cub) {
55- return ComputeCubicSubdivisions (intolerance , cub.p1 , cub.cp1 , cub.cp2 ,
49+ return ComputeCubicSubdivisions (scale_factor , cub.p1 , cub.cp1 , cub.cp2 ,
5650 cub.p2 );
5751}
5852
0 commit comments