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 | 8 |
9 #include "SkDiscretePathEffect.h" | 9 #include "SkDiscretePathEffect.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
12 #include "SkPathMeasure.h" | 12 #include "SkPathMeasure.h" |
13 #include "SkStrokeRec.h" | 13 #include "SkStrokeRec.h" |
14 | 14 |
15 sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar devi
ation, | 15 sk_sp<SkPathEffect> SkDiscretePathEffect::Make(SkScalar segLength, SkScalar devi
ation, |
16 uint32_t seedAssist) { | 16 uint32_t seedAssist) { |
| 17 if (!SkScalarIsFinite(segLength) || !SkScalarIsFinite(deviation)) { |
| 18 return nullptr; |
| 19 } |
| 20 if (segLength <= SK_ScalarNearlyZero) { |
| 21 return nullptr; |
| 22 } |
17 return sk_sp<SkPathEffect>(new SkDiscretePathEffect(segLength, deviation, se
edAssist)); | 23 return sk_sp<SkPathEffect>(new SkDiscretePathEffect(segLength, deviation, se
edAssist)); |
18 } | 24 } |
19 | 25 |
20 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { | 26 static void Perterb(SkPoint* p, const SkVector& tangent, SkScalar scale) { |
21 SkVector normal = tangent; | 27 SkVector normal = tangent; |
22 normal.rotateCCW(); | 28 normal.rotateCCW(); |
23 normal.setLength(scale); | 29 normal.setLength(scale); |
24 *p += normal; | 30 *p += normal; |
25 } | 31 } |
26 | 32 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 buffer.writeUInt(fSeedAssist); | 140 buffer.writeUInt(fSeedAssist); |
135 } | 141 } |
136 | 142 |
137 #ifndef SK_IGNORE_TO_STRING | 143 #ifndef SK_IGNORE_TO_STRING |
138 void SkDiscretePathEffect::toString(SkString* str) const { | 144 void SkDiscretePathEffect::toString(SkString* str) const { |
139 str->appendf("SkDiscretePathEffect: ("); | 145 str->appendf("SkDiscretePathEffect: ("); |
140 str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb
, fSeedAssist); | 146 str->appendf("segLength: %.2f deviation: %.2f seed %d", fSegLength, fPerterb
, fSeedAssist); |
141 str->append(")"); | 147 str->append(")"); |
142 } | 148 } |
143 #endif | 149 #endif |
OLD | NEW |