Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: src/effects/SkDiscretePathEffect.cpp

Issue 311803002: Randomize seed for SkDiscretePathEffect::filterPath() (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: don't multiply seedAssist with seed, xor instead Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/effects/SkDiscretePathEffect.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkDiscretePathEffect.cpp
diff --git a/src/effects/SkDiscretePathEffect.cpp b/src/effects/SkDiscretePathEffect.cpp
index de834424df34fc661638fcbb7026bdc8214571a7..f6f91124479404330b1763370a51a70deb44f76d 100644
--- a/src/effects/SkDiscretePathEffect.cpp
+++ b/src/effects/SkDiscretePathEffect.cpp
@@ -20,9 +20,10 @@ static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) {
*p += normal;
}
-
-SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, SkScalar deviation)
- : fSegLength(segLength), fPerterb(deviation)
+SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength,
+ SkScalar deviation,
+ uint32_t seedAssist)
+ : fSegLength(segLength), fPerterb(deviation), fSeedAssist(seedAssist)
{
}
@@ -31,7 +32,10 @@ bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src,
bool doFill = rec->isFillStyle();
SkPathMeasure meas(src, doFill);
- uint32_t seed = SkScalarRoundToInt(meas.getLength());
+
+ /* Caller may supply their own seed assist, which by default is 0 */
+ uint32_t seed = fSeedAssist ^ SkScalarRoundToInt(meas.getLength());
+
SkLCGRandom rand(seed ^ ((seed << 16) | (seed >> 16)));
SkScalar scale = fPerterb;
SkPoint p;
@@ -75,9 +79,11 @@ void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const {
this->INHERITED::flatten(buffer);
buffer.writeScalar(fSegLength);
buffer.writeScalar(fPerterb);
+ buffer.writeUInt(fSeedAssist);
}
SkDiscretePathEffect::SkDiscretePathEffect(SkReadBuffer& buffer) {
fSegLength = buffer.readScalar();
fPerterb = buffer.readScalar();
+ fSeedAssist = buffer.readUInt();
}
« no previous file with comments | « include/effects/SkDiscretePathEffect.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698