Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkDiscretePathEffectImpl Class Reference
Inheritance diagram for SkDiscretePathEffectImpl:
SkPathEffectBase SkPathEffect SkFlattenable SkRefCnt SkRefCntBase

Public Member Functions

 SkDiscretePathEffectImpl (SkScalar segLength, SkScalar deviation, uint32_t seedAssist)
 
bool onFilterPath (SkPath *dst, const SkPath &src, SkStrokeRec *rec, const SkRect *, const SkMatrix &) const override
 
bool computeFastBounds (SkRect *bounds) 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 onFilterPath (SkPath *, const SkPath &, SkStrokeRec *, const SkRect *, const SkMatrix &) const =0
 
virtual bool onNeedsCTM () const
 
virtual bool onAsPoints (PointData *, const SkPath &, const SkStrokeRec &, const SkMatrix &, const SkRect *) const
 
virtual DashType onAsADash (DashInfo *) const
 
virtual bool computeFastBounds (SkRect *bounds) const =0
 
- 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 ()
 
virtual Factory getFactory () const =0
 
virtual const char * getTypeName () const =0
 
virtual void flatten (SkWriteBuffer &) const
 
virtual Type getFlattenableType () const =0
 
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 79 of file SkDiscretePathEffect.cpp.

Constructor & Destructor Documentation

◆ SkDiscretePathEffectImpl()

SkDiscretePathEffectImpl::SkDiscretePathEffectImpl ( SkScalar  segLength,
SkScalar  deviation,
uint32_t  seedAssist 
)
inline

Definition at line 81 of file SkDiscretePathEffect.cpp.

82 : fSegLength(segLength), fPerterb(deviation), fSeedAssist(seedAssist)
83 {
84 SkASSERT(SkIsFinite(segLength));
85 SkASSERT(SkIsFinite(deviation));
86 SkASSERT(segLength > SK_ScalarNearlyZero);
87 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool SkIsFinite(T x, Pack... values)
#define SK_ScalarNearlyZero
Definition: SkScalar.h:99

Member Function Documentation

◆ computeFastBounds()

bool SkDiscretePathEffectImpl::computeFastBounds ( SkRect bounds) const
inlineoverridevirtual

Implements SkPathEffectBase.

Definition at line 144 of file SkDiscretePathEffect.cpp.

144 {
145 if (bounds) {
146 SkScalar maxOutset = SkScalarAbs(fPerterb);
147 bounds->outset(maxOutset, maxOutset);
148 }
149 return true;
150 }
#define SkScalarAbs(x)
Definition: SkScalar.h:39
float SkScalar
Definition: extension.cpp:12
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ CreateProc()

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

Definition at line 152 of file SkDiscretePathEffect.cpp.

152 {
153 SkScalar segLength = buffer.readScalar();
154 SkScalar perterb = buffer.readScalar();
155 uint32_t seed = buffer.readUInt();
156 return SkDiscretePathEffect::Make(segLength, perterb, seed);
157 }
static sk_sp< SkPathEffect > Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist=0)
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 to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ flatten()

void SkDiscretePathEffectImpl::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 159 of file SkDiscretePathEffect.cpp.

159 {
160 buffer.writeScalar(fSegLength);
161 buffer.writeScalar(fPerterb);
162 buffer.writeUInt(fSeedAssist);
163 }

◆ getFactory()

Factory SkDiscretePathEffectImpl::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 165 of file SkDiscretePathEffect.cpp.

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

◆ getTypeName()

const char * SkDiscretePathEffectImpl::getTypeName ( ) const
inlineoverridevirtual

Returns the name of the object's class.

Implements SkFlattenable.

Definition at line 166 of file SkDiscretePathEffect.cpp.

166{ return "SkDiscretePathEffect"; }

◆ onFilterPath()

bool SkDiscretePathEffectImpl::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 89 of file SkDiscretePathEffect.cpp.

90 {
91 bool doFill = rec->isFillStyle();
92
93 SkPathMeasure meas(src, doFill);
94
95 /* Caller may supply their own seed assist, which by default is 0 */
96 uint32_t seed = fSeedAssist ^ SkScalarRoundToInt(meas.getLength());
97
98 LCGRandom rand(seed ^ ((seed << 16) | (seed >> 16)));
99 SkScalar scale = fPerterb;
100 SkPoint p;
101 SkVector v;
102
103 do {
104 SkScalar length = meas.getLength();
105 #if defined(SK_BUILD_FOR_FUZZER)
106 if (length > 1000) {
107 return false;
108 }
109 #endif
110
111 if (fSegLength * (2 + doFill) > length) {
112 meas.getSegment(0, length, dst, true); // to short for us to mangle
113 } else {
114 int n = SkScalarRoundToInt(length / fSegLength);
115 constexpr int kMaxReasonableIterations = 100000;
116 n = std::min(n, kMaxReasonableIterations);
117 SkScalar delta = length / n;
118 SkScalar distance = 0;
119
120 if (meas.isClosed()) {
121 n -= 1;
122 distance += delta/2;
123 }
124
125 if (meas.getPosTan(distance, &p, &v)) {
126 Perterb(&p, v, rand.nextSScalar1() * scale);
127 dst->moveTo(p);
128 }
129 while (--n >= 0) {
130 distance += delta;
131 if (meas.getPosTan(distance, &p, &v)) {
132 Perterb(&p, v, rand.nextSScalar1() * scale);
133 dst->lineTo(p);
134 }
135 }
136 if (meas.isClosed()) {
137 dst->close();
138 }
139 }
140 } while (meas.nextContour());
141 return true;
142 }
static void Perterb(SkPoint *p, const SkVector &tangent, SkScalar scale)
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
static float min(float r, float g, float b)
Definition: hsl.cpp:48
size_t length
dst
Definition: cp.py:12
const Scalar scale

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