Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Friends | List of all members
SkClipStack::Element Class Reference

#include <SkClipStack.h>

Public Types

enum class  DeviceSpaceType {
  kEmpty , kRect , kRRect , kPath ,
  kShader , kLastType = kShader
}
 

Public Member Functions

 Element ()
 
 Element (const Element &)
 
 Element (const SkRect &rect, const SkMatrix &m, SkClipOp op, bool doAA)
 
 Element (const SkRRect &rrect, const SkMatrix &m, SkClipOp op, bool doAA)
 
 Element (const SkPath &path, const SkMatrix &m, SkClipOp op, bool doAA)
 
 Element (sk_sp< SkShader > shader)
 
 Element (const SkRect &rect, bool doAA)
 
 ~Element ()
 
bool operator== (const Element &element) const
 
bool operator!= (const Element &element) const
 Call to get the type of the clip element.
 
DeviceSpaceType getDeviceSpaceType () const
 Call to get the save count associated with this clip element.
 
int getSaveCount () const
 Call if getDeviceSpaceType() is kPath to get the path.
 
const SkPathgetDeviceSpacePath () const
 Call if getDeviceSpaceType() is kRRect to get the round-rect.
 
const SkRRectgetDeviceSpaceRRect () const
 Call if getDeviceSpaceType() is kRect to get the rect.
 
const SkRectgetDeviceSpaceRect () const
 Call if getDeviceSpaceType() is kShader to get a reference to the clip shader.
 
sk_sp< SkShaderrefShader () const
 
const SkShadergetShader () const
 
SkClipOp getOp () const
 
bool isReplaceOp () const
 Call to get the element as a path, regardless of its type.
 
void asDeviceSpacePath (SkPath *path) const
 Call if getType() is not kPath to get the element as a round rect.
 
const SkRRectasDeviceSpaceRRect () const
 
bool isAA () const
 Inverts the fill of the clip shape. Note that a kEmpty element remains kEmpty.
 
void invertShapeFillType ()
 
uint32_t getGenID () const
 
const SkRectgetBounds () const
 
bool contains (const SkRect &rect) const
 
bool contains (const SkRRect &rrect) const
 
bool isInverseFilled () const
 

Static Public Attributes

static const int kTypeCnt = (int)DeviceSpaceType::kLastType + 1
 

Friends

class SkClipStack
 

Detailed Description

An element of the clip stack. It represents a shape combined with the prevoius clip using a set operator. Each element can be antialiased or not.

Definition at line 49 of file SkClipStack.h.

Member Enumeration Documentation

◆ DeviceSpaceType

This indicates the shape type of the clip element in device space.

Enumerator
kEmpty 

This element makes the clip empty (regardless of previous elements).

This element combines a device space rect with the current clip.

kRect 

This element combines a device space round-rect with the current clip.

kRRect 

This element combines a device space path with the current clip.

kPath 

This element does not have geometry, but applies a shader to the clip.

kShader 
kLastType 

Definition at line 52 of file SkClipStack.h.

52 {
53 //!< This element makes the clip empty (regardless of previous elements).
54 kEmpty,
55 //!< This element combines a device space rect with the current clip.
56 kRect,
57 //!< This element combines a device space round-rect with the current clip.
58 kRRect,
59 //!< This element combines a device space path with the current clip.
60 kPath,
61 //!< This element does not have geometry, but applies a shader to the clip
62 kShader,
63
65 };
@ kPath
This element does not have geometry, but applies a shader to the clip.
@ kEmpty
This element makes the clip empty (regardless of previous elements).
@ kRect
This element combines a device space round-rect with the current clip.
@ kRRect
This element combines a device space path with the current clip.

Constructor & Destructor Documentation

◆ Element() [1/7]

SkClipStack::Element::Element ( )
inline

Definition at line 68 of file SkClipStack.h.

68 {
69 this->initCommon(0, SkClipOp::kIntersect, false);
70 this->setEmpty();
71 }

◆ Element() [2/7]

SkClipStack::Element::Element ( const Element that)

Definition at line 22 of file SkClipStack.cpp.

22 {
23 switch (that.getDeviceSpaceType()) {
25 fDeviceSpaceRRect.setEmpty();
26 fDeviceSpacePath.reset();
27 fShader.reset();
28 break;
29 case DeviceSpaceType::kRect: // Rect uses rrect
31 fDeviceSpacePath.reset();
32 fShader.reset();
33 fDeviceSpaceRRect = that.fDeviceSpaceRRect;
34 break;
36 fShader.reset();
37 fDeviceSpacePath.set(that.getDeviceSpacePath());
38 break;
40 fDeviceSpacePath.reset();
41 fShader = that.fShader;
42 break;
43 }
44
45 fSaveCount = that.fSaveCount;
46 fOp = that.fOp;
47 fDeviceSpaceType = that.fDeviceSpaceType;
48 fDoAA = that.fDoAA;
49 fIsReplace = that.fIsReplace;
50 fFiniteBoundType = that.fFiniteBoundType;
51 fFiniteBound = that.fFiniteBound;
52 fIsIntersectionOfRects = that.fIsIntersectionOfRects;
53 fGenID = that.fGenID;
54}
void setEmpty()
Definition SkRRect.h:118
void reset()
Definition SkTLazy.h:69
T * set(const T &src)
Definition SkTLazy.h:56
void reset(T *ptr=nullptr)
Definition SkRefCnt.h:310

◆ Element() [3/7]

SkClipStack::Element::Element ( const SkRect rect,
const SkMatrix m,
SkClipOp  op,
bool  doAA 
)
inline

Definition at line 75 of file SkClipStack.h.

75 {
76 this->initRect(0, rect, m, op, doAA);
77 }

◆ Element() [4/7]

SkClipStack::Element::Element ( const SkRRect rrect,
const SkMatrix m,
SkClipOp  op,
bool  doAA 
)
inline

Definition at line 79 of file SkClipStack.h.

79 {
80 this->initRRect(0, rrect, m, op, doAA);
81 }

◆ Element() [5/7]

SkClipStack::Element::Element ( const SkPath path,
const SkMatrix m,
SkClipOp  op,
bool  doAA 
)
inline

Definition at line 83 of file SkClipStack.h.

83 {
84 this->initPath(0, path, m, op, doAA);
85 }

◆ Element() [6/7]

SkClipStack::Element::Element ( sk_sp< SkShader shader)
inline

Definition at line 87 of file SkClipStack.h.

87 {
88 this->initShader(0, std::move(shader));
89 }

◆ Element() [7/7]

SkClipStack::Element::Element ( const SkRect rect,
bool  doAA 
)
inline

Definition at line 91 of file SkClipStack.h.

91 {
92 this->initReplaceRect(0, rect, doAA);
93 }

◆ ~Element()

SkClipStack::Element::~Element ( )
default

Member Function Documentation

◆ asDeviceSpacePath()

void SkClipStack::Element::asDeviceSpacePath ( SkPath path) const

Call if getType() is not kPath to get the element as a round rect.

Definition at line 255 of file SkClipStack.cpp.

255 {
256 switch (fDeviceSpaceType) {
258 path->reset();
259 break;
261 path->reset();
262 path->addRect(this->getDeviceSpaceRect());
263 break;
265 path->reset();
266 path->addRRect(fDeviceSpaceRRect);
267 break;
269 *path = *fDeviceSpacePath;
270 break;
272 path->reset();
273 path->addRect(SkRectPriv::MakeLargeS32());
274 break;
275 }
276 path->setIsVolatile(true);
277}
const SkRect & getDeviceSpaceRect() const
Call if getDeviceSpaceType() is kShader to get a reference to the clip shader.
SkPath & reset()
Definition SkPath.cpp:360
static SkRect MakeLargeS32()
Definition SkRectPriv.h:33
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

◆ asDeviceSpaceRRect()

const SkRRect & SkClipStack::Element::asDeviceSpaceRRect ( ) const
inline

Definition at line 143 of file SkClipStack.h.

143 {
144 SkASSERT(DeviceSpaceType::kPath != fDeviceSpaceType);
145 return fDeviceSpaceRRect;
146 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ contains() [1/2]

bool SkClipStack::Element::contains ( const SkRect rect) const

Conservatively checks whether the clip shape contains the rect/rrect. (Whether the shape is inverse filled is not considered.)

Definition at line 106 of file SkClipStack.cpp.

106 {
107 switch (fDeviceSpaceType) {
109 return this->getDeviceSpaceRect().contains(rect);
111 return fDeviceSpaceRRect.contains(rect);
113 return fDeviceSpacePath->conservativelyContainsRect(rect);
116 return false;
117 default:
118 SkDEBUGFAIL("Unexpected type.");
119 return false;
120 }
121}
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
bool conservativelyContainsRect(const SkRect &rect) const
Definition SkPath.cpp:289
bool contains(const SkRect &rect) const
Definition SkRRect.cpp:360
bool contains(SkScalar x, SkScalar y) const
Definition extension.cpp:19

◆ contains() [2/2]

bool SkClipStack::Element::contains ( const SkRRect rrect) const

Definition at line 123 of file SkClipStack.cpp.

123 {
124 switch (fDeviceSpaceType) {
126 return this->getDeviceSpaceRect().contains(rrect.getBounds());
128 // We don't currently have a generalized rrect-rrect containment.
129 return fDeviceSpaceRRect.contains(rrect.getBounds()) || rrect == fDeviceSpaceRRect;
131 return fDeviceSpacePath->conservativelyContainsRect(rrect.getBounds());
134 return false;
135 default:
136 SkDEBUGFAIL("Unexpected type.");
137 return false;
138 }
139}
const SkRect & getBounds() const
Definition SkRRect.h:279
SkRRect rrect
Definition SkRecords.h:232

◆ getBounds()

const SkRect & SkClipStack::Element::getBounds ( ) const

Gets the bounds of the clip element, either the rect or path bounds. (Whether the shape is inverse filled is not considered.)

Definition at line 84 of file SkClipStack.cpp.

84 {
85 static const SkRect kEmpty = {0, 0, 0, 0};
87 switch (fDeviceSpaceType) {
88 case DeviceSpaceType::kRect: // fallthrough
90 return fDeviceSpaceRRect.getBounds();
92 return fDeviceSpacePath->getBounds();
94 // Shaders have infinite bounds since any pixel could have clipped or full coverage
95 // (which is different from wide-open, where every pixel has 1.0 coverage, or empty
96 // where every pixel has 0.0 coverage).
97 return kInfinite;
99 return kEmpty;
100 default:
101 SkDEBUGFAIL("Unexpected type.");
102 return kEmpty;
103 }
104}
@ kInfinite
const SkRect & getBounds() const
Definition SkPath.cpp:420

◆ getDeviceSpacePath()

const SkPath & SkClipStack::Element::getDeviceSpacePath ( ) const
inline

Call if getDeviceSpaceType() is kRRect to get the round-rect.

Definition at line 107 of file SkClipStack.h.

◆ getDeviceSpaceRect()

const SkRect & SkClipStack::Element::getDeviceSpaceRect ( ) const
inline

Call if getDeviceSpaceType() is kShader to get a reference to the clip shader.

Definition at line 119 of file SkClipStack.h.

◆ getDeviceSpaceRRect()

const SkRRect & SkClipStack::Element::getDeviceSpaceRRect ( ) const
inline

Call if getDeviceSpaceType() is kRect to get the rect.

Definition at line 113 of file SkClipStack.h.

◆ getDeviceSpaceType()

DeviceSpaceType SkClipStack::Element::getDeviceSpaceType ( ) const
inline

Call to get the save count associated with this clip element.

Definition at line 101 of file SkClipStack.h.

◆ getGenID()

uint32_t SkClipStack::Element::getGenID ( ) const
inline

The GenID can be used by clip stack clients to cache representations of the clip. The ID corresponds to the set of clip elements up to and including this element within the stack not to the element itself. That is the same clip path in different stacks will have a different ID since the elements produce different clip result in the context of their stacks.

Definition at line 160 of file SkClipStack.h.

160{ SkASSERT(kInvalidGenID != fGenID); return fGenID; }
static const uint32_t kInvalidGenID

◆ getOp()

SkClipOp SkClipStack::Element::getOp ( ) const
inline

Definition at line 135 of file SkClipStack.h.

135{ return fOp; }

◆ getSaveCount()

int SkClipStack::Element::getSaveCount ( ) const
inline

Call if getDeviceSpaceType() is kPath to get the path.

Definition at line 104 of file SkClipStack.h.

◆ getShader()

const SkShader * SkClipStack::Element::getShader ( ) const
inline

Call if getDeviceSpaceType() is not kEmpty to get the set operation used to combine this element.

Definition at line 129 of file SkClipStack.h.

◆ invertShapeFillType()

void SkClipStack::Element::invertShapeFillType ( )

Definition at line 141 of file SkClipStack.cpp.

141 {
142 switch (fDeviceSpaceType) {
144 fDeviceSpacePath.init();
145 fDeviceSpacePath->addRect(this->getDeviceSpaceRect());
147 fDeviceSpaceType = DeviceSpaceType::kPath;
148 break;
150 fDeviceSpacePath.init();
151 fDeviceSpacePath->addRRect(fDeviceSpaceRRect);
153 fDeviceSpaceType = DeviceSpaceType::kPath;
154 break;
156 fDeviceSpacePath->toggleInverseFillType();
157 break;
159 fShader = as_SB(fShader)->makeInvertAlpha();
160 break;
162 // Should this set to an empty, inverse filled path?
163 break;
164 }
165}
SkShaderBase * as_SB(SkShader *shader)
void setFillType(SkPathFillType ft)
Definition SkPath.h:235
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
Definition SkPath.cpp:990
void toggleInverseFillType()
Definition SkPath.h:249
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition SkPath.cpp:854
sk_sp< SkShader > makeInvertAlpha() const
T * init(Args &&... args)
Definition SkTLazy.h:45

◆ isAA()

bool SkClipStack::Element::isAA ( ) const
inline

Inverts the fill of the clip shape. Note that a kEmpty element remains kEmpty.

If getType() is not kEmpty this indicates whether the clip shape should be anti-aliased when it is rasterized.

Definition at line 150 of file SkClipStack.h.

◆ isInverseFilled()

bool SkClipStack::Element::isInverseFilled ( ) const
inline

Is the clip shape inverse filled.

Definition at line 178 of file SkClipStack.h.

178 {
179 return DeviceSpaceType::kPath == fDeviceSpaceType &&
180 fDeviceSpacePath->isInverseFillType();
181 }
bool isInverseFillType() const
Definition SkPath.h:244

◆ isReplaceOp()

bool SkClipStack::Element::isReplaceOp ( ) const
inline

Call to get the element as a path, regardless of its type.

Definition at line 137 of file SkClipStack.h.

◆ operator!=()

bool SkClipStack::Element::operator!= ( const Element element) const
inline

Call to get the type of the clip element.

Definition at line 98 of file SkClipStack.h.

◆ operator==()

bool SkClipStack::Element::operator== ( const Element element) const

Definition at line 58 of file SkClipStack.cpp.

58 {
59 if (this == &element) {
60 return true;
61 }
62 if (fOp != element.fOp || fDeviceSpaceType != element.fDeviceSpaceType ||
63 fDoAA != element.fDoAA || fIsReplace != element.fIsReplace ||
64 fSaveCount != element.fSaveCount) {
65 return false;
66 }
67 switch (fDeviceSpaceType) {
69 return this->getShader() == element.getShader();
71 return this->getDeviceSpacePath() == element.getDeviceSpacePath();
73 return fDeviceSpaceRRect == element.fDeviceSpaceRRect;
75 return this->getDeviceSpaceRect() == element.getDeviceSpaceRect();
77 return true;
78 default:
79 SkDEBUGFAIL("Unexpected type.");
80 return false;
81 }
82}
const SkShader * getShader() const
const SkPath & getDeviceSpacePath() const
Call if getDeviceSpaceType() is kRRect to get the round-rect.

◆ refShader()

sk_sp< SkShader > SkClipStack::Element::refShader ( ) const
inline

Definition at line 126 of file SkClipStack.h.

126 {
127 return fShader;
128 }

Friends And Related Symbol Documentation

◆ SkClipStack

friend class SkClipStack
friend

Definition at line 192 of file SkClipStack.h.

Member Data Documentation

◆ kTypeCnt

const int SkClipStack::Element::kTypeCnt = (int)DeviceSpaceType::kLastType + 1
static

Definition at line 66 of file SkClipStack.h.


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