Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
GrAAConvexTessellator.cpp File Reference
#include "src/gpu/ganesh/geometry/GrAAConvexTessellator.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkPath.h"
#include "include/core/SkPoint.h"
#include "include/core/SkRect.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkTPin.h"
#include "src/core/SkPathPriv.h"
#include "src/gpu/ganesh/geometry/GrPathUtils.h"
#include <algorithm>
#include "src/core/SkGeometry.h"

Go to the source code of this file.

Functions

static bool intersect (const SkPoint &p0, const SkPoint &n0, const SkPoint &p1, const SkPoint &n1, SkScalar *t)
 
static bool perp_intersect (const SkPoint &p0, const SkPoint &n0, const SkPoint &p1, const SkPoint &perp, SkScalar *t)
 
static bool duplicate_pt (const SkPoint &p0, const SkPoint &p1)
 
static bool points_are_colinear_and_b_is_middle (const SkPoint &a, const SkPoint &b, const SkPoint &c, float *accumError)
 
static SkScalar compute_coverage (SkScalar depth, SkScalar initialDepth, SkScalar initialCoverage, SkScalar targetDepth, SkScalar targetCoverage)
 

Variables

static constexpr SkScalar kClose = (SK_Scalar1 / 16)
 
static constexpr SkScalar kCloseSqd = kClose * kClose
 
static constexpr SkScalar kQuadTolerance = 0.2f
 
static constexpr SkScalar kCubicTolerance = 0.2f
 
static constexpr SkScalar kQuadToleranceSqd = kQuadTolerance * kQuadTolerance
 
static constexpr SkScalar kCubicToleranceSqd = kCubicTolerance * kCubicTolerance
 
static constexpr SkScalar kConicTolerance = 0.25f
 
static constexpr SkScalar kRoundCapThreshold = 0.8f
 
static constexpr SkScalar kCurveConnectionThreshold = 0.8f
 

Function Documentation

◆ compute_coverage()

static SkScalar compute_coverage ( SkScalar  depth,
SkScalar  initialDepth,
SkScalar  initialCoverage,
SkScalar  targetDepth,
SkScalar  targetCoverage 
)
static

Definition at line 683 of file GrAAConvexTessellator.cpp.

684 {
685 if (SkScalarNearlyEqual(initialDepth, targetDepth)) {
686 return targetCoverage;
687 }
688 SkScalar result = (depth - initialDepth) / (targetDepth - initialDepth) *
689 (targetCoverage - initialCoverage) + initialCoverage;
690 return SkTPin(result, 0.0f, 1.0f);
691}
static bool SkScalarNearlyEqual(SkScalar x, SkScalar y, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:107
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition SkTPin.h:19
float SkScalar
Definition extension.cpp:12
GAsyncResult * result

◆ duplicate_pt()

static bool duplicate_pt ( const SkPoint p0,
const SkPoint p1 
)
static

Definition at line 70 of file GrAAConvexTessellator.cpp.

70 {
71 SkScalar distSq = SkPointPriv::DistanceToSqd(p0, p1);
72 return distSq < kCloseSqd;
73}
static constexpr SkScalar kCloseSqd
static SkScalar DistanceToSqd(const SkPoint &pt, const SkPoint &a)
Definition SkPointPriv.h:48

◆ intersect()

static bool intersect ( const SkPoint p0,
const SkPoint n0,
const SkPoint p1,
const SkPoint n1,
SkScalar t 
)
static

Definition at line 44 of file GrAAConvexTessellator.cpp.

46 {
47 const SkPoint v = p1 - p0;
48 SkScalar perpDot = n0.fX * n1.fY - n0.fY * n1.fX;
49 if (SkScalarNearlyZero(perpDot)) {
50 return false;
51 }
52 *t = (v.fX * n1.fY - v.fY * n1.fX) / perpDot;
53 return SkIsFinite(*t);
54}
static bool SkIsFinite(T x, Pack... values)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
Definition SkScalar.h:101
float fX
x-axis value
float fY
y-axis value

◆ perp_intersect()

static bool perp_intersect ( const SkPoint p0,
const SkPoint n0,
const SkPoint p1,
const SkPoint perp,
SkScalar t 
)
static

Definition at line 58 of file GrAAConvexTessellator.cpp.

60 {
61 const SkPoint v = p1 - p0;
62 SkScalar perpDot = n0.dot(perp);
63 if (SkScalarNearlyZero(perpDot)) {
64 return false;
65 }
66 *t = v.dot(perp) / perpDot;
67 return SkIsFinite(*t);
68}
float dot(const SkVector &vec) const

◆ points_are_colinear_and_b_is_middle()

static bool points_are_colinear_and_b_is_middle ( const SkPoint a,
const SkPoint b,
const SkPoint c,
float *  accumError 
)
static

Definition at line 75 of file GrAAConvexTessellator.cpp.

76 {
77 // First check distance from b to the infinite line through a, c
78 SkVector aToC = c - a;
79 SkVector n = {aToC.fY, -aToC.fX};
80 n.normalize();
81
82 SkScalar distBToLineAC = SkScalarAbs(n.dot(b) - n.dot(a));
83 if (*accumError + distBToLineAC >= kClose || aToC.dot(b - a) <= 0.f || aToC.dot(c - b) <= 0.f) {
84 // Too far from the line or not between the line segment from a to c
85 return false;
86 } else {
87 // Accumulate the distance from b to |ac| that goes "away" when this near-colinear point
88 // is removed to simplify the path.
89 *accumError += distBToLineAC;
90 return true;
91 }
92}
static constexpr SkScalar kClose
#define SkScalarAbs(x)
Definition SkScalar.h:39
static bool b
struct MyStruct a[10]
bool normalize()
Definition SkPoint.cpp:22

Variable Documentation

◆ kClose

constexpr SkScalar kClose = (SK_Scalar1 / 16)
staticconstexpr

Definition at line 28 of file GrAAConvexTessellator.cpp.

◆ kCloseSqd

constexpr SkScalar kCloseSqd = kClose * kClose
staticconstexpr

Definition at line 29 of file GrAAConvexTessellator.cpp.

◆ kConicTolerance

constexpr SkScalar kConicTolerance = 0.25f
staticconstexpr

Definition at line 36 of file GrAAConvexTessellator.cpp.

◆ kCubicTolerance

constexpr SkScalar kCubicTolerance = 0.2f
staticconstexpr

Definition at line 33 of file GrAAConvexTessellator.cpp.

◆ kCubicToleranceSqd

constexpr SkScalar kCubicToleranceSqd = kCubicTolerance * kCubicTolerance
staticconstexpr

Definition at line 35 of file GrAAConvexTessellator.cpp.

◆ kCurveConnectionThreshold

constexpr SkScalar kCurveConnectionThreshold = 0.8f
staticconstexpr

Definition at line 42 of file GrAAConvexTessellator.cpp.

◆ kQuadTolerance

constexpr SkScalar kQuadTolerance = 0.2f
staticconstexpr

Definition at line 32 of file GrAAConvexTessellator.cpp.

◆ kQuadToleranceSqd

constexpr SkScalar kQuadToleranceSqd = kQuadTolerance * kQuadTolerance
staticconstexpr

Definition at line 34 of file GrAAConvexTessellator.cpp.

◆ kRoundCapThreshold

constexpr SkScalar kRoundCapThreshold = 0.8f
staticconstexpr

Definition at line 39 of file GrAAConvexTessellator.cpp.