Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkAnalyticEdge.h
Go to the documentation of this file.
1/*
2 * Copyright 2006 The Android Open Source Project
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef SkAnalyticEdge_DEFINED
9#define SkAnalyticEdge_DEFINED
10
15#include "src/core/SkEdge.h"
16
17#include <cstdint>
18
19struct SkPoint;
20
22 // Similar to SkEdge, the conic edges will be converted to quadratic edges
28
31
32 // During aaa_walk_edges, if this edge is a left edge,
33 // then fRiteE is its corresponding right edge. Otherwise it's nullptr.
35
38 SkFixed fUpperX; // The x value when y = fUpperY
39 SkFixed fY; // The current y
40 SkFixed fUpperY; // The upper bound of y (our edge is from y = fUpperY to y = fLowerY)
41 SkFixed fLowerY; // The lower bound of y (our edge is from y = fUpperY to y = fLowerY)
42 SkFixed fDY; // abs(1/fDX); may be SK_MaxS32 when fDX is close to 0.
43 // fDY is only used for blitting trapezoids.
44
45 SkFixed fSavedX; // For deferred blitting
46 SkFixed fSavedY; // For deferred blitting
47 SkFixed fSavedDY; // For deferred blitting
48
49 Type fEdgeType; // Remembers the *initial* edge type
50
51 int8_t fCurveCount; // only used by kQuad(+) and kCubic(-)
52 uint8_t fCurveShift; // appled to all Dx/DDx/DDDx except for fCubicDShift exception
53 uint8_t fCubicDShift; // applied to fCDx and fCDy only in cubic
54 int8_t fWinding; // 1 or -1
55
56 static const int kDefaultAccuracy = 2; // default accuracy for snapping
57
58 static inline SkFixed SnapY(SkFixed y) {
59 const int accuracy = kDefaultAccuracy;
60 // This approach is safer than left shift, round, then right shift
61 return ((unsigned)y + (SK_Fixed1 >> (accuracy + 1))) >> (16 - accuracy) << (16 - accuracy);
62 }
63
64 // Update fX, fY of this edge so fY = y
65 inline void goY(SkFixed y) {
66 if (y == fY + SK_Fixed1) {
67 fX = fX + fDX;
68 fY = y;
69 } else if (y != fY) {
70 // Drop lower digits as our alpha only has 8 bits
71 // (fDX and y - fUpperY may be greater than SK_Fixed1)
73 fY = y;
74 }
75 }
76
77 inline void goY(SkFixed y, int yShift) {
78 SkASSERT(yShift >= 0 && yShift <= kDefaultAccuracy);
79 SkASSERT(fDX == 0 || y - fY == SK_Fixed1 >> yShift);
80 fY = y;
81 fX += fDX >> yShift;
82 }
83
84 inline void saveXY(SkFixed x, SkFixed y, SkFixed dY) {
85 fSavedX = x;
86 fSavedY = y;
87 fSavedDY = dY;
88 }
89
90 bool setLine(const SkPoint& p0, const SkPoint& p1);
91 bool updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by, SkFixed slope);
92
93 // return true if we're NOT done with this edge
94 bool update(SkFixed last_y, bool sortY = true);
95
96#ifdef SK_DEBUG
97 void dump() const {
98 SkDebugf("edge: upperY:%d lowerY:%d y:%g x:%g dx:%g w:%d\n",
101 }
102
103 void validate() const {
104 SkASSERT(fPrev && fNext);
105 SkASSERT(fPrev->fNext == this);
106 SkASSERT(fNext->fPrev == this);
107
110 }
111#endif
112};
113
116
117 // snap y to integer points in the middle of the curve to accelerate AAA path filling
119
120 bool setQuadratic(const SkPoint pts[3]);
121 bool updateQuadratic();
122 inline void keepContinuous() {
123 // We use fX as the starting x to ensure the continuouty.
124 // Without it, we may break the sorted edge list.
126 SkASSERT(SkAbs32(fY - fSnappedY) < SK_Fixed1); // This may differ due to smooth jump
127 fSnappedX = fX;
128 fSnappedY = fY;
129 }
130};
131
134
135 SkFixed fSnappedY; // to make sure that y is increasing with smooth jump and snapping
136
137 bool setCubic(const SkPoint pts[4], bool sortY = true);
138 bool updateCubic(bool sortY = true);
139 inline void keepContinuous() {
141 fCEdge.fCx = fX;
142 fSnappedY = fY;
143 }
144};
145
146#endif
#define SkASSERT(cond)
Definition SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
int32_t SkFixed
Definition SkFixed.h:25
#define SK_Fixed1
Definition SkFixed.h:26
#define SkFixedToFloat(x)
Definition SkFixed.h:41
static SkFixed SkFixedMul(SkFixed a, SkFixed b)
Definition SkFixed.h:96
static int32_t SkAbs32(int32_t value)
Definition SkSafe32.h:41
static void dump(const float m[20], SkYUVColorSpace cs, bool rgb2yuv)
double y
double x
bool updateCubic(bool sortY=true)
bool setCubic(const SkPoint pts[4], bool sortY=true)
void goY(SkFixed y, int yShift)
static const int kDefaultAccuracy
void goY(SkFixed y)
bool updateLine(SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by, SkFixed slope)
SkAnalyticEdge * fRiteE
SkAnalyticEdge * fNext
SkAnalyticEdge * fPrev
void saveXY(SkFixed x, SkFixed y, SkFixed dY)
bool setLine(const SkPoint &p0, const SkPoint &p1)
static SkFixed SnapY(SkFixed y)
bool setQuadratic(const SkPoint pts[3])
SkFixed fCx
Definition SkEdge.h:82
SkFixed fCy
Definition SkEdge.h:82