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 "SkDrawExtraPathEffect.h" | 8 #include "SkDrawExtraPathEffect.h" |
9 #include "SkDrawPath.h" | 9 #include "SkDrawPath.h" |
10 #include "Sk1DPathEffect.h" | 10 #include "Sk1DPathEffect.h" |
11 #include "Sk2DPathEffect.h" | 11 #include "Sk2DPathEffect.h" |
12 #include "SkMemberInfo.h" | 12 #include "SkMemberInfo.h" |
13 #include "SkPaintPart.h" | 13 #include "SkPaintPart.h" |
14 #include "SkPathEffect.h" | 14 #include "SkPathEffect.h" |
15 #include "SkCornerPathEffect.h" | 15 #include "SkCornerPathEffect.h" |
16 | 16 |
17 #include "SkDashPathEffect.h" | 17 #include "SkDashPathEffect.h" |
18 | 18 |
19 class SkDrawShapePathEffect : public SkDrawPathEffect { | 19 class SkDrawShapePathEffect : public SkDrawPathEffect { |
20 DECLARE_PRIVATE_MEMBER_INFO(DrawShapePathEffect); | 20 DECLARE_PRIVATE_MEMBER_INFO(DrawShapePathEffect); |
21 SkDrawShapePathEffect(); | 21 SkDrawShapePathEffect(); |
22 virtual ~SkDrawShapePathEffect(); | 22 virtual ~SkDrawShapePathEffect(); |
23 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; | 23 bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; |
24 virtual SkPathEffect* getPathEffect() SK_OVERRIDE; | 24 SkPathEffect* getPathEffect() SK_OVERRIDE; |
25 protected: | 25 protected: |
26 SkADrawable* addPath; | 26 SkADrawable* addPath; |
27 SkADrawable* addMatrix; | 27 SkADrawable* addMatrix; |
28 SkDrawPath* path; | 28 SkDrawPath* path; |
29 SkPathEffect* fPathEffect; | 29 SkPathEffect* fPathEffect; |
30 friend class SkShape1DPathEffect; | 30 friend class SkShape1DPathEffect; |
31 friend class SkShape2DPathEffect; | 31 friend class SkShape2DPathEffect; |
32 }; | 32 }; |
33 | 33 |
34 class SkDrawShape1DPathEffect : public SkDrawShapePathEffect { | 34 class SkDrawShape1DPathEffect : public SkDrawShapePathEffect { |
35 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape1DPathEffect); | 35 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape1DPathEffect); |
36 SkDrawShape1DPathEffect(SkDisplayTypes ); | 36 SkDrawShape1DPathEffect(SkDisplayTypes ); |
37 virtual ~SkDrawShape1DPathEffect(); | 37 virtual ~SkDrawShape1DPathEffect(); |
38 virtual void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; | 38 void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; |
39 private: | 39 private: |
40 SkString phase; | 40 SkString phase; |
41 SkString spacing; | 41 SkString spacing; |
42 friend class SkShape1DPathEffect; | 42 friend class SkShape1DPathEffect; |
43 typedef SkDrawShapePathEffect INHERITED; | 43 typedef SkDrawShapePathEffect INHERITED; |
44 }; | 44 }; |
45 | 45 |
46 class SkDrawShape2DPathEffect : public SkDrawShapePathEffect { | 46 class SkDrawShape2DPathEffect : public SkDrawShapePathEffect { |
47 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape2DPathEffect); | 47 DECLARE_EXTRAS_MEMBER_INFO(SkDrawShape2DPathEffect); |
48 SkDrawShape2DPathEffect(SkDisplayTypes ); | 48 SkDrawShape2DPathEffect(SkDisplayTypes ); |
49 virtual ~SkDrawShape2DPathEffect(); | 49 virtual ~SkDrawShape2DPathEffect(); |
50 virtual void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; | 50 void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; |
51 private: | 51 private: |
52 SkDrawMatrix* matrix; | 52 SkDrawMatrix* matrix; |
53 friend class SkShape2DPathEffect; | 53 friend class SkShape2DPathEffect; |
54 typedef SkDrawShapePathEffect INHERITED; | 54 typedef SkDrawShapePathEffect INHERITED; |
55 }; | 55 }; |
56 | 56 |
57 class SkDrawComposePathEffect : public SkDrawPathEffect { | 57 class SkDrawComposePathEffect : public SkDrawPathEffect { |
58 DECLARE_EXTRAS_MEMBER_INFO(SkDrawComposePathEffect); | 58 DECLARE_EXTRAS_MEMBER_INFO(SkDrawComposePathEffect); |
59 SkDrawComposePathEffect(SkDisplayTypes ); | 59 SkDrawComposePathEffect(SkDisplayTypes ); |
60 virtual ~SkDrawComposePathEffect(); | 60 virtual ~SkDrawComposePathEffect(); |
61 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; | 61 bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; |
62 virtual SkPathEffect* getPathEffect() SK_OVERRIDE; | 62 SkPathEffect* getPathEffect() SK_OVERRIDE; |
63 virtual bool isPaint() const SK_OVERRIDE; | 63 bool isPaint() const SK_OVERRIDE; |
64 private: | 64 private: |
65 SkDrawPathEffect* effect1; | 65 SkDrawPathEffect* effect1; |
66 SkDrawPathEffect* effect2; | 66 SkDrawPathEffect* effect2; |
67 }; | 67 }; |
68 | 68 |
69 class SkDrawCornerPathEffect : public SkDrawPathEffect { | 69 class SkDrawCornerPathEffect : public SkDrawPathEffect { |
70 DECLARE_EXTRAS_MEMBER_INFO(SkDrawCornerPathEffect); | 70 DECLARE_EXTRAS_MEMBER_INFO(SkDrawCornerPathEffect); |
71 SkDrawCornerPathEffect(SkDisplayTypes ); | 71 SkDrawCornerPathEffect(SkDisplayTypes ); |
72 virtual ~SkDrawCornerPathEffect(); | 72 virtual ~SkDrawCornerPathEffect(); |
73 virtual SkPathEffect* getPathEffect() SK_OVERRIDE; | 73 SkPathEffect* getPathEffect() SK_OVERRIDE; |
74 private: | 74 private: |
75 SkScalar radius; | 75 SkScalar radius; |
76 }; | 76 }; |
77 | 77 |
78 //////////// SkShape1DPathEffect | 78 //////////// SkShape1DPathEffect |
79 | 79 |
80 #include "SkAnimateMaker.h" | 80 #include "SkAnimateMaker.h" |
81 #include "SkAnimatorScript.h" | 81 #include "SkAnimatorScript.h" |
82 #include "SkDisplayApply.h" | 82 #include "SkDisplayApply.h" |
83 #include "SkDrawMatrix.h" | 83 #include "SkDrawMatrix.h" |
84 #include "SkPaint.h" | 84 #include "SkPaint.h" |
85 | 85 |
86 class SkShape1DPathEffect : public Sk1DPathEffect { | 86 class SkShape1DPathEffect : public Sk1DPathEffect { |
87 public: | 87 public: |
88 SkShape1DPathEffect(SkDrawShape1DPathEffect* draw, SkAnimateMaker* maker) : | 88 SkShape1DPathEffect(SkDrawShape1DPathEffect* draw, SkAnimateMaker* maker) : |
89 fDraw(draw), fMaker(maker) { | 89 fDraw(draw), fMaker(maker) { |
90 } | 90 } |
91 | 91 |
92 // For serialization. This will never be called. | 92 // For serialization. This will never be called. |
93 Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; } | 93 Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; } |
94 | 94 |
95 protected: | 95 protected: |
96 virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE { | 96 SkScalar begin(SkScalar contourLength) const SK_OVERRIDE { |
97 SkScriptValue value; | 97 SkScriptValue value; |
98 SkAnimatorScript engine(*fMaker, NULL, SkType_Float); | 98 SkAnimatorScript engine(*fMaker, NULL, SkType_Float); |
99 engine.propertyCallBack(GetContourLength, &contourLength); | 99 engine.propertyCallBack(GetContourLength, &contourLength); |
100 value.fOperand.fScalar = 0; | 100 value.fOperand.fScalar = 0; |
101 engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float); | 101 engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float); |
102 return value.fOperand.fScalar; | 102 return value.fOperand.fScalar; |
103 } | 103 } |
104 | 104 |
105 virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const
SK_OVERRIDE { | 105 SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const SK_OVERR
IDE { |
106 fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance); | 106 fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance); |
107 SkDrawPath* drawPath = NULL; | 107 SkDrawPath* drawPath = NULL; |
108 if (fDraw->addPath->isPath()) { | 108 if (fDraw->addPath->isPath()) { |
109 drawPath = (SkDrawPath*) fDraw->addPath; | 109 drawPath = (SkDrawPath*) fDraw->addPath; |
110 } else { | 110 } else { |
111 SkApply* apply = (SkApply*) fDraw->addPath; | 111 SkApply* apply = (SkApply*) fDraw->addPath; |
112 apply->refresh(*fMaker); | 112 apply->refresh(*fMaker); |
113 apply->activate(*fMaker); | 113 apply->activate(*fMaker); |
114 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000)); | 114 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000)); |
115 drawPath = (SkDrawPath*) apply->getScope(); | 115 drawPath = (SkDrawPath*) apply->getScope(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 class SkShape2DPathEffect : public Sk2DPathEffect { | 226 class SkShape2DPathEffect : public Sk2DPathEffect { |
227 public: | 227 public: |
228 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, | 228 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, |
229 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { | 229 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { |
230 } | 230 } |
231 | 231 |
232 // For serialization. This will never be called. | 232 // For serialization. This will never be called. |
233 Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; } | 233 Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; } |
234 | 234 |
235 protected: | 235 protected: |
236 virtual void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE { | 236 void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE { |
237 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds); | 237 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds); |
238 } | 238 } |
239 | 239 |
240 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const SK_OV
ERRIDE { | 240 void next(const SkPoint& loc, int u, int v, SkPath* dst) const SK_OVERRIDE { |
241 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst); | 241 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst); |
242 } | 242 } |
243 | 243 |
244 private: | 244 private: |
245 void setUVBounds(const SkIRect& uvBounds) { | 245 void setUVBounds(const SkIRect& uvBounds) { |
246 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), | 246 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), |
247 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); | 247 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); |
248 } | 248 } |
249 | 249 |
250 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) { | 250 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) { |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 | 508 |
509 void InitializeSkExtraPathEffects(SkAnimator* animator) { | 509 void InitializeSkExtraPathEffects(SkAnimator* animator) { |
510 animator->addExtras(new SkExtraPathEffects()); | 510 animator->addExtras(new SkExtraPathEffects()); |
511 } | 511 } |
512 | 512 |
513 //////////////// | 513 //////////////// |
514 | 514 |
515 | 515 |
516 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { | 516 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { |
517 } | 517 } |
OLD | NEW |