Flutter Engine
 
Loading...
Searching...
No Matches
wangs_formula.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
6#define FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
7
10
11// Skia GPU Ports
12
13// Wang's formula gives the minimum number of evenly spaced (in the parametric
14// sense) line segments that a bezier curve must be chopped into in order to
15// guarantee all lines stay within a distance of "1/precision" pixels from the
16// true curve. Its definition for a bezier curve of degree "n" is as follows:
17//
18// maxLength = max([length(p[i+2] - 2p[i+1] + p[i]) for (0 <= i <= n-2)])
19// numParametricSegments = sqrt(maxLength * precision * n*(n - 1)/8)
20//
21// (Goldman, Ron. (2003). 5.6.3 Wang's Formula. "Pyramid Algorithms: A Dynamic
22// Programming Approach to Curves and Surfaces for Geometric Modeling". Morgan
23// Kaufmann Publishers.)
24namespace impeller {
25
26/// Returns the minimum number of evenly spaced (in the parametric sense) line
27/// segments that the cubic must be chopped into in order to guarantee all lines
28/// stay within a distance of "1/intolerance" pixels from the true curve.
29///
30/// The scale_factor should be the max basis XY of the current transform.
32 Point p0,
33 Point p1,
34 Point p2,
35 Point p3);
36
37/// Returns the minimum number of evenly spaced (in the parametric sense) line
38/// segments that the quadratic must be chopped into in order to guarantee all
39/// lines stay within a distance of "1/intolerance" pixels from the true curve.
40///
41/// The scale_factor should be the max basis XY of the current transform.
43 Point p0,
44 Point p1,
45 Point p2);
46
47/// Returns the minimum number of evenly spaced (in the parametric sense) line
48/// segments that the conic must be chopped into in order to guarantee all
49/// lines stay within a distance of "1/intolerance" pixels from the true curve.
50///
51/// The scale_factor should be the max basis XY of the current transform.
53 Point p0,
54 Point p1,
55 Point p2,
56 Scalar w);
57} // namespace impeller
58
59#endif // FLUTTER_IMPELLER_GEOMETRY_WANGS_FORMULA_H_
float Scalar
Definition scalar.h:19
TPoint< Scalar > Point
Definition point.h:327
Scalar ComputeConicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Scalar w)
Scalar ComputeQuadradicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2)
Scalar ComputeCubicSubdivisions(Scalar scale_factor, Point p0, Point p1, Point p2, Point p3)