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 #include "SkDashPathEffect.h" | 8 #include "SkDashPathEffect.h" |
9 | 9 |
10 #include "SkDashPathPriv.h" | 10 #include "SkDashPathPriv.h" |
11 #include "SkReadBuffer.h" | 11 #include "SkReadBuffer.h" |
12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
13 #include "SkStrokeRec.h" | 13 #include "SkStrokeRec.h" |
14 | 14 |
15 SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScal
ar phase) | 15 SkDashPathEffect::SkDashPathEffect(const SkScalar intervals[], int count, SkScal
ar phase) |
16 : fPhase(0) | 16 : fPhase(0) |
17 , fInitialDashLength(-1) | 17 , fInitialDashLength(-1) |
18 , fInitialDashIndex(0) | 18 , fInitialDashIndex(0) |
19 , fIntervalLength(0) { | 19 , fIntervalLength(0) { |
20 SkASSERT(intervals); | 20 SkASSERT(intervals); |
21 SkASSERT(count > 1 && SkAlign2(count) == count); | 21 SkASSERT(count > 1 && SkIsAlign2(count)); |
22 | 22 |
23 fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count); | 23 fIntervals = (SkScalar*)sk_malloc_throw(sizeof(SkScalar) * count); |
24 fCount = count; | 24 fCount = count; |
25 for (int i = 0; i < count; i++) { | 25 for (int i = 0; i < count; i++) { |
26 fIntervals[i] = intervals[i]; | 26 fIntervals[i] = intervals[i]; |
27 } | 27 } |
28 | 28 |
29 // set the internal data members | 29 // set the internal data members |
30 SkDashPath::CalcDashParameters(phase, fIntervals, fCount, | 30 SkDashPath::CalcDashParameters(phase, fIntervals, fCount, |
31 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength, &fPhase); | 31 &fInitialDashLength, &fInitialDashIndex, &fIntervalLength, &fPhase); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 #endif | 392 #endif |
393 | 393 |
394 ////////////////////////////////////////////////////////////////////////////////
////////////////// | 394 ////////////////////////////////////////////////////////////////////////////////
////////////////// |
395 | 395 |
396 sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count
, SkScalar phase) { | 396 sk_sp<SkPathEffect> SkDashPathEffect::Make(const SkScalar intervals[], int count
, SkScalar phase) { |
397 if (!SkDashPath::ValidDashPath(phase, intervals, count)) { | 397 if (!SkDashPath::ValidDashPath(phase, intervals, count)) { |
398 return nullptr; | 398 return nullptr; |
399 } | 399 } |
400 return sk_sp<SkPathEffect>(new SkDashPathEffect(intervals, count, phase)); | 400 return sk_sp<SkPathEffect>(new SkDashPathEffect(intervals, count, phase)); |
401 } | 401 } |
OLD | NEW |