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 Sk2DPathEffect_DEFINED | 8 #ifndef Sk2DPathEffect_DEFINED |
9 #define Sk2DPathEffect_DEFINED | 9 #define Sk2DPathEffect_DEFINED |
10 | 10 |
11 #include "SkPath.h" | 11 #include "SkPath.h" |
12 #include "SkPathEffect.h" | 12 #include "SkPathEffect.h" |
13 #include "SkMatrix.h" | 13 #include "SkMatrix.h" |
14 | 14 |
15 class SK_API Sk2DPathEffect : public SkPathEffect { | 15 class SK_API Sk2DPathEffect : public SkPathEffect { |
16 public: | 16 public: |
17 Sk2DPathEffect(const SkMatrix& mat); | 17 static Sk2DPathEffect* Create(const SkMatrix& mat) { |
| 18 return SkNEW_ARGS(Sk2DPathEffect, (mat)); |
| 19 } |
18 | 20 |
19 virtual bool filterPath(SkPath*, const SkPath&, | 21 virtual bool filterPath(SkPath*, const SkPath&, |
20 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 22 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
21 | 23 |
22 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) | 24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) |
23 | 25 |
24 protected: | 26 protected: |
| 27 Sk2DPathEffect(const SkMatrix& mat); |
| 28 |
25 /** New virtual, to be overridden by subclasses. | 29 /** New virtual, to be overridden by subclasses. |
26 This is called once from filterPath, and provides the | 30 This is called once from filterPath, and provides the |
27 uv parameter bounds for the path. Subsequent calls to | 31 uv parameter bounds for the path. Subsequent calls to |
28 next() will receive u and v values within these bounds, | 32 next() will receive u and v values within these bounds, |
29 and then a call to end() will signal the end of processing. | 33 and then a call to end() will signal the end of processing. |
30 */ | 34 */ |
31 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; | 35 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; |
32 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; | 36 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; |
33 virtual void end(SkPath* dst) const; | 37 virtual void end(SkPath* dst) const; |
34 | 38 |
(...skipping 16 matching lines...) Expand all Loading... |
51 // illegal | 55 // illegal |
52 Sk2DPathEffect(const Sk2DPathEffect&); | 56 Sk2DPathEffect(const Sk2DPathEffect&); |
53 Sk2DPathEffect& operator=(const Sk2DPathEffect&); | 57 Sk2DPathEffect& operator=(const Sk2DPathEffect&); |
54 | 58 |
55 friend class Sk2DPathEffectBlitter; | 59 friend class Sk2DPathEffectBlitter; |
56 typedef SkPathEffect INHERITED; | 60 typedef SkPathEffect INHERITED; |
57 }; | 61 }; |
58 | 62 |
59 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { | 63 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { |
60 public: | 64 public: |
61 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) | 65 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { |
62 : Sk2DPathEffect(matrix), fWidth(width) {} | 66 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); |
| 67 } |
63 | 68 |
64 virtual bool filterPath(SkPath* dst, const SkPath& src, | 69 virtual bool filterPath(SkPath* dst, const SkPath& src, |
65 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 70 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
66 | 71 |
67 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) | 72 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) |
68 | 73 |
69 protected: | 74 protected: |
| 75 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) |
| 76 : Sk2DPathEffect(matrix), fWidth(width) {} |
| 77 |
70 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; | 78 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; |
71 | 79 |
72 SkLine2DPathEffect(SkReadBuffer&); | 80 SkLine2DPathEffect(SkReadBuffer&); |
73 | 81 |
74 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 82 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
75 | 83 |
76 private: | 84 private: |
77 SkScalar fWidth; | 85 SkScalar fWidth; |
78 | 86 |
79 typedef Sk2DPathEffect INHERITED; | 87 typedef Sk2DPathEffect INHERITED; |
80 }; | 88 }; |
81 | 89 |
82 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { | 90 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { |
83 public: | 91 public: |
84 /** | 92 /** |
85 * Stamp the specified path to fill the shape, using the matrix to define | 93 * Stamp the specified path to fill the shape, using the matrix to define |
86 * the latice. | 94 * the latice. |
87 */ | 95 */ |
88 SkPath2DPathEffect(const SkMatrix&, const SkPath&); | 96 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path
) { |
| 97 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); |
| 98 } |
89 | 99 |
90 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) | 100 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) |
91 | 101 |
92 protected: | 102 protected: |
| 103 SkPath2DPathEffect(const SkMatrix&, const SkPath&); |
93 SkPath2DPathEffect(SkReadBuffer& buffer); | 104 SkPath2DPathEffect(SkReadBuffer& buffer); |
94 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 105 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
95 | 106 |
96 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; | 107 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; |
97 | 108 |
98 private: | 109 private: |
99 SkPath fPath; | 110 SkPath fPath; |
100 | 111 |
101 typedef Sk2DPathEffect INHERITED; | 112 typedef Sk2DPathEffect INHERITED; |
102 }; | 113 }; |
103 | 114 |
104 #endif | 115 #endif |
OLD | NEW |