|
1 /* |
|
2 * Copyright 2006 The Android Open Source Project |
|
3 * |
|
4 * Use of this source code is governed by a BSD-style license that can be |
|
5 * found in the LICENSE file. |
|
6 */ |
|
7 |
|
8 #ifndef Sk2DPathEffect_DEFINED |
|
9 #define Sk2DPathEffect_DEFINED |
|
10 |
|
11 #include "SkPath.h" |
|
12 #include "SkPathEffect.h" |
|
13 #include "SkMatrix.h" |
|
14 |
|
15 class SK_API Sk2DPathEffect : public SkPathEffect { |
|
16 public: |
|
17 static Sk2DPathEffect* Create(const SkMatrix& mat) { |
|
18 return SkNEW_ARGS(Sk2DPathEffect, (mat)); |
|
19 } |
|
20 |
|
21 virtual bool filterPath(SkPath*, const SkPath&, |
|
22 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
|
23 |
|
24 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(Sk2DPathEffect) |
|
25 |
|
26 protected: |
|
27 /** New virtual, to be overridden by subclasses. |
|
28 This is called once from filterPath, and provides the |
|
29 uv parameter bounds for the path. Subsequent calls to |
|
30 next() will receive u and v values within these bounds, |
|
31 and then a call to end() will signal the end of processing. |
|
32 */ |
|
33 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; |
|
34 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; |
|
35 virtual void end(SkPath* dst) const; |
|
36 |
|
37 /** Low-level virtual called per span of locations in the u-direction. |
|
38 The default implementation calls next() repeatedly with each |
|
39 location. |
|
40 */ |
|
41 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; |
|
42 |
|
43 const SkMatrix& getMatrix() const { return fMatrix; } |
|
44 |
|
45 // protected so that subclasses can call this during unflattening |
|
46 Sk2DPathEffect(SkReadBuffer&); |
|
47 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
|
48 |
|
49 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
|
50 public: |
|
51 #endif |
|
52 Sk2DPathEffect(const SkMatrix& mat); |
|
53 |
|
54 private: |
|
55 SkMatrix fMatrix, fInverse; |
|
56 bool fMatrixIsInvertible; |
|
57 |
|
58 // illegal |
|
59 Sk2DPathEffect(const Sk2DPathEffect&); |
|
60 Sk2DPathEffect& operator=(const Sk2DPathEffect&); |
|
61 |
|
62 friend class Sk2DPathEffectBlitter; |
|
63 typedef SkPathEffect INHERITED; |
|
64 }; |
|
65 |
|
66 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { |
|
67 public: |
|
68 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { |
|
69 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); |
|
70 } |
|
71 |
|
72 virtual bool filterPath(SkPath* dst, const SkPath& src, |
|
73 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
|
74 |
|
75 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) |
|
76 |
|
77 protected: |
|
78 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; |
|
79 |
|
80 SkLine2DPathEffect(SkReadBuffer&); |
|
81 |
|
82 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
|
83 |
|
84 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
|
85 public: |
|
86 #endif |
|
87 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) |
|
88 : Sk2DPathEffect(matrix), fWidth(width) {} |
|
89 |
|
90 private: |
|
91 SkScalar fWidth; |
|
92 |
|
93 typedef Sk2DPathEffect INHERITED; |
|
94 }; |
|
95 |
|
96 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { |
|
97 public: |
|
98 /** |
|
99 * Stamp the specified path to fill the shape, using the matrix to define |
|
100 * the latice. |
|
101 */ |
|
102 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path) { |
|
103 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); |
|
104 } |
|
105 |
|
106 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) |
|
107 |
|
108 protected: |
|
109 SkPath2DPathEffect(SkReadBuffer& buffer); |
|
110 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
|
111 |
|
112 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; |
|
113 |
|
114 #ifdef SK_SUPPORT_LEGACY_PUBLICEFFECTCONSTRUCTORS |
|
115 public: |
|
116 #endif |
|
117 SkPath2DPathEffect(const SkMatrix&, const SkPath&); |
|
118 |
|
119 private: |
|
120 SkPath fPath; |
|
121 |
|
122 typedef Sk2DPathEffect INHERITED; |
|
123 }; |
|
124 |
|
125 #endif |