Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 26 of file SkEdge.h.

Member Enumeration Documentation

◆ Type

Enumerator
kLine_Type 
kQuad_Type 
kCubic_Type 

Definition at line 27 of file SkEdge.h.

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

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:3824
int32_t fLastY
Definition SkEdge.h:39
SkFixed fX
Definition SkEdge.h:36
SkFixed fDX
Definition SkEdge.h:37
int32_t fFirstY
Definition SkEdge.h:38

◆ intersectsClip()

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

Definition at line 52 of file SkEdge.h.

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

◆ 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:24
#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
Type::kYUV Type::kRGBA() int(0.7 *637)
const Scalar scale
int8_t fWinding
Definition SkEdge.h:44
uint8_t fCurveShift
Definition SkEdge.h:42
Type fEdgeType
Definition SkEdge.h:40
int8_t fCurveCount
Definition SkEdge.h:41
void chopLineWithClip(const SkIRect &clip)
Definition SkEdge.cpp:149
float fX
x-axis value
float fY
y-axis value

◆ setLine() [2/2]

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

Definition at line 93 of file SkEdge.h.

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

◆ 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 43 of file SkEdge.h.

◆ fCurveCount

int8_t SkEdge::fCurveCount

Definition at line 41 of file SkEdge.h.

◆ fCurveShift

uint8_t SkEdge::fCurveShift

Definition at line 42 of file SkEdge.h.

◆ fDX

SkFixed SkEdge::fDX

Definition at line 37 of file SkEdge.h.

◆ fEdgeType

Type SkEdge::fEdgeType

Definition at line 40 of file SkEdge.h.

◆ fFirstY

int32_t SkEdge::fFirstY

Definition at line 38 of file SkEdge.h.

◆ fLastY

int32_t SkEdge::fLastY

Definition at line 39 of file SkEdge.h.

◆ fNext

SkEdge* SkEdge::fNext

Definition at line 33 of file SkEdge.h.

◆ fPrev

SkEdge* SkEdge::fPrev

Definition at line 34 of file SkEdge.h.

◆ fWinding

int8_t SkEdge::fWinding

Definition at line 44 of file SkEdge.h.

◆ fX

SkFixed SkEdge::fX

Definition at line 36 of file SkEdge.h.


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