Chromium Code Reviews| 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 #ifndef SkDashPathEffect_DEFINED | 8 #ifndef SkDashPathEffect_DEFINED |
| 9 #define SkDashPathEffect_DEFINED | 9 #define SkDashPathEffect_DEFINED |
| 10 | 10 |
| 11 #include "SkPathEffect.h" | 11 #include "SkPathEffect.h" |
| 12 | 12 |
| 13 /** \class SkDashPathEffect | 13 /** \class SkDashPathEffect |
| 14 | 14 |
| 15 SkDashPathEffect is a subclass of SkPathEffect that implements dashing | 15 SkDashPathEffect is a subclass of SkPathEffect that implements dashing |
| 16 */ | 16 */ |
| 17 class SK_API SkDashPathEffect : public SkPathEffect { | 17 class SK_API SkDashPathEffect : public SkPathEffect { |
| 18 public: | 18 public: |
| 19 static SkDashPathEffect* Create(const SkScalar intervals[], int count, | |
| 20 SkScalar phase, bool scaleToFit = false) { | |
| 21 return SkNEW_ARGS(SkDashPathEffect, (intervals, count, phase, scaleToFit )); | |
| 22 } | |
| 23 virtual ~SkDashPathEffect(); | |
| 24 | |
| 25 virtual bool filterPath(SkPath* dst, const SkPath& src, | |
| 26 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | |
| 27 | |
| 28 virtual bool asPoints(PointData* results, const SkPath& src, | |
| 29 const SkStrokeRec&, const SkMatrix&, | |
| 30 const SkRect*) const SK_OVERRIDE; | |
| 31 | |
| 32 virtual Factory getFactory() const SK_OVERRIDE; | |
| 33 | |
| 34 static SkFlattenable* CreateProc(SkReadBuffer&); | |
| 35 | |
| 36 protected: | |
| 37 SkDashPathEffect(SkReadBuffer&); | |
| 38 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | |
| 39 | |
| 40 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS | |
| 41 public: | |
| 42 #endif | |
| 19 /** intervals: array containing an even number of entries (>=2), with | 43 /** intervals: array containing an even number of entries (>=2), with |
|
scroggo
2014/02/18 16:53:11
Again, I think this comment belongs with the new f
Dominik Grewe
2014/02/18 17:05:30
Done.
| |
| 20 the even indices specifying the length of "on" intervals, and the odd | 44 the even indices specifying the length of "on" intervals, and the odd |
| 21 indices specifying the length of "off" intervals. | 45 indices specifying the length of "off" intervals. |
| 22 count: number of elements in the intervals array | 46 count: number of elements in the intervals array |
| 23 phase: offset into the intervals array (mod the sum of all of the | 47 phase: offset into the intervals array (mod the sum of all of the |
| 24 intervals). | 48 intervals). |
| 25 | 49 |
| 26 For example: if intervals[] = {10, 20}, count = 2, and phase = 25, | 50 For example: if intervals[] = {10, 20}, count = 2, and phase = 25, |
| 27 this will set up a dashed path like so: | 51 this will set up a dashed path like so: |
| 28 5 pixels off | 52 5 pixels off |
| 29 10 pixels on | 53 10 pixels on |
| 30 20 pixels off | 54 20 pixels off |
| 31 10 pixels on | 55 10 pixels on |
| 32 20 pixels off | 56 20 pixels off |
| 33 ... | 57 ... |
| 34 A phase of -5, 25, 55, 85, etc. would all result in the same path, | 58 A phase of -5, 25, 55, 85, etc. would all result in the same path, |
| 35 because the sum of all the intervals is 30. | 59 because the sum of all the intervals is 30. |
| 36 | 60 |
| 37 Note: only affects stroked paths. | 61 Note: only affects stroked paths. |
| 38 */ | 62 */ |
| 39 SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, | 63 SkDashPathEffect(const SkScalar intervals[], int count, SkScalar phase, |
| 40 bool scaleToFit = false); | 64 bool scaleToFit = false); |
| 41 virtual ~SkDashPathEffect(); | |
| 42 | |
| 43 virtual bool filterPath(SkPath* dst, const SkPath& src, | |
| 44 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | |
| 45 | |
| 46 virtual bool asPoints(PointData* results, const SkPath& src, | |
| 47 const SkStrokeRec&, const SkMatrix&, | |
| 48 const SkRect*) const SK_OVERRIDE; | |
| 49 | |
| 50 virtual Factory getFactory() const SK_OVERRIDE; | |
| 51 | |
| 52 static SkFlattenable* CreateProc(SkReadBuffer&); | |
| 53 | |
| 54 protected: | |
| 55 SkDashPathEffect(SkReadBuffer&); | |
| 56 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | |
| 57 | 65 |
| 58 private: | 66 private: |
| 59 SkScalar* fIntervals; | 67 SkScalar* fIntervals; |
| 60 int32_t fCount; | 68 int32_t fCount; |
| 61 // computed from phase | 69 // computed from phase |
| 62 SkScalar fInitialDashLength; | 70 SkScalar fInitialDashLength; |
| 63 int32_t fInitialDashIndex; | 71 int32_t fInitialDashIndex; |
| 64 SkScalar fIntervalLength; | 72 SkScalar fIntervalLength; |
| 65 bool fScaleToFit; | 73 bool fScaleToFit; |
| 66 | 74 |
| 67 typedef SkPathEffect INHERITED; | 75 typedef SkPathEffect INHERITED; |
| 68 }; | 76 }; |
| 69 | 77 |
| 70 #endif | 78 #endif |
| OLD | NEW |