2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkDiscretePathEffect_DEFINED
|
|
|
|
#define SkDiscretePathEffect_DEFINED
|
|
|
|
|
|
|
|
#include "SkPathEffect.h"
|
|
|
|
|
|
|
|
/** \class SkDiscretePathEffect
|
|
|
|
|
|
|
|
This path effect chops a path into discrete segments, and randomly displaces them.
|
|
|
|
*/
|
2012-10-12 14:41:39 +00:00
|
|
|
class SK_API SkDiscretePathEffect : public SkPathEffect {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
/** Break the path into segments of segLength length, and randomly move the endpoints
|
|
|
|
away from the original path by a maximum of deviation.
|
|
|
|
Note: works on filled or framed paths
|
2014-06-13 05:55:08 +00:00
|
|
|
|
|
|
|
@param seedAssist This is a caller-supplied seedAssist that modifies
|
|
|
|
the seed value that is used to randomize the path
|
|
|
|
segments' endpoints. If not supplied it defaults to 0,
|
|
|
|
in which case filtering a path multiple times will
|
|
|
|
result in the same set of segments (this is useful for
|
|
|
|
testing). If a caller does not want this behaviour
|
|
|
|
they can pass in a different seedAssist to get a
|
|
|
|
different set of path segments.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-03-18 18:22:57 +00:00
|
|
|
static sk_sp<SkPathEffect> Make(SkScalar segLength, SkScalar dev, uint32_t seedAssist = 0);
|
|
|
|
|
2012-12-18 16:12:09 +00:00
|
|
|
virtual bool filterPath(SkPath* dst, const SkPath& src,
|
2015-03-26 01:17:31 +00:00
|
|
|
SkStrokeRec*, const SkRect*) const override;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-05-20 23:15:43 +00:00
|
|
|
void toString(SkString* str) const override;
|
2012-03-26 17:57:35 +00:00
|
|
|
SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect)
|
2011-06-21 19:24:00 +00:00
|
|
|
|
2015-03-05 16:01:07 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
2015-03-26 01:17:31 +00:00
|
|
|
bool exposedInAndroidJavaAPI() const override { return true; }
|
2015-03-05 16:01:07 +00:00
|
|
|
#endif
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
protected:
|
2014-06-13 05:55:08 +00:00
|
|
|
SkDiscretePathEffect(SkScalar segLength,
|
|
|
|
SkScalar deviation,
|
|
|
|
uint32_t seedAssist);
|
2015-03-26 01:17:31 +00:00
|
|
|
void flatten(SkWriteBuffer&) const override;
|
2014-02-20 20:40:19 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
|
|
|
SkScalar fSegLength, fPerterb;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2014-06-13 05:55:08 +00:00
|
|
|
/* Caller-supplied 32 bit seed assist */
|
|
|
|
uint32_t fSeedAssist;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
typedef SkPathEffect INHERITED;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|