Chromium Code Reviews| Index: src/effects/SkDiscretePathEffect.cpp |
| diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp |
| index de834424df34fc661638fcbb7026bdc8214571a7..8423842ed147df79632b1e48deec48e1aa3d9c68 100644 |
| --- a/src/effects/SkDiscretePathEffect.cpp |
| +++ b/src/effects/SkDiscretePathEffect.cpp |
| @@ -12,6 +12,7 @@ |
| #include "SkWriteBuffer.h" |
| #include "SkPathMeasure.h" |
| #include "SkRandom.h" |
| +#include "SkTime.h" |
|
scroggo
2014/06/05 16:09:30
Not used. Please remove.
rs.prinja
2014/06/07 10:46:05
Done.
|
| static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { |
| SkVector normal = tangent; |
| @@ -20,10 +21,12 @@ static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { |
| *p += normal; |
| } |
| +uint32_t SkDiscretePathEffect::fObjectIdGenerator = 0; |
| -SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, SkScalar deviation) |
| - : fSegLength(segLength), fPerterb(deviation) |
| +SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, SkScalar deviation, uint32_t seedAssist) |
|
scroggo
2014/06/05 16:09:30
Over 100 chars.
rs.prinja
2014/06/07 10:46:05
Done.
|
| + : fSegLength(segLength), fPerterb(deviation), fSeedAssist(seedAssist) |
| { |
| + fObjectId = fObjectIdGenerator++; |
| } |
| bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, |
| @@ -31,7 +34,17 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, |
| bool doFill = rec->isFillStyle(); |
| SkPathMeasure meas(src, doFill); |
| - uint32_t seed = SkScalarRoundToInt(meas.getLength()); |
| + |
| + /* We want to have identical seeds for identical paths that share the same effect object |
| + * but different seeds for identical paths that use different effect objects */ |
| + uint32_t seed = fObjectId + SkScalarRoundToInt(meas.getLength()); |
|
scroggo
2014/06/05 16:09:30
As stated elsewhere, please just use the length an
rs.prinja
2014/06/07 10:46:05
Done.
|
| + |
| + /* Also, across different runs of the same program, the same path should be seeded differently */ |
| + seed += SkTime::GetMSecs() / 1000; |
|
scroggo
2014/06/05 16:09:30
Please remove.
rs.prinja
2014/06/07 10:46:05
Done.
|
| + |
| + /* Caller may supply their own seed assist, which by default is 1 */ |
| + seed *= fSeedAssist; |
| + |
| SkLCGRandom rand(seed ^ ((seed << 16) | (seed >> 16))); |
| SkScalar scale = fPerterb; |
| SkPoint p; |