Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkRasterClip Class Reference

#include <SkRasterClip.h>

Public Member Functions

 SkRasterClip ()
 
 SkRasterClip (const SkIRect &)
 
 SkRasterClip (const SkRegion &)
 
 SkRasterClip (const SkRasterClip &)
 
 SkRasterClip (const SkPath &path, const SkIRect &bounds, bool doAA)
 
 ~SkRasterClip ()
 
SkRasterClipoperator= (const SkRasterClip &)
 
bool isBW () const
 
bool isAA () const
 
const SkRegionbwRgn () const
 
const SkAAClipaaRgn () const
 
bool isEmpty () const
 
bool isRect () const
 
bool isComplex () const
 
const SkIRectgetBounds () const
 
bool setEmpty ()
 
bool setRect (const SkIRect &)
 
bool op (const SkIRect &, SkClipOp)
 
bool op (const SkRegion &, SkClipOp)
 
bool op (const SkRect &, const SkMatrix &matrix, SkClipOp, bool doAA)
 
bool op (const SkRRect &, const SkMatrix &matrix, SkClipOp, bool doAA)
 
bool op (const SkPath &, const SkMatrix &matrix, SkClipOp, bool doAA)
 
bool op (sk_sp< SkShader >)
 
void translate (int dx, int dy, SkRasterClip *dst) const
 
bool quickContains (const SkIRect &rect) const
 
bool quickReject (const SkIRect &rect) const
 
void validate () const
 
sk_sp< SkShaderclipShader () const
 

Detailed Description

Wraps a SkRegion and SkAAClip, so we have a single object that can represent either our BW or antialiased clips.

Definition at line 29 of file SkRasterClip.h.

Constructor & Destructor Documentation

◆ SkRasterClip() [1/5]

SkRasterClip::SkRasterClip ( )

Definition at line 68 of file SkRasterClip.cpp.

68 {
69 fIsBW = true;
70 fIsEmpty = true;
71 fIsRect = false;
72 SkDEBUGCODE(this->validate();)
73}
#define SkDEBUGCODE(...)
Definition SkDebug.h:23
void validate() const

◆ SkRasterClip() [2/5]

SkRasterClip::SkRasterClip ( const SkIRect bounds)
explicit

Definition at line 61 of file SkRasterClip.cpp.

61 : fBW(bounds) {
62 fIsBW = true;
63 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute
64 fIsRect = !fIsEmpty;
65 SkDEBUGCODE(this->validate();)
66}

◆ SkRasterClip() [3/5]

SkRasterClip::SkRasterClip ( const SkRegion rgn)
explicit

Definition at line 54 of file SkRasterClip.cpp.

54 : fBW(rgn) {
55 fIsBW = true;
56 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute
57 fIsRect = !fIsEmpty;
58 SkDEBUGCODE(this->validate();)
59}

◆ SkRasterClip() [4/5]

SkRasterClip::SkRasterClip ( const SkRasterClip that)
explicit

Definition at line 20 of file SkRasterClip.cpp.

21 : fIsBW(that.fIsBW)
22 , fIsEmpty(that.fIsEmpty)
23 , fIsRect(that.fIsRect)
24 , fShader(that.fShader)
25{
27
28 if (fIsBW) {
29 fBW = that.fBW;
30 } else {
31 fAA = that.fAA;
32 }
33
34 SkDEBUGCODE(this->validate();)
35}
#define AUTO_RASTERCLIP_VALIDATE(rc)

◆ SkRasterClip() [5/5]

SkRasterClip::SkRasterClip ( const SkPath path,
const SkIRect bounds,
bool  doAA 
)

Definition at line 75 of file SkRasterClip.cpp.

75 {
76 if (doAA) {
77 fIsBW = false;
78 fAA.setPath(path, bounds, true);
79 } else {
80 fIsBW = true;
81 fBW.setPath(path, SkRegion(bounds));
82 }
83 fIsEmpty = this->computeIsEmpty(); // bounds might be empty, so compute
84 fIsRect = this->computeIsRect();
85 SkDEBUGCODE(this->validate();)
86}
bool setPath(const SkPath &, const SkIRect &bounds, bool doAA=true)
bool setPath(const SkPath &path, const SkRegion &clip)

◆ ~SkRasterClip()

SkRasterClip::~SkRasterClip ( )

Definition at line 88 of file SkRasterClip.cpp.

88 {
89 SkDEBUGCODE(this->validate();)
90}

Member Function Documentation

◆ aaRgn()

const SkAAClip & SkRasterClip::aaRgn ( ) const
inline

Definition at line 44 of file SkRasterClip.h.

44{ SkASSERT(!fIsBW); return fAA; }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ bwRgn()

const SkRegion & SkRasterClip::bwRgn ( ) const
inline

Definition at line 43 of file SkRasterClip.h.

43{ SkASSERT(fIsBW); return fBW; }

◆ clipShader()

sk_sp< SkShader > SkRasterClip::clipShader ( ) const
inline

Definition at line 94 of file SkRasterClip.h.

94{ return fShader; }

◆ getBounds()

const SkIRect & SkRasterClip::getBounds ( ) const
inline

Definition at line 59 of file SkRasterClip.h.

59 {
60 return fIsBW ? fBW.getBounds() : fAA.getBounds();
61 }
const SkIRect & getBounds() const
Definition SkAAClip.h:33
const SkIRect & getBounds() const
Definition SkRegion.h:165

◆ isAA()

bool SkRasterClip::isAA ( ) const
inline

Definition at line 42 of file SkRasterClip.h.

42{ return !fIsBW; }

◆ isBW()

bool SkRasterClip::isBW ( ) const
inline

Definition at line 41 of file SkRasterClip.h.

41{ return fIsBW; }

◆ isComplex()

bool SkRasterClip::isComplex ( ) const
inline

Definition at line 56 of file SkRasterClip.h.

56 {
57 return fIsBW ? fBW.isComplex() : !fAA.isEmpty();
58 }
bool isEmpty() const
Definition SkAAClip.h:32
bool isComplex() const
Definition SkRegion.h:158

◆ isEmpty()

bool SkRasterClip::isEmpty ( ) const
inline

Definition at line 46 of file SkRasterClip.h.

46 {
47 SkASSERT(this->computeIsEmpty() == fIsEmpty);
48 return fIsEmpty;
49 }

◆ isRect()

bool SkRasterClip::isRect ( ) const
inline

Definition at line 51 of file SkRasterClip.h.

51 {
52 SkASSERT(this->computeIsRect() == fIsRect);
53 return fIsRect;
54 }

◆ op() [1/6]

bool SkRasterClip::op ( const SkIRect rect,
SkClipOp  op 
)

Definition at line 115 of file SkRasterClip.cpp.

115 {
117
118 if (fIsBW) {
119 fBW.op(rect, (SkRegion::Op) op);
120 } else {
121 fAA.op(rect, op);
122 }
123 return this->updateCacheAndReturnNonEmpty();
124}
bool op(const SkIRect &, SkClipOp)
bool op(const SkIRect &, SkClipOp)
bool op(const SkIRect &rect, Op op)
Definition SkRegion.h:384

◆ op() [2/6]

bool SkRasterClip::op ( const SkPath path,
const SkMatrix matrix,
SkClipOp  op,
bool  doAA 
)

Definition at line 185 of file SkRasterClip.cpp.

185 {
187
188 SkPath devPath;
189 path.transform(matrix, &devPath);
190
191 // Since op is either intersect or difference, the clip is always shrinking; that means we can
192 // always use our current bounds as the limiting factor for region/aaclip operations.
193 if (this->isRect() && op == SkClipOp::kIntersect) {
194 // However, in the relatively common case of intersecting a new path with a rectangular
195 // clip, it's faster to convert the path into a region/aa-mask in place than evaluate the
196 // actual intersection. See skbug.com/12398
197 if (doAA && fIsBW) {
198 this->convertToAA();
199 }
200 if (fIsBW) {
201 fBW.setPath(devPath, SkRegion(this->getBounds()));
202 } else {
203 fAA.setPath(devPath, this->getBounds(), doAA);
204 }
205 return this->updateCacheAndReturnNonEmpty();
206 } else {
207 return this->op(SkRasterClip(devPath, this->getBounds(), doAA), op);
208 }
209}
const SkIRect & getBounds() const
bool isRect() const
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
Definition switches.h:57

◆ op() [3/6]

bool SkRasterClip::op ( const SkRect localRect,
const SkMatrix matrix,
SkClipOp  op,
bool  doAA 
)

Definition at line 152 of file SkRasterClip.cpp.

152 {
154
155 const bool isScaleTrans = matrix.isScaleTranslate();
156 if (!isScaleTrans) {
157 return this->op(SkPath::Rect(localRect), matrix, op, doAA);
158 }
159
160 SkRect devRect = matrix.mapRect(localRect);
161 if (fIsBW && doAA) {
162 // check that the rect really needs aa, or is it close enought to
163 // integer boundaries that we can just treat it as a BW rect?
164 if (nearly_integral(devRect.fLeft) && nearly_integral(devRect.fTop) &&
165 nearly_integral(devRect.fRight) && nearly_integral(devRect.fBottom)) {
166 doAA = false;
167 }
168 }
169
170 if (fIsBW && !doAA) {
171 (void)fBW.op(devRect.round(), (SkRegion::Op) op);
172 } else {
173 if (fIsBW) {
174 this->convertToAA();
175 }
176 (void)fAA.op(devRect, op, doAA);
177 }
178 return this->updateCacheAndReturnNonEmpty();
179}
static bool nearly_integral(SkScalar x)
static SkPath Rect(const SkRect &, SkPathDirection=SkPathDirection::kCW, unsigned startIndex=0)
Definition SkPath.cpp:3518
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258
SkScalar fBottom
larger y-axis bounds
Definition extension.cpp:17
SkScalar fLeft
smaller x-axis bounds
Definition extension.cpp:14
SkScalar fRight
larger x-axis bounds
Definition extension.cpp:16
void round(SkIRect *dst) const
Definition SkRect.h:1228
SkScalar fTop
smaller y-axis bounds
Definition extension.cpp:15

◆ op() [4/6]

bool SkRasterClip::op ( const SkRegion rgn,
SkClipOp  op 
)

Definition at line 126 of file SkRasterClip.cpp.

126 {
128
129 if (fIsBW) {
130 (void)fBW.op(rgn, (SkRegion::Op) op);
131 } else {
132 SkAAClip tmp;
133 tmp.setRegion(rgn);
134 (void)fAA.op(tmp, op);
135 }
136 return this->updateCacheAndReturnNonEmpty();
137}
bool setRegion(const SkRegion &)

◆ op() [5/6]

bool SkRasterClip::op ( const SkRRect rrect,
const SkMatrix matrix,
SkClipOp  op,
bool  doAA 
)

Definition at line 181 of file SkRasterClip.cpp.

181 {
182 return this->op(SkPath::RRect(rrect), matrix, op, doAA);
183}
static SkPath RRect(const SkRRect &, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:3534

◆ op() [6/6]

bool SkRasterClip::op ( sk_sp< SkShader sh)

Definition at line 211 of file SkRasterClip.cpp.

211 {
213
214 if (!fShader) {
215 fShader = sh;
216 } else {
217 fShader = SkShaders::Blend(SkBlendMode::kSrcIn, sh, fShader);
218 }
219 return !this->isEmpty();
220}
@ kSrcIn
r = s * da
bool isEmpty() const

◆ operator=()

SkRasterClip & SkRasterClip::operator= ( const SkRasterClip that)

Definition at line 37 of file SkRasterClip.cpp.

37 {
39
40 fIsBW = that.fIsBW;
41 if (fIsBW) {
42 fBW = that.fBW;
43 } else {
44 fAA = that.fAA;
45 }
46
47 fIsEmpty = that.isEmpty();
48 fIsRect = that.isRect();
49 fShader = that.fShader;
50 SkDEBUGCODE(this->validate();)
51 return *this;
52}

◆ quickContains()

bool SkRasterClip::quickContains ( const SkIRect rect) const
inline

Definition at line 75 of file SkRasterClip.h.

75 {
76 return fIsBW ? fBW.quickContains(rect) : fAA.quickContains(rect);
77 }
bool quickContains(const SkIRect &r) const
Definition SkAAClip.h:56
bool quickContains(const SkIRect &r) const
Definition SkRegion.h:310

◆ quickReject()

bool SkRasterClip::quickReject ( const SkIRect rect) const
inline

Return true if this region is empty, or if the specified rectangle does not intersect the region. Returning false is not a guarantee that they intersect, but returning true is a guarantee that they do not.

Definition at line 84 of file SkRasterClip.h.

84 {
85 return !SkIRect::Intersects(this->getBounds(), rect);
86 }
static bool Intersects(const SkIRect &a, const SkIRect &b)
Definition SkRect.h:535

◆ setEmpty()

bool SkRasterClip::setEmpty ( )

Definition at line 92 of file SkRasterClip.cpp.

92 {
94
95 fIsBW = true;
96 fBW.setEmpty();
97 fAA.setEmpty();
98 fIsEmpty = true;
99 fIsRect = false;
100 return false;
101}
bool setEmpty()
bool setEmpty()
Definition SkRegion.cpp:185

◆ setRect()

bool SkRasterClip::setRect ( const SkIRect rect)

Definition at line 103 of file SkRasterClip.cpp.

103 {
105
106 fIsBW = true;
107 fAA.setEmpty();
108 fIsRect = fBW.setRect(rect);
109 fIsEmpty = !fIsRect;
110 return fIsRect;
111}
bool setRect(const SkIRect &rect)
Definition SkRegion.cpp:192

◆ translate()

void SkRasterClip::translate ( int  dx,
int  dy,
SkRasterClip dst 
) const

Definition at line 246 of file SkRasterClip.cpp.

246 {
247 if (nullptr == dst) {
248 return;
249 }
250
252
253 if (this->isEmpty()) {
254 dst->setEmpty();
255 return;
256 }
257 if (0 == (dx | dy)) {
258 *dst = *this;
259 return;
260 }
261
262 dst->fIsBW = fIsBW;
263 if (fIsBW) {
264 fBW.translate(dx, dy, &dst->fBW);
265 dst->fAA.setEmpty();
266 } else {
267 fAA.translate(dx, dy, &dst->fAA);
268 dst->fBW.setEmpty();
269 }
270 dst->updateCacheAndReturnNonEmpty();
271}
bool translate(int dx, int dy, SkAAClip *dst) const
void translate(int dx, int dy)
Definition SkRegion.h:349
dst
Definition cp.py:12

◆ validate()

void SkRasterClip::validate ( ) const
inline

Definition at line 91 of file SkRasterClip.h.

91{}

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