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 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; |
24 virtual SkPathEffect* getPathEffect(); | 24 virtual 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& ); | 38 virtual 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& ); | 50 virtual 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 virtual bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; |
62 virtual SkPathEffect* getPathEffect(); | 62 virtual SkPathEffect* getPathEffect() SK_OVERRIDE; |
63 virtual bool isPaint() const; | 63 virtual 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(); | 73 virtual 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 SK_DECLARE_UNFLATTENABLE_OBJECT() | 92 SK_DECLARE_UNFLATTENABLE_OBJECT() |
93 | 93 |
94 protected: | 94 protected: |
95 virtual SkScalar begin(SkScalar contourLength) const { | 95 virtual SkScalar begin(SkScalar contourLength) const SK_OVERRIDE { |
96 SkScriptValue value; | 96 SkScriptValue value; |
97 SkAnimatorScript engine(*fMaker, NULL, SkType_Float); | 97 SkAnimatorScript engine(*fMaker, NULL, SkType_Float); |
98 engine.propertyCallBack(GetContourLength, &contourLength); | 98 engine.propertyCallBack(GetContourLength, &contourLength); |
99 value.fOperand.fScalar = 0; | 99 value.fOperand.fScalar = 0; |
100 engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float); | 100 engine.evaluate(fDraw->phase.c_str(), &value, SkType_Float); |
101 return value.fOperand.fScalar; | 101 return value.fOperand.fScalar; |
102 } | 102 } |
103 | 103 |
104 virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const
{ | 104 virtual SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const
SK_OVERRIDE { |
105 fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance); | 105 fMaker->setExtraPropertyCallBack(fDraw->fType, GetDistance, &distance); |
106 SkDrawPath* drawPath = NULL; | 106 SkDrawPath* drawPath = NULL; |
107 if (fDraw->addPath->isPath()) { | 107 if (fDraw->addPath->isPath()) { |
108 drawPath = (SkDrawPath*) fDraw->addPath; | 108 drawPath = (SkDrawPath*) fDraw->addPath; |
109 } else { | 109 } else { |
110 SkApply* apply = (SkApply*) fDraw->addPath; | 110 SkApply* apply = (SkApply*) fDraw->addPath; |
111 apply->refresh(*fMaker); | 111 apply->refresh(*fMaker); |
112 apply->activate(*fMaker); | 112 apply->activate(*fMaker); |
113 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000)); | 113 apply->interpolate(*fMaker, SkScalarRoundToInt(distance * 1000)); |
114 drawPath = (SkDrawPath*) apply->getScope(); | 114 drawPath = (SkDrawPath*) apply->getScope(); |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 504 |
505 void InitializeSkExtraPathEffects(SkAnimator* animator) { | 505 void InitializeSkExtraPathEffects(SkAnimator* animator) { |
506 animator->addExtras(new SkExtraPathEffects()); | 506 animator->addExtras(new SkExtraPathEffects()); |
507 } | 507 } |
508 | 508 |
509 //////////////// | 509 //////////////// |
510 | 510 |
511 | 511 |
512 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { | 512 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { |
513 } | 513 } |
OLD | NEW |