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
|
|
|
|
|
2018-05-21 15:56:57 +00:00
|
|
|
#include "SkFlattenable.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#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);
|
|
|
|
|
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;
|
2018-08-16 17:22:16 +00:00
|
|
|
bool onFilterPath(SkPath* dst, const SkPath& src, SkStrokeRec*, const SkRect*) const override;
|
2014-02-20 20:40:19 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
private:
|
2018-10-18 21:27:16 +00:00
|
|
|
SK_FLATTENABLE_HOOKS(SkDiscretePathEffect)
|
2018-05-21 15:56:57 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
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
|