Flutter Engine
The Flutter Engine
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 30 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}
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
void validate() const
Definition: SkRasterClip.h:92

◆ 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}
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ 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)
Definition: SkRasterClip.h:149

◆ 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;
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)
Definition: SkAAClip.cpp:1401
bool setPath(const SkPath &path, const SkRegion &clip)
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

◆ ~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 45 of file SkRasterClip.h.

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

◆ bwRgn()

const SkRegion & SkRasterClip::bwRgn ( ) const
inline

Definition at line 44 of file SkRasterClip.h.

44{ SkASSERT(fIsBW); return fBW; }

◆ clipShader()

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

Definition at line 95 of file SkRasterClip.h.

95{ return fShader; }

◆ getBounds()

const SkIRect & SkRasterClip::getBounds ( ) const
inline

Definition at line 60 of file SkRasterClip.h.

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

◆ isAA()

bool SkRasterClip::isAA ( ) const
inline

Definition at line 43 of file SkRasterClip.h.

43{ return !fIsBW; }

◆ isBW()

bool SkRasterClip::isBW ( ) const
inline

Definition at line 42 of file SkRasterClip.h.

42{ return fIsBW; }

◆ isComplex()

bool SkRasterClip::isComplex ( ) const
inline

Definition at line 57 of file SkRasterClip.h.

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

◆ isEmpty()

bool SkRasterClip::isEmpty ( ) const
inline

Definition at line 47 of file SkRasterClip.h.

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

◆ isRect()

bool SkRasterClip::isRect ( ) const
inline

Definition at line 52 of file SkRasterClip.h.

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

◆ 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)
Definition: SkAAClip.cpp:1459
bool op(const SkIRect &, SkClipOp)
bool op(const SkIRect &rect, Op op)
Definition: SkRegion.h:384
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ 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}
Definition: SkPath.h:59
const SkIRect & getBounds() const
Definition: SkRasterClip.h:60
bool isRect() const
Definition: SkRasterClip.h:52
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

◆ 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:3586
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 &)
Definition: SkAAClip.cpp:1313

◆ 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:3602

◆ 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
Definition: SkRasterClip.h:47
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
sh
Definition: run_sh.py:10

◆ 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 76 of file SkRasterClip.h.

76 {
77 return fIsBW ? fBW.quickContains(rect) : fAA.quickContains(rect);
78 }
bool quickContains(const SkIRect &r) const
Definition: SkAAClip.h:57
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 85 of file SkRasterClip.h.

85 {
86 return !SkIRect::Intersects(this->getBounds(), rect);
87 }
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()
Definition: SkAAClip.cpp:1264
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
Definition: SkAAClip.cpp:1524
void translate(int dx, int dy)
Definition: SkRegion.h:349
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208
dst
Definition: cp.py:12

◆ validate()

void SkRasterClip::validate ( ) const
inline

Definition at line 92 of file SkRasterClip.h.

92{}

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