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" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkPathMeasure.h" | 13 #include "SkPathMeasure.h" |
14 #include "SkStrokeRec.h" | 14 #include "SkStrokeRec.h" |
15 | 15 |
16 sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar devi
ation, | |
17 uint32_t seedAssist) { | |
18 return sk_sp<SkPathEffect>(new SkDiscretePathEffect(segLength, deviation, se
edAssist)); | |
19 } | |
20 | |
21 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { | 16 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { |
22 SkVector normal = tangent; | 17 SkVector normal = tangent; |
23 normal.rotateCCW(); | 18 normal.rotateCCW(); |
24 normal.setLength(scale); | 19 normal.setLength(scale); |
25 *p += normal; | 20 *p += normal; |
26 } | 21 } |
27 | 22 |
28 SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, | 23 SkDiscretePathEffect::SkDiscretePathEffect(SkScalar segLength, |
29 SkScalar deviation, | 24 SkScalar deviation, |
30 uint32_t seedAssist) | 25 uint32_t seedAssist) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 } | 114 } |
120 } | 115 } |
121 } while (meas.nextContour()); | 116 } while (meas.nextContour()); |
122 return true; | 117 return true; |
123 } | 118 } |
124 | 119 |
125 SkFlattenable* SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) { | 120 SkFlattenable* SkDiscretePathEffect::CreateProc(SkReadBuffer& buffer) { |
126 SkScalar segLength = buffer.readScalar(); | 121 SkScalar segLength = buffer.readScalar(); |
127 SkScalar perterb = buffer.readScalar(); | 122 SkScalar perterb = buffer.readScalar(); |
128 uint32_t seed = buffer.readUInt(); | 123 uint32_t seed = buffer.readUInt(); |
129 return Make(segLength, perterb, seed).release(); | 124 return Create(segLength, perterb, seed); |
130 } | 125 } |
131 | 126 |
132 void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const { | 127 void SkDiscretePathEffect::flatten(SkWriteBuffer& buffer) const { |
133 buffer.writeScalar(fSegLength); | 128 buffer.writeScalar(fSegLength); |
134 buffer.writeScalar(fPerterb); | 129 buffer.writeScalar(fPerterb); |
135 buffer.writeUInt(fSeedAssist); | 130 buffer.writeUInt(fSeedAssist); |
136 } | 131 } |
137 | 132 |
138 #ifndef SK_IGNORE_TO_STRING | 133 #ifndef SK_IGNORE_TO_STRING |
139 void SkDiscretePathEffect::toString(SkString* str) const { | 134 void SkDiscretePathEffect::toString(SkString* str) const { |
140 str->appendf("SkDiscretePathEffect: ("); | 135 str->appendf("SkDiscretePathEffect: ("); |
141 str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb
, fSeedAssist); | 136 str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb
, fSeedAssist); |
142 str->append(")"); | 137 str->append(")"); |
143 } | 138 } |
144 #endif | 139 #endif |
OLD | NEW |