Flutter Engine
The Flutter Engine
|
#include "src/core/SkGeometry.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPoint3.h"
#include "include/core/SkRect.h"
#include "include/core/SkScalar.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkTPin.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkBezierCurves.h"
#include "src/base/SkCubics.h"
#include "src/base/SkUtils.h"
#include "src/base/SkVx.h"
#include "src/core/SkPointPriv.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <cstdint>
Go to the source code of this file.
Macros | |
#define | AS_QUAD_ERROR_SETUP |
#define | kMaxConicToQuadPOW2 5 |
#define AS_QUAD_ERROR_SETUP |
Definition at line 1469 of file SkGeometry.cpp.
#define kMaxConicToQuadPOW2 5 |
Definition at line 1486 of file SkGeometry.cpp.
Definition at line 1525 of file SkGeometry.cpp.
Definition at line 881 of file SkGeometry.cpp.
Definition at line 1091 of file SkGeometry.cpp.
|
static |
Definition at line 771 of file SkGeometry.cpp.
|
static |
Definition at line 1152 of file SkGeometry.cpp.
Given an array and count, remove all pair-wise duplicates from the array, keeping the existing sorting, and return the new count
Definition at line 896 of file SkGeometry.cpp.
Definition at line 1251 of file SkGeometry.cpp.
Definition at line 1262 of file SkGeometry.cpp.
Definition at line 407 of file SkGeometry.cpp.
Definition at line 394 of file SkGeometry.cpp.
|
static |
Definition at line 1156 of file SkGeometry.cpp.
|
static |
Definition at line 686 of file SkGeometry.cpp.
|
inlinestatic |
Definition at line 272 of file SkGeometry.cpp.
|
static |
Definition at line 597 of file SkGeometry.cpp.
Definition at line 1021 of file SkGeometry.cpp.
Definition at line 169 of file SkGeometry.cpp.
Definition at line 1098 of file SkGeometry.cpp.
Definition at line 1278 of file SkGeometry.cpp.
|
inlinestatic |
Definition at line 782 of file SkGeometry.cpp.
Given a src cubic bezier, chop it at the specified t0 and t1 values, where 0 <= t0 <= t1 <= 1, and return the three new cubics in dst: dst[0..3], dst[3..6], and dst[6..9]
Definition at line 504 of file SkGeometry.cpp.
Given a src cubic bezier, chop it at the specified t value, where 0 <= t <= 1, and return the two new cubics in dst: dst[0..3] and dst[3..6]
Definition at line 473 of file SkGeometry.cpp.
Given a src cubic bezier, chop it at the specified t values, where 0 <= t0 <= t1 <= ... <= 1, and return the new cubics in dst: dst[0..3],dst[3..6],...,dst[3*t_count..3*(t_count+1)]
Definition at line 541 of file SkGeometry.cpp.
Given a src cubic bezier, chop it at the specified t == 1/2, The new cubics are returned in dst[0..3] and dst[3..6]
Definition at line 575 of file SkGeometry.cpp.
Return 1 for no chop, 2 for having chopped the cubic at a single inflection point, 3 for having chopped at 2 inflection points. dst will hold the resulting 1, 2, or 3 cubics.
Definition at line 755 of file SkGeometry.cpp.
Definition at line 1060 of file SkGeometry.cpp.
Definition at line 714 of file SkGeometry.cpp.
Given 4 points on a cubic bezier, chop it into 1, 2, 3 beziers such that the resulting beziers are monotonic in Y. This is called by the scan converter. Depending on what is returned, dst[] is treated as follows: 0 dst[0..3] is the original cubic 1 dst[0..3] and dst[3..6] are the two new cubics 2 dst[0..3], dst[3..6], dst[6..9] are the three new cubics If dst == null, it is ignored and only the count is returned.
Definition at line 698 of file SkGeometry.cpp.
Given a monotonically increasing or decreasing cubic bezier src, chop it where the X value is the specified value. The returned cubics will be in dst, sharing the middle point. That is, the first cubic is dst[0..3] and the second dst[3..6].
If the cubic provided is not monotone, it will be chopped at the first time the curve has the specified X value.
If the cubic never reaches the specified value, the function returns false.
Definition at line 1204 of file SkGeometry.cpp.
Given a monotonically increasing or decreasing cubic bezier src, chop it where the Y value is the specified value. The returned cubics will be in dst, sharing the middle point. That is, the first cubic is dst[0..3] and the second dst[3..6].
If the cubic provided is not monotone, it will be chopped at the first time the curve has the specified Y value.
If the cubic never reaches the specified value, the function returns false.
Definition at line 1188 of file SkGeometry.cpp.
Given a src quadratic bezier, chop it at the specified t value, where 0 < t < 1, and return the two new quadratics in dst: dst[0..2] and dst[2..4]
Definition at line 175 of file SkGeometry.cpp.
Given a src quadratic bezier, chop it at the specified t == 1/2, The new quads are returned in dst[0..2] and dst[2..4]
Definition at line 193 of file SkGeometry.cpp.
Given 3 points on a quadratic bezier, divide it into 2 quadratics if the point of maximum curvature exists on the quad segment. Depending on what is returned, dst[] is treated as follows 1 dst[0..2] is the original quad 2 dst[0..2] and dst[2..4] are the two new quads If dst == null, it is ignored and only the count is returned.
Definition at line 367 of file SkGeometry.cpp.
Definition at line 307 of file SkGeometry.cpp.
Given 3 points on a quadratic bezier, chop it into 1, 2 beziers such that the resulting beziers are monotonic in Y. This is called by the scan converter. Depending on what is returned, dst[] is treated as follows 0 dst[0..2] is the original quad 1 dst[0..2] and dst[2..4] are the two new quads
Definition at line 279 of file SkGeometry.cpp.
SkCubicType SkClassifyCubic | ( | const SkPoint | p[4], |
double | t[2] = nullptr , |
||
double | s[2] = nullptr , |
||
double | d[4] = nullptr |
||
) |
Returns the cubic classification.
t[],s[] are set to the two homogeneous parameter values at which points the lines L & M intersect with K, sorted from smallest to largest and oriented so positive values of the implicit are on the "left" side. For a serpentine curve they are the inflection points. For a loop they are the double point. For a local cusp, they are both equal and denote the cusp point. For a cusp at an infinite parameter value, one will be the local inflection point and the other +inf (t,s = 1,0). If the curve is degenerate (i.e. quadratic or linear) they are both set to a parameter value of +inf (t,s = 1,0).
d[] is filled with the cubic inflection function coefficients. See "Resolution Independent Curve Rendering using Programmable Graphics Hardware", 4.2 Curve Categorization:
If the input points contain infinities or NaN, the return values are undefined.
https://www.microsoft.com/en-us/research/wp-content/uploads/2005/01/p1000-loop.pdf
Definition at line 809 of file SkGeometry.cpp.
Given 3 points on a quadratic bezier, use degree elevation to convert it into the cubic fitting the same curve. The new cubic curve is returned in dst[0..3].
Definition at line 378 of file SkGeometry.cpp.
void SkEvalCubicAt | ( | const SkPoint | src[4], |
SkScalar | t, | ||
SkPoint * | locOrNull, | ||
SkVector * | tangentOrNull, | ||
SkVector * | curvatureOrNull | ||
) |
Set pt to the point on the src cubic specified by t. t must be 0 <= t <= 1.0
Definition at line 418 of file SkGeometry.cpp.
Definition at line 144 of file SkGeometry.cpp.
Set pt to the point on the src quadratic specified by t. t must be 0 <= t <= 1.0
Definition at line 132 of file SkGeometry.cpp.
Definition at line 148 of file SkGeometry.cpp.
Returns a new, arbitrarily scaled vector that bisects the given vectors. The returned bisector will always point toward the interior of the provided vectors.
Definition at line 204 of file SkGeometry.cpp.
Returns t value of cusp if cubic has one; returns -1 otherwise.
Definition at line 1112 of file SkGeometry.cpp.
http://www.faculty.idc.ac.il/arik/quality/appendixA.html
Inflection means that curvature is zero. Curvature is [F' x F''] / [F'^3] So we solve F'x X F''y - F'y X F''y == 0 After some canceling of the cubic term, we get A = b - a B = c - 2b + a C = d - 3c + 3b - a (BxCy - ByCx)t^2 + (AxCy - AyCx)t + AxBy - AyBx == 0
Definition at line 741 of file SkGeometry.cpp.
Definition at line 1043 of file SkGeometry.cpp.
float SkFindCubicMidTangent | ( | const SkPoint | src[4] | ) |
Given a src cubic bezier, returns the T value whose tangent angle is halfway between the tangents at p0 and p3.
Definition at line 620 of file SkGeometry.cpp.
Given 3 points on a quadratic bezier, if the point of maximum curvature exists on the segment, returns the t value for this point along the curve. Otherwise it will return a value of 0.
Definition at line 344 of file SkGeometry.cpp.
float SkFindQuadMidTangent | ( | const SkPoint | src[3] | ) |
Given a src quadratic bezier, returns the T value whose tangent angle is halfway between the tangents at p0 and p3.
Definition at line 231 of file SkGeometry.cpp.
From Numerical Recipes in C.
Q = -1/2 (B + sign(B) sqrt[B*B - 4*A*C]) x1 = Q / A x2 = C / Q
Definition at line 95 of file SkGeometry.cpp.
Measures the angle between two vectors, in the range [0, pi].
Definition at line 197 of file SkGeometry.cpp.
float SkMeasureNonInflectCubicRotation | ( | const | SkPoint[4] | ) |
Given a cubic curve with no inflection points, this method measures the rotation in radians.
Rotation is perhaps easiest described via a driving analogy: If you drive your car along the curve from p0 to p3, then by the time you arrive at p3, how many radians will your car have rotated? This is not quite the same as the vector inside the tangents at the endpoints, even without inflection, because the curve might rotate around the outside of the tangents (>= 180 degrees) or the inside (<= 180 degrees).
Cubics can have rotations in the range [0, 2*pi].
NOTE: The caller must either call SkChopCubicAtInflections or otherwise prove that the provided cubic has no inflection points prior to calling this method.
Definition at line 579 of file SkGeometry.cpp.
Definition at line 950 of file SkGeometry.cpp.
Definition at line 961 of file SkGeometry.cpp.
|
static |
Definition at line 616 of file SkGeometry.cpp.
|
static |
Definition at line 602 of file SkGeometry.cpp.
Definition at line 1529 of file SkGeometry.cpp.
Definition at line 1397 of file SkGeometry.cpp.
|
inlinestatic |
Definition at line 468 of file SkGeometry.cpp.
|
inlinestatic |
Definition at line 791 of file SkGeometry.cpp.