Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
SkCornerPathEffectImpl Class Reference
Inheritance diagram for SkCornerPathEffectImpl:
SkPathEffectBase SkPathEffect SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkCornerPathEffectImpl (SkScalar radius)
 
bool onFilterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *, const SkMatrix &) const override
 
bool computeFastBounds (SkRect *) const override
 
void flatten (SkWriteBuffer &buffer) const override
 
Factory getFactory () const override
 
const char * getTypeName () const override
 
- Public Member Functions inherited from SkPathEffectBase
 SkPathEffectBase ()
 
bool asPoints (PointData *results, const SkPath &src, const SkStrokeRec &, const SkMatrix &, const SkRect *cullR) const
 
SkFlattenable::Type getFlattenableType () const override
 
virtual bool onNeedsCTM () const
 
virtual bool onAsPoints (PointData *, const SkPath &, const SkStrokeRec &, const SkMatrix &, const SkRect *) const
 
virtual DashType onAsADash (DashInfo *) const
 
- Public Member Functions inherited from SkPathEffect
DashType asADash (DashInfo *info) const
 
bool filterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR) const
 
bool filterPath (SkPath *dst, const SkPath &src, SkStrokeRec *, const SkRect *cullR, const SkMatrix &ctm) const
 
bool needsCTM () const
 
- Public Member Functions inherited from SkFlattenable
 SkFlattenable ()
 
sk_sp< SkDataserialize (const SkSerialProcs *=nullptr) const
 
size_t serialize (void *memory, size_t memory_size, const SkSerialProcs *=nullptr) const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static sk_sp< SkFlattenableCreateProc (SkReadBuffer &buffer)
 
- Static Public Member Functions inherited from SkPathEffectBase
static sk_sp< SkPathEffectDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
static void RegisterFlattenables ()
 
- Static Public Member Functions inherited from SkPathEffect
static sk_sp< SkPathEffectMakeSum (sk_sp< SkPathEffect > first, sk_sp< SkPathEffect > second)
 
static sk_sp< SkPathEffectMakeCompose (sk_sp< SkPathEffect > outer, sk_sp< SkPathEffect > inner)
 
static SkFlattenable::Type GetFlattenableType ()
 
static sk_sp< SkPathEffectDeserialize (const void *data, size_t size, const SkDeserialProcs *procs=nullptr)
 
- Static Public Member Functions inherited from SkFlattenable
static Factory NameToFactory (const char name[])
 
static const char * FactoryToName (Factory)
 
static void Register (const char name[], Factory)
 
static sk_sp< SkFlattenableDeserialize (Type, const void *data, size_t length, const SkDeserialProcs *procs=nullptr)
 

Additional Inherited Members

- Public Types inherited from SkPathEffect
enum  DashType { kNone_DashType , kDash_DashType }
 
- Public Types inherited from SkFlattenable
enum  Type {
  kSkColorFilter_Type , kSkBlender_Type , kSkDrawable_Type , kSkDrawLooper_Type ,
  kSkImageFilter_Type , kSkMaskFilter_Type , kSkPathEffect_Type , kSkShader_Type
}
 
typedef sk_sp< SkFlattenable >(* Factory) (SkReadBuffer &)
 

Detailed Description

Definition at line 40 of file SkCornerPathEffect.cpp.

Constructor & Destructor Documentation

◆ SkCornerPathEffectImpl()

SkCornerPathEffectImpl::SkCornerPathEffectImpl ( SkScalar  radius)
inlineexplicit

Definition at line 42 of file SkCornerPathEffect.cpp.

42 : fRadius(radius) {
43 SkASSERT(radius > 0);
44 }
#define SkASSERT(cond)
Definition SkAssert.h:116

Member Function Documentation

◆ computeFastBounds()

bool SkCornerPathEffectImpl::computeFastBounds ( SkRect ) const
inlineoverridevirtual

Implements SkPathEffectBase.

Definition at line 156 of file SkCornerPathEffect.cpp.

156 {
157 // Rounding sharp corners within a path produces a new path that is still contained within
158 // the original's bounds, so leave 'bounds' unmodified.
159 return true;
160 }

◆ CreateProc()

static sk_sp< SkFlattenable > SkCornerPathEffectImpl::CreateProc ( SkReadBuffer buffer)
inlinestatic

Definition at line 162 of file SkCornerPathEffect.cpp.

162 {
163 return SkCornerPathEffect::Make(buffer.readScalar());
164 }
static sk_sp< SkPathEffect > Make(SkScalar radius)
static const uint8_t buffer[]

◆ flatten()

void SkCornerPathEffectImpl::flatten ( SkWriteBuffer ) const
inlineoverridevirtual

Override this if your subclass needs to record data that it will need to recreate itself from its CreateProc (returned by getFactory()).

DEPRECATED public : will move to protected ... use serialize() instead

Reimplemented from SkFlattenable.

Definition at line 166 of file SkCornerPathEffect.cpp.

166 {
167 buffer.writeScalar(fRadius);
168 }

◆ getFactory()

Factory SkCornerPathEffectImpl::getFactory ( ) const
inlineoverridevirtual

Implement this to return a factory function pointer that can be called to recreate your class given a buffer (previously written to by your override of flatten().

Implements SkFlattenable.

Definition at line 170 of file SkCornerPathEffect.cpp.

170{ return CreateProc; }
static sk_sp< SkFlattenable > CreateProc(SkReadBuffer &buffer)

◆ getTypeName()

const char * SkCornerPathEffectImpl::getTypeName ( ) const
inlineoverridevirtual

Returns the name of the object's class.

Implements SkFlattenable.

Definition at line 171 of file SkCornerPathEffect.cpp.

171{ return "SkCornerPathEffect"; }

◆ onFilterPath()

bool SkCornerPathEffectImpl::onFilterPath ( SkPath ,
const SkPath ,
SkStrokeRec ,
const SkRect ,
const SkMatrix  
) const
inlineoverridevirtual

Filter the input path.

The CTM parameter is provided for path effects that can use the information. The output of path effects must always be in the original (input) coordinate system, regardless of whether the path effect uses the CTM or not.

Implements SkPathEffectBase.

Definition at line 46 of file SkCornerPathEffect.cpp.

47 {
48 if (fRadius <= 0) {
49 return false;
50 }
51
52 SkPath::Iter iter(src, false);
53 SkPath::Verb verb, prevVerb = SkPath::kDone_Verb;
54 SkPoint pts[4];
55
56 bool closed;
57 SkPoint moveTo, lastCorner;
58 SkVector firstStep, step;
59 bool prevIsValid = true;
60
61 // to avoid warnings
62 step.set(0, 0);
63 moveTo.set(0, 0);
64 firstStep.set(0, 0);
65 lastCorner.set(0, 0);
66
67 for (;;) {
68 switch (verb = iter.next(pts)) {
70 // close out the previous (open) contour
71 if (SkPath::kLine_Verb == prevVerb) {
72 dst->lineTo(lastCorner);
73 }
74 closed = iter.isClosedContour();
75 if (closed) {
76 moveTo = pts[0];
77 prevIsValid = false;
78 } else {
79 dst->moveTo(pts[0]);
80 prevIsValid = true;
81 }
82 break;
83 case SkPath::kLine_Verb: {
84 bool drawSegment = ComputeStep(pts[0], pts[1], fRadius, &step);
85 // prev corner
86 if (!prevIsValid) {
87 dst->moveTo(moveTo + step);
88 prevIsValid = true;
89 } else {
90 dst->quadTo(pts[0].fX, pts[0].fY, pts[0].fX + step.fX,
91 pts[0].fY + step.fY);
92 }
93 if (drawSegment) {
94 dst->lineTo(pts[1].fX - step.fX, pts[1].fY - step.fY);
95 }
96 lastCorner = pts[1];
97 prevIsValid = true;
98 break;
99 }
101 // TBD - just replicate the curve for now
102 if (!prevIsValid) {
103 dst->moveTo(pts[0]);
104 prevIsValid = true;
105 }
106 dst->quadTo(pts[1], pts[2]);
107 lastCorner = pts[2];
108 firstStep.set(0, 0);
109 break;
111 // TBD - just replicate the curve for now
112 if (!prevIsValid) {
113 dst->moveTo(pts[0]);
114 prevIsValid = true;
115 }
116 dst->conicTo(pts[1], pts[2], iter.conicWeight());
117 lastCorner = pts[2];
118 firstStep.set(0, 0);
119 break;
121 if (!prevIsValid) {
122 dst->moveTo(pts[0]);
123 prevIsValid = true;
124 }
125 // TBD - just replicate the curve for now
126 dst->cubicTo(pts[1], pts[2], pts[3]);
127 lastCorner = pts[3];
128 firstStep.set(0, 0);
129 break;
131 if (firstStep.fX || firstStep.fY) {
132 dst->quadTo(lastCorner.fX, lastCorner.fY,
133 lastCorner.fX + firstStep.fX,
134 lastCorner.fY + firstStep.fY);
135 }
136 dst->close();
137 prevIsValid = false;
138 break;
140 if (prevIsValid) {
141 dst->lineTo(lastCorner);
142 }
143 return true;
144 default:
145 SkDEBUGFAIL("default should not be reached");
146 return false;
147 }
148
149 if (SkPath::kMove_Verb == prevVerb) {
150 firstStep = step;
151 }
152 prevVerb = verb;
153 }
154 }
static int step(int x, SkScalar min, SkScalar max)
Definition BlurTest.cpp:215
#define SkDEBUGFAIL(message)
Definition SkAssert.h:118
static bool ComputeStep(const SkPoint &a, const SkPoint &b, SkScalar radius, SkPoint *step)
@ kClose_Verb
Definition SkPath.h:1463
@ kMove_Verb
Definition SkPath.h:1458
@ kConic_Verb
Definition SkPath.h:1461
@ kDone_Verb
Definition SkPath.h:1464
@ kCubic_Verb
Definition SkPath.h:1462
@ kQuad_Verb
Definition SkPath.h:1460
@ kLine_Verb
Definition SkPath.h:1459
dst
Definition cp.py:12
float fX
x-axis value
void set(float x, float y)
float fY
y-axis value

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