| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkDiscretePathEffect_DEFINED | 8 #ifndef SkDiscretePathEffect_DEFINED |
| 9 #define SkDiscretePathEffect_DEFINED | 9 #define SkDiscretePathEffect_DEFINED |
| 10 | 10 |
| 11 #include "SkPathEffect.h" | 11 #include "SkPathEffect.h" |
| 12 | 12 |
| 13 /** \class SkDiscretePathEffect | 13 /** \class SkDiscretePathEffect |
| 14 | 14 |
| 15 This path effect chops a path into discrete segments, and randomly displaces
them. | 15 This path effect chops a path into discrete segments, and randomly displaces
them. |
| 16 */ | 16 */ |
| 17 class SK_API SkDiscretePathEffect : public SkPathEffect { | 17 class SK_API SkDiscretePathEffect : public SkPathEffect { |
| 18 public: | 18 public: |
| 19 /** Break the path into segments of segLength length, and randomly move the
endpoints | 19 /** Break the path into segments of segLength length, and randomly move the
endpoints |
| 20 away from the original path by a maximum of deviation. | 20 away from the original path by a maximum of deviation. |
| 21 Note: works on filled or framed paths | 21 Note: works on filled or framed paths |
| 22 |
| 23 @param seedAssist This is a caller-supplied seedAssist that modifies |
| 24 the seed value that is used to randomize the path |
| 25 segments' endpoints. If not supplied it defaults to 0, |
| 26 in which case filtering a path multiple times will |
| 27 result in the same set of segments (this is useful for |
| 28 testing). If a caller does not want this behaviour |
| 29 they can pass in a different seedAssist to get a |
| 30 different set of path segments. |
| 22 */ | 31 */ |
| 23 static SkDiscretePathEffect* Create(SkScalar segLength, SkScalar deviation)
{ | 32 static SkDiscretePathEffect* Create(SkScalar segLength, |
| 24 return SkNEW_ARGS(SkDiscretePathEffect, (segLength, deviation)); | 33 SkScalar deviation, |
| 34 uint32_t seedAssist=0) { |
| 35 return SkNEW_ARGS(SkDiscretePathEffect, |
| 36 (segLength, deviation, seedAssist)); |
| 25 } | 37 } |
| 26 | 38 |
| 27 virtual bool filterPath(SkPath* dst, const SkPath& src, | 39 virtual bool filterPath(SkPath* dst, const SkPath& src, |
| 28 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 40 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
| 29 | 41 |
| 30 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect) | 42 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkDiscretePathEffect) |
| 31 | 43 |
| 32 protected: | 44 protected: |
| 33 SkDiscretePathEffect(SkScalar segLength, SkScalar deviation); | 45 SkDiscretePathEffect(SkScalar segLength, |
| 46 SkScalar deviation, |
| 47 uint32_t seedAssist); |
| 34 explicit SkDiscretePathEffect(SkReadBuffer&); | 48 explicit SkDiscretePathEffect(SkReadBuffer&); |
| 35 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 49 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
| 36 | 50 |
| 37 private: | 51 private: |
| 38 SkScalar fSegLength, fPerterb; | 52 SkScalar fSegLength, fPerterb; |
| 39 | 53 |
| 54 /* Caller-supplied 32 bit seed assist */ |
| 55 uint32_t fSeedAssist; |
| 56 |
| 40 typedef SkPathEffect INHERITED; | 57 typedef SkPathEffect INHERITED; |
| 41 }; | 58 }; |
| 42 | 59 |
| 43 #endif | 60 #endif |
| OLD | NEW |