39#if !defined(SK_ENABLE_OPTIMIZE_SIZE)
100 void appendTriangle(uint16_t index0, uint16_t index1, uint16_t index2);
101 void appendQuad(uint16_t index0, uint16_t index1, uint16_t index2, uint16_t index3);
149 normal.fX = p0.
fY - p1.
fY;
150 normal.fY = p1.
fX - p0.
fX;
152 if (!normal.normalize()) {
175 : fZPlaneParams(zPlaneParams)
181 , fFirstVertexIndex(-1)
183 , fTransparent(transparent)
187 , fPrevUmbraIndex(-1)
190 , fPrevUmbraOutside(
false)
191 , fFirstUmbraOutside(
false) {
284 if (distSq < minDistSq) {
295 auto ratio = 128 * (newInset /
inset + 1);
353 for (
int i = 1;
i < polyCount; ++
i) {
361 i == polyCount - 1, doClip);
397 bool hiddenCentroid =
true;
407 if (initCross*v0.
cross(v1) <= 0) {
408 hiddenCentroid =
false;
418 bool lastEdge,
bool doClip) {
427 duplicate = this->
addInnerPoint(nextPoint, umbraColor, umbraPolygon, &currUmbraIndex);
463 SkPoint newPoint = nextPoint + nextNormal;
478 SkVector segmentVector = centroid - umbraPoint;
493 }
else if (t_num >= 0 && t_num <= denom) {
496 if (s_num >= 0 && s_num <= denom) {
497 segmentVector *= s_num / denom;
498 *clipPoint = umbraPoint + segmentVector;
510 int* currUmbraIndex) {
515 umbraPoint = pathPoint + v;
583 &umbraPolygon, &umbraIndices)) {
594 &penumbraPolygon, &penumbraIndices)) {
599 if (umbraPolygon.
empty() || penumbraPolygon.
empty()) {
604 this->
stitchConcaveRings(umbraPolygon, &umbraIndices, penumbraPolygon, &penumbraIndices);
618 int min = (*penumbraIndices)[0];
619 for (
int i = 1;
i < (*penumbraIndices).size(); ++
i) {
620 if ((*penumbraIndices)[
i] <
min) {
621 min = (*penumbraIndices)[
i];
625 int currPenumbra = minIndex;
628 min = (*umbraIndices)[0];
629 for (
int i = 1;
i < (*umbraIndices).size(); ++
i) {
630 if ((*umbraIndices)[
i] <
min) {
631 min = (*umbraIndices)[
i];
635 int currUmbra = minIndex;
640 while ((*penumbraIndices)[currPenumbra] != (*umbraIndices)[currUmbra]) {
641 if ((*penumbraIndices)[currPenumbra] < (*umbraIndices)[currUmbra]) {
643 maxPenumbraIndex = (*penumbraIndices)[currPenumbra];
644 currPenumbra = (currPenumbra + 1) % penumbraPolygon.
size();
647 maxUmbraIndex = (*umbraIndices)[currUmbra];
648 currUmbra = (currUmbra + 1) % umbraPolygon.
size();
654 int prevPenumbraIndex = 0;
658 indexMap[currUmbra] = 1;
660 int nextPenumbra = (currPenumbra + 1) % penumbraPolygon.
size();
661 int nextUmbra = (currUmbra + 1) % umbraPolygon.
size();
662 while ((*penumbraIndices)[nextPenumbra] <= maxPenumbraIndex ||
663 (*umbraIndices)[nextUmbra] <= maxUmbraIndex) {
665 if ((*umbraIndices)[nextUmbra] == (*penumbraIndices)[nextPenumbra]) {
674 indexMap[nextUmbra] = currUmbraIndex;
676 this->
appendQuad(prevPenumbraIndex, currPenumbraIndex,
679 prevPenumbraIndex = currPenumbraIndex;
681 currPenumbra = nextPenumbra;
682 nextPenumbra = (currPenumbra + 1) % penumbraPolygon.
size();
686 currUmbra = nextUmbra;
687 nextUmbra = (currUmbra + 1) % umbraPolygon.
size();
690 while ((*penumbraIndices)[nextPenumbra] < (*umbraIndices)[nextUmbra] &&
691 (*penumbraIndices)[nextPenumbra] <= maxPenumbraIndex) {
699 prevPenumbraIndex = currPenumbraIndex;
702 currPenumbra = nextPenumbra;
703 nextPenumbra = (currPenumbra + 1) % penumbraPolygon.
size();
706 while ((*umbraIndices)[nextUmbra] < (*penumbraIndices)[nextPenumbra] &&
707 (*umbraIndices)[nextUmbra] <= maxUmbraIndex) {
712 indexMap[nextUmbra] = currUmbraIndex;
719 currUmbra = nextUmbra;
720 nextUmbra = (currUmbra + 1) % umbraPolygon.
size();
731 indexMap[nextUmbra] = currUmbraIndex;
733 this->
appendQuad(prevPenumbraIndex, currPenumbraIndex,
744#if defined(SK_GANESH)
792#if defined(SK_GANESH)
823#if defined(SK_GANESH)
843 if (
m.hasPerspective()) {
849 SkPoint lastPoint = *(quads++);
853 quadPts[0] = lastPoint;
854 quadPts[1] = quads[0];
855 quadPts[2] =
i ==
count - 1 ? pts[2] : quads[1];
857 lastPoint = quadPts[2];
871 for (
int i = 0;
i < numSteps-1; ++
i) {
873 currNormal.
fX = prevNormal.
fX*rotCos - prevNormal.
fY*rotSin;
874 currNormal.
fY = prevNormal.
fY*rotCos + prevNormal.
fX*rotSin;
879 prevNormal = currNormal;
881 if (finishArc && numSteps) {
888 return (numSteps > 0);
900 uint16_t index2, uint16_t index3) {
917 const SkPoint3& zPlaneParams,
bool transparent);
936 if (!this->computePathPolygon(
path, ctm)) {
960bool SkAmbientShadowTessellator::computePathPolygon(
const SkPath&
path,
const SkMatrix& ctm) {
968 bool verbSeen =
false;
969 bool closeSeen =
false;
1010 SkScalar lightRadius,
bool transparent,
bool directional);
1015 void addToClip(
const SkVector& nextPoint);
1023 bool transparent,
bool directional)
1030 path.getBounds(), directional,
1031 &shadowTransform, &
outset)) {
1037 if (!this->computeClipAndPathPolygons(
path, ctm, shadowTransform)) {
1069bool SkSpotShadowTessellator::computeClipAndPathPolygons(
const SkPath&
path,
const SkMatrix& ctm,
1084 static constexpr SkScalar kA = 0.32495117187f;
1085 static constexpr SkScalar kB = 0.44311523437f;
1086 static constexpr SkScalar kC = 0.20141601562f;
1087 static constexpr SkScalar kD = 0.03051757812f;
1091 bool closeSeen =
false;
1092 bool verbSeen =
false;
1100 this->addToClip(clipPts[0]);
1106 curvePoint.
fX = 0.25f*clipPts[0].
fX + 0.5f*clipPts[1].
fX + 0.25f*clipPts[2].
fX;
1107 curvePoint.
fY = 0.25f*clipPts[0].
fY + 0.5f*clipPts[1].
fY + 0.25f*clipPts[2].
fY;
1108 this->addToClip(curvePoint);
1109 this->addToClip(clipPts[2]);
1114 w = iter.conicWeight();
1116 curvePoint.
fX = 0.25f*clipPts[0].
fX +
w*0.5f*clipPts[1].
fX + 0.25f*clipPts[2].
fX;
1117 curvePoint.
fY = 0.25f*clipPts[0].
fY +
w*0.5f*clipPts[1].
fY + 0.25f*clipPts[2].
fY;
1119 this->addToClip(curvePoint);
1120 this->addToClip(clipPts[2]);
1126 curvePoint.
fX =
kA*clipPts[0].
fX +
kB*clipPts[1].
fX
1127 +
kC*clipPts[2].
fX +
kD*clipPts[3].
fX;
1128 curvePoint.
fY =
kA*clipPts[0].
fY +
kB*clipPts[1].
fY
1129 +
kC*clipPts[2].
fY +
kD*clipPts[3].
fY;
1130 this->addToClip(curvePoint);
1132 curvePoint.
fX =
kD*clipPts[0].
fX +
kC*clipPts[1].
fX
1133 +
kB*clipPts[2].
fX +
kA*clipPts[3].
fX;
1134 curvePoint.
fY =
kD*clipPts[0].
fY +
kC*clipPts[1].
fY
1135 +
kB*clipPts[2].
fY +
kA*clipPts[3].
fY;
1136 this->addToClip(curvePoint);
1137 this->addToClip(clipPts[3]);
1159void SkSpotShadowTessellator::addToClip(
const SkPoint& point) {
1168 const SkPoint3& zPlane,
bool transparent) {
1178 SkScalar lightRadius,
bool transparent,
static constexpr SkScalar kQuadTolerance
static constexpr SkScalar kQuadToleranceSqd
static constexpr SkScalar kCubicToleranceSqd
static constexpr SkScalar kCubicTolerance
static constexpr SkScalar kCloseSqd
static constexpr float kTolerance
static float next(float f)
#define SkDEBUGFAIL(message)
static SkPMColor SkPMLerp(SkPMColor src, SkPMColor dst, unsigned scale)
constexpr SkColor SK_ColorTRANSPARENT
constexpr SkColor SK_ColorBLACK
static bool SkIsFinite(T x, Pack... values)
static constexpr float sk_ieee_float_divide(float numer, float denom)
@ kClose
SkPath::RawIter returns 0 points.
bool SkComputeRadialSteps(const SkVector &v1, const SkVector &v2, SkScalar offset, SkScalar *rotSin, SkScalar *rotCos, int *n)
bool SkTriangulateSimplePolygon(const SkPoint *polygonVerts, uint16_t *indexMap, int polygonSize, SkTDArray< uint16_t > *triangleIndices)
bool SkOffsetSimplePolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, const SkRect &bounds, SkScalar offset, SkTDArray< SkPoint > *offsetPolygon, SkTDArray< int > *polygonIndices)
bool SkIsSimplePolygon(const SkPoint *polygon, int polygonSize)
bool SkInsetConvexPolygon(const SkPoint *inputPolygonVerts, int inputPolygonSize, SkScalar inset, SkTDArray< SkPoint > *insetPolygon)
#define SkScalarInvert(x)
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
#define SK_ScalarNearlyZero
#define SkScalarRoundToScalar(x)
static bool duplicate_pt(const SkPoint &p0, const SkPoint &p1)
static SkScalar perp_dot(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2)
static constexpr SkScalar kConicTolerance
static bool compute_normal(const SkPoint &p0, const SkPoint &p1, SkScalar dir, SkVector *newNormal)
static void sanitize_point(const SkPoint &in, SkPoint *out)
SkAmbientShadowTessellator(const SkPath &path, const SkMatrix &ctm, const SkPoint3 &zPlaneParams, bool transparent)
const SkPoint * computeQuads(const SkConic &conic, SkScalar tol)
void appendQuad(uint16_t index0, uint16_t index1, uint16_t index2, uint16_t index3)
bool accumulateCentroid(const SkPoint &c, const SkPoint &n)
void stitchConcaveRings(const SkTDArray< SkPoint > &umbraPolygon, SkTDArray< int > *umbraIndices, const SkTDArray< SkPoint > &penumbraPolygon, SkTDArray< int > *penumbraIndices)
static constexpr auto kMinHeight
void handleLine(const SkPoint &p)
SkScalar heightFunc(SkScalar x, SkScalar y)
static constexpr auto kUmbraColor
virtual ~SkBaseShadowTessellator()
SkTDArray< SkPoint > fPointBuffer
static constexpr auto kPenumbraColor
SkTDArray< SkPoint > fClipPolygon
SkTDArray< SkVector > fClipVectors
bool clipUmbraPoint(const SkPoint &umbraPoint, const SkPoint ¢roid, SkPoint *clipPoint)
void handleCubic(const SkMatrix &m, SkPoint pts[4])
bool computeConcaveShadow(SkScalar inset, SkScalar outset)
sk_sp< SkVertices > releaseVertices()
bool computeConvexShadow(SkScalar inset, SkScalar outset, bool doClip)
void handleConic(const SkMatrix &m, SkPoint pts[3], SkScalar w)
void addEdge(const SkVector &nextPoint, const SkVector &nextNormal, SkColor umbraColor, const SkTDArray< SkPoint > &umbraPolygon, bool lastEdge, bool doClip)
SkTDArray< SkPoint > fPositions
bool addInnerPoint(const SkPoint &pathPoint, SkColor umbraColor, const SkTDArray< SkPoint > &umbraPolygon, int *currUmbraIndex)
void appendTriangle(uint16_t index0, uint16_t index1, uint16_t index2)
SkTDArray< uint16_t > fIndices
SkTDArray< SkColor > fColors
void handleQuad(const SkPoint pts[3])
int getClosestUmbraIndex(const SkPoint &point, const SkTDArray< SkPoint > &umbraPolygon)
bool checkConvexity(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2)
void computeClipVectorsAndTestCentroid()
bool addArc(const SkVector &nextNormal, SkScalar offset, bool finishArc)
SkTDArray< SkPoint > fPathPolygon
SkBaseShadowTessellator(const SkPoint3 &zPlaneParams, const SkRect &bounds, bool transparent)
void mapPoints(SkPoint dst[], const SkPoint src[], int count) const
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
static SkScalar DistanceToLineSegmentBetweenSqd(const SkPoint &pt, const SkPoint &a, const SkPoint &b)
static SkScalar DistanceToSqd(const SkPoint &pt, const SkPoint &a)
static constexpr float HalfWidth(const SkRect &r)
static constexpr float HalfHeight(const SkRect &r)
SkSpotShadowTessellator(const SkPath &path, const SkMatrix &ctm, const SkPoint3 &zPlaneParams, const SkPoint3 &lightPos, SkScalar lightRadius, bool transparent, bool directional)
void push_back(const T &v)
static sk_sp< SkVertices > MakeCopy(VertexMode mode, int vertexCount, const SkPoint positions[], const SkPoint texs[], const SkColor colors[], int indexCount, const uint16_t indices[])
static float min(float r, float g, float b)
uint32_t generateCubicPoints(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, const SkPoint &p3, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
uint32_t quadraticPointCount(const SkPoint points[], SkScalar tol)
uint32_t cubicPointCount(const SkPoint points[], SkScalar tol)
uint32_t generateQuadraticPoints(const SkPoint &p0, const SkPoint &p1, const SkPoint &p2, SkScalar tolSqd, SkPoint **points, uint32_t pointsLeft)
bool GetSpotShadowTransform(const SkPoint3 &lightPos, SkScalar lightRadius, const SkMatrix &ctm, const SkPoint3 &zPlaneParams, const SkRect &pathBounds, bool directional, SkMatrix *shadowTransform, SkScalar *radius)
SkScalar AmbientRecipAlpha(SkScalar height)
SkScalar AmbientBlurRadius(SkScalar height)
Optional< SkRect > bounds
sk_sp< SkVertices > MakeAmbient(const SkPath &path, const SkMatrix &ctm, const SkPoint3 &zPlane, bool transparent)
sk_sp< SkVertices > MakeSpot(const SkPath &path, const SkMatrix &ctm, const SkPoint3 &zPlane, const SkPoint3 &lightPos, SkScalar lightRadius, bool transparent, bool directional)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace Enable an endless trace buffer The default is a ring buffer This is useful when very old events need to viewed For during application launch Memory usage will continue to grow indefinitely however Start app with an specific route defined on the framework flutter assets dir
int64_t cross(Point d0, Point d1)
static SkRect inset(const SkRect &r)
static SkScalar TransformW(const SkPoint[3], SkScalar w, const SkMatrix &)
float cross(const SkVector &vec) const
constexpr float centerX() const
constexpr float centerY() const