/* * Copyright 2023 Google LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "src/base/SkQuads.h" #include "include/private/base/SkAssert.h" #include "include/private/base/SkFloatingPoint.h" #include <cmath> #include <limits> // Solve 0 = M * x + B. If M is 0, there are no solutions, unless B is also 0, // in which case there are infinite solutions, so we just return 1 of them. static int solve_linear(const double M, const double B, double solution[2]) { … } // When B >> A, then the x^2 component doesn't contribute much to the output, so the second root // will be very large, but have massive round off error. Because of the round off error, the // second root will not evaluate to zero when substituted back into the quadratic equation. In // the situation when B >> A, then just treat the quadratic as a linear equation. static bool close_to_linear(double A, double B) { … } double SkQuads::Discriminant(const double a, const double b, const double c) { … } SkQuads::RootResult SkQuads::Roots(double A, double B, double C) { … } static double zero_if_tiny(double x) { … } int SkQuads::RootsReal(const double A, const double B, const double C, double solution[2]) { … } double SkQuads::EvalAt(double A, double B, double C, double t) { … }