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 virtual bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*)
const SK_OVERRIDE; | 17 bool filterPath(SkPath*, const SkPath&, SkStrokeRec*, const SkRect*) const S
K_OVERRIDE; |
18 | 18 |
19 protected: | 19 protected: |
20 /** New virtual, to be overridden by subclasses. | 20 /** New virtual, to be overridden by subclasses. |
21 This is called once from filterPath, and provides the | 21 This is called once from filterPath, and provides the |
22 uv parameter bounds for the path. Subsequent calls to | 22 uv parameter bounds for the path. Subsequent calls to |
23 next() will receive u and v values within these bounds, | 23 next() will receive u and v values within these bounds, |
24 and then a call to end() will signal the end of processing. | 24 and then a call to end() will signal the end of processing. |
25 */ | 25 */ |
26 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; | 26 virtual void begin(const SkIRect& uvBounds, SkPath* dst) const; |
27 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; | 27 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const; |
28 virtual void end(SkPath* dst) const; | 28 virtual void end(SkPath* dst) const; |
29 | 29 |
30 /** Low-level virtual called per span of locations in the u-direction. | 30 /** Low-level virtual called per span of locations in the u-direction. |
31 The default implementation calls next() repeatedly with each | 31 The default implementation calls next() repeatedly with each |
32 location. | 32 location. |
33 */ | 33 */ |
34 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; | 34 virtual void nextSpan(int u, int v, int ucount, SkPath* dst) const; |
35 | 35 |
36 const SkMatrix& getMatrix() const { return fMatrix; } | 36 const SkMatrix& getMatrix() const { return fMatrix; } |
37 | 37 |
38 // protected so that subclasses can call this during unflattening | 38 // protected so that subclasses can call this during unflattening |
39 explicit Sk2DPathEffect(const SkMatrix& mat); | 39 explicit Sk2DPathEffect(const SkMatrix& mat); |
40 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 40 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
41 | 41 |
42 private: | 42 private: |
43 SkMatrix fMatrix, fInverse; | 43 SkMatrix fMatrix, fInverse; |
44 bool fMatrixIsInvertible; | 44 bool fMatrixIsInvertible; |
45 | 45 |
46 // illegal | 46 // illegal |
47 Sk2DPathEffect(const Sk2DPathEffect&); | 47 Sk2DPathEffect(const Sk2DPathEffect&); |
48 Sk2DPathEffect& operator=(const Sk2DPathEffect&); | 48 Sk2DPathEffect& operator=(const Sk2DPathEffect&); |
49 | 49 |
50 friend class Sk2DPathEffectBlitter; | 50 friend class Sk2DPathEffectBlitter; |
51 typedef SkPathEffect INHERITED; | 51 typedef SkPathEffect INHERITED; |
52 }; | 52 }; |
53 | 53 |
54 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { | 54 class SK_API SkLine2DPathEffect : public Sk2DPathEffect { |
55 public: | 55 public: |
56 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { | 56 static SkLine2DPathEffect* Create(SkScalar width, const SkMatrix& matrix) { |
57 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); | 57 return SkNEW_ARGS(SkLine2DPathEffect, (width, matrix)); |
58 } | 58 } |
59 | 59 |
60 virtual bool filterPath(SkPath* dst, const SkPath& src, | 60 virtual bool filterPath(SkPath* dst, const SkPath& src, |
61 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; | 61 SkStrokeRec*, const SkRect*) const SK_OVERRIDE; |
62 | 62 |
63 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) | 63 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkLine2DPathEffect) |
64 | 64 |
65 protected: | 65 protected: |
66 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) | 66 SkLine2DPathEffect(SkScalar width, const SkMatrix& matrix) |
67 : Sk2DPathEffect(matrix), fWidth(width) {} | 67 : Sk2DPathEffect(matrix), fWidth(width) {} |
68 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 68 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
69 | 69 |
70 virtual void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; | 70 void nextSpan(int u, int v, int ucount, SkPath*) const SK_OVERRIDE; |
71 | 71 |
72 private: | 72 private: |
73 SkScalar fWidth; | 73 SkScalar fWidth; |
74 | 74 |
75 typedef Sk2DPathEffect INHERITED; | 75 typedef Sk2DPathEffect INHERITED; |
76 }; | 76 }; |
77 | 77 |
78 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { | 78 class SK_API SkPath2DPathEffect : public Sk2DPathEffect { |
79 public: | 79 public: |
80 /** | 80 /** |
81 * Stamp the specified path to fill the shape, using the matrix to define | 81 * Stamp the specified path to fill the shape, using the matrix to define |
82 * the latice. | 82 * the latice. |
83 */ | 83 */ |
84 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path
) { | 84 static SkPath2DPathEffect* Create(const SkMatrix& matrix, const SkPath& path
) { |
85 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); | 85 return SkNEW_ARGS(SkPath2DPathEffect, (matrix, path)); |
86 } | 86 } |
87 | 87 |
88 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) | 88 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkPath2DPathEffect) |
89 | 89 |
90 protected: | 90 protected: |
91 SkPath2DPathEffect(const SkMatrix&, const SkPath&); | 91 SkPath2DPathEffect(const SkMatrix&, const SkPath&); |
92 virtual void flatten(SkWriteBuffer&) const SK_OVERRIDE; | 92 void flatten(SkWriteBuffer&) const SK_OVERRIDE; |
93 | 93 |
94 virtual void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; | 94 void next(const SkPoint&, int u, int v, SkPath*) const SK_OVERRIDE; |
95 | 95 |
96 private: | 96 private: |
97 SkPath fPath; | 97 SkPath fPath; |
98 | 98 |
99 typedef Sk2DPathEffect INHERITED; | 99 typedef Sk2DPathEffect INHERITED; |
100 }; | 100 }; |
101 | 101 |
102 #endif | 102 #endif |
OLD | NEW |