Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Public Attributes | List of all members
SkEdge Struct Reference

#include <SkEdge.h>

Inheritance diagram for SkEdge:
SkCubicEdge SkQuadraticEdge

Public Types

enum  Type { kLine_Type , kQuad_Type , kCubic_Type }
 

Public Member Functions

int setLine (const SkPoint &p0, const SkPoint &p1, const SkIRect *clip, int shiftUp)
 
int setLine (const SkPoint &p0, const SkPoint &p1, int shiftUp)
 
int updateLine (SkFixed ax, SkFixed ay, SkFixed bx, SkFixed by)
 
void chopLineWithClip (const SkIRect &clip)
 
bool intersectsClip (const SkIRect &clip) const
 

Public Attributes

SkEdgefNext
 
SkEdgefPrev
 
SkFixed fX
 
SkFixed fDX
 
int32_t fFirstY
 
int32_t fLastY
 
Type fEdgeType
 
int8_t fCurveCount
 
uint8_t fCurveShift
 
uint8_t fCubicDShift
 
int8_t fWinding
 

Detailed Description

Definition at line 27 of file SkEdge.h.

Member Enumeration Documentation

◆ Type

Enumerator
kLine_Type 
kQuad_Type 
kCubic_Type 

Definition at line 28 of file SkEdge.h.

28 {
32 };
@ kCubic_Type
Definition: SkEdge.h:31
@ kLine_Type
Definition: SkEdge.h:29
@ kQuad_Type
Definition: SkEdge.h:30

Member Function Documentation

◆ chopLineWithClip()

void SkEdge::chopLineWithClip ( const SkIRect clip)

Definition at line 149 of file SkEdge.cpp.

150{
151 int top = fFirstY;
152
153 SkASSERT(top < clip.fBottom);
154
155 // clip the line to the top
156 if (top < clip.fTop)
157 {
158 SkASSERT(fLastY >= clip.fTop);
159 fX += fDX * (clip.fTop - top);
160 fFirstY = clip.fTop;
161 }
162}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
int32_t fLastY
Definition: SkEdge.h:40
SkFixed fX
Definition: SkEdge.h:37
SkFixed fDX
Definition: SkEdge.h:38
int32_t fFirstY
Definition: SkEdge.h:39

◆ intersectsClip()

bool SkEdge::intersectsClip ( const SkIRect clip) const
inline

Definition at line 53 of file SkEdge.h.

53 {
54 SkASSERT(fFirstY < clip.fBottom);
55 return fLastY >= clip.fTop;
56 }

◆ setLine() [1/2]

int SkEdge::setLine ( const SkPoint p0,
const SkPoint p1,
const SkIRect clip,
int  shiftUp 
)

Definition at line 57 of file SkEdge.cpp.

57 {
58 SkFDot6 x0, y0, x1, y1;
59
60 {
61#ifdef SK_RASTERIZE_EVEN_ROUNDING
62 x0 = SkScalarRoundToFDot6(p0.fX, shift);
63 y0 = SkScalarRoundToFDot6(p0.fY, shift);
64 x1 = SkScalarRoundToFDot6(p1.fX, shift);
65 y1 = SkScalarRoundToFDot6(p1.fY, shift);
66#else
67 float scale = float(1 << (shift + 6));
68 x0 = int(p0.fX * scale);
69 y0 = int(p0.fY * scale);
70 x1 = int(p1.fX * scale);
71 y1 = int(p1.fY * scale);
72#endif
73 }
74
75 int winding = 1;
76
77 if (y0 > y1) {
78 using std::swap;
79 swap(x0, x1);
80 swap(y0, y1);
81 winding = -1;
82 }
83
84 int top = SkFDot6Round(y0);
85 int bot = SkFDot6Round(y1);
86
87 // are we a zero-height line?
88 if (top == bot) {
89 return 0;
90 }
91 // are we completely above or below the clip?
92 if (clip && (top >= clip->fBottom || bot <= clip->fTop)) {
93 return 0;
94 }
95
96 SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
97 const SkFDot6 dy = SkEdge_Compute_DY(top, y0);
98
99 fX = SkFDot6ToFixed(x0 + SkFixedMul(slope, dy)); // + SK_Fixed1/2
100 fDX = slope;
101 fFirstY = top;
102 fLastY = bot - 1;
104 fCurveCount = 0;
105 fWinding = SkToS8(winding);
106 fCurveShift = 0;
107
108 if (clip) {
109 this->chopLineWithClip(*clip);
110 }
111 return 1;
112}
#define SkEdge_Compute_DY(top, y0)
Definition: SkEdge.h:25
#define SkFDot6Round(x)
Definition: SkFDot6.h:54
int32_t SkFDot6
Definition: SkFDot6.h:16
SkFixed SkFDot6ToFixed(SkFDot6 x)
Definition: SkFDot6.h:58
SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b)
Definition: SkFDot6.h:68
SkFDot6 SkScalarRoundToFDot6(SkScalar x, int shift=0)
Definition: SkFDot6.h:23
int32_t SkFixed
Definition: SkFixed.h:25
static SkFixed SkFixedMul(SkFixed a, SkFixed b)
Definition: SkFixed.h:96
void swap(sk_sp< T > &a, sk_sp< T > &b)
Definition: SkRefCnt.h:341
constexpr int8_t SkToS8(S x)
Definition: SkTo.h:21
const Scalar scale
int8_t fWinding
Definition: SkEdge.h:45
uint8_t fCurveShift
Definition: SkEdge.h:43
Type fEdgeType
Definition: SkEdge.h:41
int8_t fCurveCount
Definition: SkEdge.h:42
void chopLineWithClip(const SkIRect &clip)
Definition: SkEdge.cpp:149
float fX
x-axis value
Definition: SkPoint_impl.h:164
float fY
y-axis value
Definition: SkPoint_impl.h:165

◆ setLine() [2/2]

int SkEdge::setLine ( const SkPoint p0,
const SkPoint p1,
int  shiftUp 
)
inline

Definition at line 94 of file SkEdge.h.

94 {
95 SkFDot6 x0, y0, x1, y1;
96
97 {
98#ifdef SK_RASTERIZE_EVEN_ROUNDING
99 x0 = SkScalarRoundToFDot6(p0.fX, shift);
100 y0 = SkScalarRoundToFDot6(p0.fY, shift);
101 x1 = SkScalarRoundToFDot6(p1.fX, shift);
102 y1 = SkScalarRoundToFDot6(p1.fY, shift);
103#else
104 float scale = float(1 << (shift + 6));
105 x0 = int(p0.fX * scale);
106 y0 = int(p0.fY * scale);
107 x1 = int(p1.fX * scale);
108 y1 = int(p1.fY * scale);
109#endif
110 }
111
112 int winding = 1;
113
114 if (y0 > y1) {
115 using std::swap;
116 swap(x0, x1);
117 swap(y0, y1);
118 winding = -1;
119 }
120
121 int top = SkFDot6Round(y0);
122 int bot = SkFDot6Round(y1);
123
124 // are we a zero-height line?
125 if (top == bot) {
126 return 0;
127 }
128
129 SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
130 const SkFDot6 dy = SkEdge_Compute_DY(top, y0);
131
132 fX = SkFDot6ToFixed(x0 + SkFixedMul(slope, dy)); // + SK_Fixed1/2
133 fDX = slope;
134 fFirstY = top;
135 fLastY = bot - 1;
137 fCurveCount = 0;
138 fWinding = SkToS8(winding);
139 fCurveShift = 0;
140 return 1;
141}

◆ updateLine()

int SkEdge::updateLine ( SkFixed  ax,
SkFixed  ay,
SkFixed  bx,
SkFixed  by 
)
inline

Definition at line 115 of file SkEdge.cpp.

116{
117 SkASSERT(fWinding == 1 || fWinding == -1);
118 SkASSERT(fCurveCount != 0);
119// SkASSERT(fCurveShift != 0);
120
121 y0 >>= 10;
122 y1 >>= 10;
123
124 SkASSERT(y0 <= y1);
125
126 int top = SkFDot6Round(y0);
127 int bot = SkFDot6Round(y1);
128
129// SkASSERT(top >= fFirstY);
130
131 // are we a zero-height line?
132 if (top == bot)
133 return 0;
134
135 x0 >>= 10;
136 x1 >>= 10;
137
138 SkFixed slope = SkFDot6Div(x1 - x0, y1 - y0);
139 const SkFDot6 dy = SkEdge_Compute_DY(top, y0);
140
141 fX = SkFDot6ToFixed(x0 + SkFixedMul(slope, dy)); // + SK_Fixed1/2
142 fDX = slope;
143 fFirstY = top;
144 fLastY = bot - 1;
145
146 return 1;
147}

Member Data Documentation

◆ fCubicDShift

uint8_t SkEdge::fCubicDShift

Definition at line 44 of file SkEdge.h.

◆ fCurveCount

int8_t SkEdge::fCurveCount

Definition at line 42 of file SkEdge.h.

◆ fCurveShift

uint8_t SkEdge::fCurveShift

Definition at line 43 of file SkEdge.h.

◆ fDX

SkFixed SkEdge::fDX

Definition at line 38 of file SkEdge.h.

◆ fEdgeType

Type SkEdge::fEdgeType

Definition at line 41 of file SkEdge.h.

◆ fFirstY

int32_t SkEdge::fFirstY

Definition at line 39 of file SkEdge.h.

◆ fLastY

int32_t SkEdge::fLastY

Definition at line 40 of file SkEdge.h.

◆ fNext

SkEdge* SkEdge::fNext

Definition at line 34 of file SkEdge.h.

◆ fPrev

SkEdge* SkEdge::fPrev

Definition at line 35 of file SkEdge.h.

◆ fWinding

int8_t SkEdge::fWinding

Definition at line 45 of file SkEdge.h.

◆ fX

SkFixed SkEdge::fX

Definition at line 37 of file SkEdge.h.


The documentation for this struct was generated from the following files: