OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDiscretePathEffect.h" | 10 #include "SkDiscretePathEffect.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 : fSegLength(segLength), fPerterb(deviation) | 24 : fSegLength(segLength), fPerterb(deviation) |
25 { | 25 { |
26 } | 26 } |
27 | 27 |
28 bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, | 28 bool SkDiscretePathEffect::filterPath(SkPath* dst, const SkPath& src, |
29 SkStrokeRec* rec, const SkRect*) const { | 29 SkStrokeRec* rec, const SkRect*) const { |
30 bool doFill = rec->isFillStyle(); | 30 bool doFill = rec->isFillStyle(); |
31 | 31 |
32 SkPathMeasure meas(src, doFill); | 32 SkPathMeasure meas(src, doFill); |
33 uint32_t seed = SkScalarRound(meas.getLength()); | 33 uint32_t seed = SkScalarRound(meas.getLength()); |
34 SkRandom rand(seed ^ ((seed << 16) | (seed >> 16))); | 34 SkLCGRandom rand(seed ^ ((seed << 16) | (seed >> 16))); |
35 SkScalar scale = fPerterb; | 35 SkScalar scale = fPerterb; |
36 SkPoint p; | 36 SkPoint p; |
37 SkVector v; | 37 SkVector v; |
38 | 38 |
39 do { | 39 do { |
40 SkScalar length = meas.getLength(); | 40 SkScalar length = meas.getLength(); |
41 | 41 |
42 if (fSegLength * (2 + doFill) > length) { | 42 if (fSegLength * (2 + doFill) > length) { |
43 meas.getSegment(0, length, dst, true); // to short for us to mangle | 43 meas.getSegment(0, length, dst, true); // to short for us to mangle |
44 } else { | 44 } else { |
(...skipping 28 matching lines...) Expand all Loading... |
73 void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { | 73 void SkDiscretePathEffect::flatten(SkFlattenableWriteBuffer& buffer) const { |
74 this->INHERITED::flatten(buffer); | 74 this->INHERITED::flatten(buffer); |
75 buffer.writeScalar(fSegLength); | 75 buffer.writeScalar(fSegLength); |
76 buffer.writeScalar(fPerterb); | 76 buffer.writeScalar(fPerterb); |
77 } | 77 } |
78 | 78 |
79 SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer) { | 79 SkDiscretePathEffect::SkDiscretePathEffect(SkFlattenableReadBuffer& buffer) { |
80 fSegLength = buffer.readScalar(); | 80 fSegLength = buffer.readScalar(); |
81 fPerterb = buffer.readScalar(); | 81 fPerterb = buffer.readScalar(); |
82 } | 82 } |
OLD | NEW |