66 shape.
addPoly(corners, 4,
true);
90 bool needsNonAA =
false;
92 for (
int i = 0;
i < 4; ++
i) {
97 if (edgeD[
i] < -1e-4f) {
105 for (
int i = 0;
i < 4;
i++) {
106 if (edgeAA[
i] && edgeD[
i] < 0.5f) {
112 return needsNonAA ? 1.f : area;
123 for (
int i = 0;
i < 4; ++
i) {
124 for (
int j = 0; j < 4; ++j) {
139 for (
int i = 0;
i < 4; ++
i) {
142 if (!edgeAA[
i] &&
d >= -1e-4f) {
145 if (
d < minCoverage) {
147 if (minCoverage < 0.f) {
152 return minCoverage < 0.f ? 0.f : minCoverage;
166 if (d0 < -1e-4f || d1 < -1e-4f || d2 < -1e-4f) {
185 SkScalar sum = bary[0] + bary[1] + bary[2];
197 static const int kFrameTris[] = {
204 static const int kNumTris = 10;
207 for (
int i = 0;
i < kNumTris; ++
i) {
208 int i0 = kFrameTris[
i * 3];
209 int i1 = kFrameTris[
i * 3 + 1];
210 int i2 = kFrameTris[
i * 3 + 2];
212 SkPoint t0 = i0 >= 4 ? inner[i0 - 4] : outer[i0];
213 SkPoint t1 = i1 >= 4 ? inner[i1 - 4] : outer[i1];
214 SkPoint t2 = i2 >= 4 ? inner[i2 - 4] : outer[i2];
217 SkScalar c0 = i0 >= 4 ? innerCoverages[i0 - 4] : outerCoverages[i0];
218 SkScalar c1 = i1 >= 4 ? innerCoverages[i1 - 4] : outerCoverages[i1];
219 SkScalar c2 = i2 >= 4 ? innerCoverages[i2 - 4] : outerCoverages[i2];
244 , fCoverageMode(CoverageMode::kArea) {
245 fOuterRect.
toQuad(fCorners);
246 for (
int i = 0;
i < 4; ++
i) {
249 fName =
"DegenerateQuad";
273 canvas->
drawRect(fOuterRect, linePaint);
275 bool valid = this->isValid();
281 for (
int i = 0;
i < 4; ++
i) {
282 make_aa_line(fCorners[
i], fCorners[(
i + 1) % 4], fEdgeAA[
i],
true, outsets +
i * 2);
283 make_aa_line(fCorners[
i], fCorners[(
i + 1) % 4], fEdgeAA[
i],
false, insets +
i * 2);
292 this->getTessellatedPoints(gpuInset, gpuInsetCoverage, gpuOutset, gpuOutsetCoverage,
304 SkPoint pixelCenter = {px + 0.5f, py + 0.5f};
306 if (fCoverageMode == CoverageMode::kArea) {
308 }
else if (fCoverageMode == CoverageMode::kEdgeDistance) {
312 SkASSERT(fCoverageMode == CoverageMode::kGPUMesh);
314 gpuInset, gpuInsetCoverage, gpuDomain,
319 pixelRect.
inset(0.1f, 0.1f);
323 canvas->
drawRect(pixelRect, pixelPaint);
326 pixelRect.
inset(0.38f, 0.38f);
327 canvas->
drawRect(pixelRect, pixelPaint);
333 if (fCoverageMode == CoverageMode::kEdgeDistance) {
334 for (
int i = 0;
i < 4; ++
i) {
350 if (fCoverageMode == CoverageMode::kGPUMesh) {
352 outsetPath.
addPoly(gpuOutset, 4,
true);
354 canvas->
drawPath(outsetPath, linePaint);
357 insetPath.
addPoly(gpuInset, 4,
true);
359 canvas->
drawPath(insetPath, linePaint);
361 SkPaint domainPaint = linePaint;
365 canvas->
drawRect(gpuDomain, domainPaint);
370 path.addPoly(fCorners, 4,
true);
376 path.addPoly(fCorners, 4,
true);
384 for (
int i = 0;
i < 4; ++
i) {
400 kArea, kEdgeDistance, kGPUMesh
408 bool isValid()
const {
410 path.addPoly(fCorners, 4,
true);
411 return path.isConvex();
433 tessellator.append(&quad,
nullptr, {1.f, 1.f, 1.f, 1.f},
438 inset[0] = {vertices[0], vertices[1]};
439 insetCoverage[0] = vertices[2];
440 inset[3] = {vertices[7], vertices[8]};
441 insetCoverage[3] = vertices[9];
442 inset[1] = {vertices[14], vertices[15]};
443 insetCoverage[1] = vertices[16];
444 inset[2] = {vertices[21], vertices[22]};
445 insetCoverage[2] = vertices[23];
447 outset[0] = {vertices[28], vertices[29]};
448 outsetCoverage[0] = vertices[30];
449 outset[3] = {vertices[35], vertices[36]};
450 outsetCoverage[3] = vertices[37];
451 outset[1] = {vertices[42], vertices[43]};
452 outsetCoverage[1] = vertices[44];
453 outset[2] = {vertices[49], vertices[50]};
454 outsetCoverage[2] = vertices[51];
456 *domain = {vertices[52], vertices[53], vertices[54], vertices[55]};
468 this->drag(&
points[fIndex]);
470 for (
int i = 0;
i < 4; ++
i) {
491 for (
int i = 0;
i < 4; ++
i) {
493 return new Click(fOuterRect,
i);
496 return new Click(fOuterRect, -1);
508 fEdgeAA[0] = !fEdgeAA[0];
511 fEdgeAA[1] = !fEdgeAA[1];
514 fEdgeAA[2] = !fEdgeAA[2];
517 fEdgeAA[3] = !fEdgeAA[3];
520 fCoverageMode = CoverageMode::kArea;
523 fCoverageMode = CoverageMode::kEdgeDistance;
526 fCoverageMode = CoverageMode::kGPUMesh;
static constexpr SkScalar kViewScale
static SkScalar get_area_coverage(const bool edgeAA[4], const SkPoint corners[4], const SkPoint &point)
static SkScalar get_edge_dist_coverage(const bool edgeAA[4], const SkPoint corners[4], const SkPoint outsetLines[8], const SkPoint insetLines[8], const SkPoint &point)
static void make_aa_line(const SkPoint &p0, const SkPoint &p1, bool aaOn, bool outset, SkPoint line[2])
static void draw_extended_line(SkCanvas *canvas, const SkPaint &paint, const SkPoint &p0, const SkPoint &p1)
static bool inside_triangle(const SkPoint &point, const SkPoint &t0, const SkPoint &t1, const SkPoint &t2, SkScalar bary[3])
static constexpr SkScalar kViewOffset
static SkScalar get_framed_coverage(const SkPoint outer[4], const SkScalar outerCoverages[4], const SkPoint inner[4], const SkScalar innerCoverages[4], const SkRect &geomDomain, const SkPoint &point)
skgpu::ganesh::QuadPerEdgeAA::VertexSpec VertexSpec
static SkScalar signed_distance(const SkPoint &p, const SkPoint &l0, const SkPoint &l1)
static const int points[]
static unsigned clamp(SkFixed fx, int max)
constexpr SkColor SK_ColorMAGENTA
constexpr SkColor SK_ColorCYAN
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorBLACK
constexpr SkColor SK_ColorGREEN
@ kIntersect_SkPathOp
intersect the two paths
static bool SkScalarNearlyZero(SkScalar x, SkScalar tolerance=SK_ScalarNearlyZero)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
void doClick(SkPoint points[4])
Click(const SkRect &clamp, int index)
bool onChar(SkUnichar) override
void draw(SkCanvas *canvas) override
DegenerateQuadSlide(const SkRect &rect)
Click * onFindClickHandler(SkScalar x, SkScalar y, skui::ModifierKey) override
bool onClick(Click *) override
static GrQuad MakeFromSkQuad(const SkPoint pts[4], const SkMatrix &)
void drawRect(const SkRect &rect, const SkPaint &paint)
void translate(SkScalar dx, SkScalar dy)
void drawLine(SkScalar x0, SkScalar y0, SkScalar x1, SkScalar y1, const SkPaint &paint)
void drawPath(const SkPath &path, const SkPaint &paint)
void scale(SkScalar sx, SkScalar sy)
void drawCircle(SkScalar cx, SkScalar cy, SkScalar radius, const SkPaint &paint)
static sk_sp< SkPathEffect > Make(const SkScalar intervals[], int count, SkScalar phase)
static const SkMatrix & I()
void setStyle(Style style)
void setColor(SkColor color)
void setAntiAlias(bool aa)
void setStrokeCap(Cap cap)
@ kStroke_Style
set to stroke geometry
void setStrokeJoin(Join join)
void setColor4f(const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
void setStrokeWidth(SkScalar width)
SkPoint getPoint(int index) const
SkPath & addPoly(const SkPoint pts[], int count, bool close)
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
FlutterSemanticsFlag flags
static float max(float r, float g, float b)
static float min(float r, float g, float b)
sk_sp< SkBlender > blender SkRect rect
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
static SkRect inset(const SkRect &r)
bool setLength(float length)
float dot(const SkVector &vec) const
static constexpr SkPoint Make(float x, float y)
static constexpr SkRect MakeEmpty()
SkScalar fBottom
larger y-axis bounds
void toQuad(SkPoint quad[4]) const
void inset(float dx, float dy)
SkScalar fLeft
smaller x-axis bounds
SkRect makeOutset(float dx, float dy) const
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
SkScalar fRight
larger x-axis bounds
static constexpr SkRect MakeWH(float w, float h)
SkScalar fTop
smaller y-axis bounds