Flutter Engine
The Flutter Engine
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. More...
 
DeviceSpaceType getDeviceSpaceType () const
 Call to get the save count associated with this clip element. More...
 
int getSaveCount () const
 Call if getDeviceSpaceType() is kPath to get the path. More...
 
const SkPathgetDeviceSpacePath () const
 Call if getDeviceSpaceType() is kRRect to get the round-rect. More...
 
const SkRRectgetDeviceSpaceRRect () const
 Call if getDeviceSpaceType() is kRect to get the rect. More...
 
const SkRectgetDeviceSpaceRect () const
 Call if getDeviceSpaceType() is kShader to get a reference to the clip shader. More...
 
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. More...
 
void asDeviceSpacePath (SkPath *path) const
 Call if getType() is not kPath to get the element as a round rect. More...
 
const SkRRectasDeviceSpaceRRect () const
 
bool isAA () const
 Inverts the fill of the clip shape. Note that a kEmpty element remains kEmpty. More...
 
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 50 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 53 of file SkClipStack.h.

53 {
54 //!< This element makes the clip empty (regardless of previous elements).
55 kEmpty,
56 //!< This element combines a device space rect with the current clip.
57 kRect,
58 //!< This element combines a device space round-rect with the current clip.
59 kRRect,
60 //!< This element combines a device space path with the current clip.
61 kPath,
62 //!< This element does not have geometry, but applies a shader to the clip
63 kShader,
64
66 };
@ kRRect
constexpr std::array< std::array< float, 2 >, 2 > kRect
@ kPath
Definition: SkGlyph.h:317

Constructor & Destructor Documentation

◆ Element() [1/7]

SkClipStack::Element::Element ( )
inline

Definition at line 69 of file SkClipStack.h.

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

◆ 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}
@ 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.
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 76 of file SkClipStack.h.

76 {
77 this->initRect(0, rect, m, op, doAA);
78 }
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350

◆ Element() [4/7]

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

Definition at line 80 of file SkClipStack.h.

80 {
81 this->initRRect(0, rrect, m, op, doAA);
82 }
SkRRect rrect
Definition: SkRecords.h:232

◆ Element() [5/7]

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

Definition at line 84 of file SkClipStack.h.

84 {
85 this->initPath(0, path, m, op, doAA);
86 }
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

◆ Element() [6/7]

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

Definition at line 88 of file SkClipStack.h.

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

◆ Element() [7/7]

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

Definition at line 92 of file SkClipStack.h.

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

◆ ~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.
Definition: SkClipStack.h:120
SkPath & reset()
Definition: SkPath.cpp:370
static SkRect MakeLargeS32()
Definition: SkRectPriv.h:33

◆ asDeviceSpaceRRect()

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

Definition at line 144 of file SkClipStack.h.

144 {
145 SkASSERT(DeviceSpaceType::kPath != fDeviceSpaceType);
146 return fDeviceSpaceRRect;
147 }
#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:291
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

◆ 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
Definition: ScalarTest.cpp:124
const SkRect & getBounds() const
Definition: SkPath.cpp:430

◆ getDeviceSpacePath()

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

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

Definition at line 108 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 120 of file SkClipStack.h.

◆ getDeviceSpaceRRect()

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

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

Definition at line 114 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 102 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 161 of file SkClipStack.h.

161{ SkASSERT(kInvalidGenID != fGenID); return fGenID; }
static const uint32_t kInvalidGenID
Definition: SkClipStack.h:383

◆ getOp()

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

Definition at line 136 of file SkClipStack.h.

136{ return fOp; }

◆ getSaveCount()

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

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

Definition at line 105 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 130 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)
Definition: SkShaderBase.h:412
void setFillType(SkPathFillType ft)
Definition: SkPath.h:235
SkPath & addRRect(const SkRRect &rrect, SkPathDirection dir=SkPathDirection::kCW)
Definition: SkPath.cpp:1000
void toggleInverseFillType()
Definition: SkPath.h:249
SkPath & addRect(const SkRect &rect, SkPathDirection dir, unsigned start)
Definition: SkPath.cpp:864
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 151 of file SkClipStack.h.

◆ isInverseFilled()

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

Is the clip shape inverse filled.

Definition at line 179 of file SkClipStack.h.

179 {
180 return DeviceSpaceType::kPath == fDeviceSpaceType &&
181 fDeviceSpacePath->isInverseFillType();
182 }
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 138 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 99 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
Definition: SkClipStack.h:130
const SkPath & getDeviceSpacePath() const
Call if getDeviceSpaceType() is kRRect to get the round-rect.
Definition: SkClipStack.h:108

◆ refShader()

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

Definition at line 127 of file SkClipStack.h.

127 {
128 return fShader;
129 }

Friends And Related Function Documentation

◆ SkClipStack

friend class SkClipStack
friend

Definition at line 193 of file SkClipStack.h.

Member Data Documentation

◆ kTypeCnt

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

Definition at line 67 of file SkClipStack.h.


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