18template <
typename... Rest>
19static float eval_poly(
float t,
float m,
float b, Rest... rest) {
25 auto valid = [](
float t) {
return t >= 0 && t <= 1; };
28 auto guess_nice_cubic_root = [](
float a,
float b,
float c,
float d) {
return -
d; };
29 float t = guess_nice_cubic_root(
A,
B,
C,
D);
32 const int MAX_ITERS = 8;
33 for (; iters < MAX_ITERS; ++iters) {
36 if (std::fabs(
f) <= 0.00005f) {
42 float numer = 2 *
fp *
f;
54 return x <= 0.0000000001f;
67 if (fType == kLine_Type) {
71 if (fType == kCubeRoot_Type) {
72 t = std::pow(
x / fCoeff[0].fX, 1.0f / 3);
76 float a = fCoeff[0].
fY;
77 float b = fCoeff[1].
fY;
78 float c = fCoeff[2].
fY;
79 float y = ((
a * t +
b) * t + c) * t;
85 return std::fabs(
delta) <= 0.0000001f;
96 (1 + s1 - s2).
store(&fCoeff[0]);
97 (s2 - s1 - s1).
store(&fCoeff[1]);
100 fType = kSolver_Type;
104 fType = kCubeRoot_Type;
static float cubic_solver(float A, float B, float C, float D)
static float eval_poly(float t, float b)
static bool nearly_zero(SkScalar x)
static bool coeff_nearly_zero(float delta)
static float compute_t_from_x(float A, float B, float C, float x)
static skvx::float4 fma(const skvx::float4 &f, float m, const skvx::float4 &a)
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
float computeYFromX(float x) const
SkPoint computeFromT(float t) const
SkCubicMap(SkPoint p1, SkPoint p2)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
static float max(float r, float g, float b)
static float min(float r, float g, float b)
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)