| 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 bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; | 23 bool addChild(SkAnimateMaker& , SkDisplayable* ) override; |
| 24 SkPathEffect* getPathEffect() SK_OVERRIDE; | 24 SkPathEffect* getPathEffect() 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 void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; | 38 void onEndElement(SkAnimateMaker& ) 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 void onEndElement(SkAnimateMaker& ) SK_OVERRIDE; | 50 void onEndElement(SkAnimateMaker& ) 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 bool addChild(SkAnimateMaker& , SkDisplayable* ) SK_OVERRIDE; | 61 bool addChild(SkAnimateMaker& , SkDisplayable* ) override; |
| 62 SkPathEffect* getPathEffect() SK_OVERRIDE; | 62 SkPathEffect* getPathEffect() override; |
| 63 bool isPaint() const SK_OVERRIDE; | 63 bool isPaint() const 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 SkPathEffect* getPathEffect() SK_OVERRIDE; | 73 SkPathEffect* getPathEffect() 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 override { sk_throw(); return NULL; } |
| 94 | 94 |
| 95 protected: | 95 protected: |
| 96 SkScalar begin(SkScalar contourLength) const SK_OVERRIDE { | 96 SkScalar begin(SkScalar contourLength) const 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 SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const SK_OVERR
IDE { | 105 SkScalar next(SkPath* dst, SkScalar distance, SkPathMeasure&) const override
{ |
| 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 17 matching lines...) Expand all Loading... |
| 133 } | 133 } |
| 134 SkScalar result = 0; | 134 SkScalar result = 0; |
| 135 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), &
result); | 135 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), &
result); |
| 136 if (drawPath) | 136 if (drawPath) |
| 137 dst->addPath(drawPath->getPath(), m); | 137 dst->addPath(drawPath->getPath(), m); |
| 138 fMaker->clearExtraPropertyCallBack(fDraw->fType); | 138 fMaker->clearExtraPropertyCallBack(fDraw->fType); |
| 139 return result; | 139 return result; |
| 140 } | 140 } |
| 141 | 141 |
| 142 #ifndef SK_IGNORE_TO_STRING | 142 #ifndef SK_IGNORE_TO_STRING |
| 143 void toString(SkString* str) const SK_OVERRIDE { | 143 void toString(SkString* str) const override { |
| 144 str->appendf("SkShape1DPathEffect: ("); | 144 str->appendf("SkShape1DPathEffect: ("); |
| 145 // TODO: fill in | 145 // TODO: fill in |
| 146 str->appendf(")"); | 146 str->appendf(")"); |
| 147 } | 147 } |
| 148 #endif | 148 #endif |
| 149 | 149 |
| 150 private: | 150 private: |
| 151 static bool GetContourLength(const char* token, size_t len, void* clen, SkSc
riptValue* value) { | 151 static bool GetContourLength(const char* token, size_t len, void* clen, SkSc
riptValue* value) { |
| 152 if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) { | 152 if (SK_LITERAL_STR_EQUAL("contourLength", token, len)) { |
| 153 value->fOperand.fScalar = *(SkScalar*) clen; | 153 value->fOperand.fScalar = *(SkScalar*) clen; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 231 |
| 232 ////////// SkShape2DPathEffect | 232 ////////// SkShape2DPathEffect |
| 233 | 233 |
| 234 class SkShape2DPathEffect : public Sk2DPathEffect { | 234 class SkShape2DPathEffect : public Sk2DPathEffect { |
| 235 public: | 235 public: |
| 236 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, | 236 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, |
| 237 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { | 237 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { |
| 238 } | 238 } |
| 239 | 239 |
| 240 // For serialization. This will never be called. | 240 // For serialization. This will never be called. |
| 241 Factory getFactory() const SK_OVERRIDE { sk_throw(); return NULL; } | 241 Factory getFactory() const override { sk_throw(); return NULL; } |
| 242 | 242 |
| 243 protected: | 243 protected: |
| 244 void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE { | 244 void begin(const SkIRect& uvBounds, SkPath*) const override { |
| 245 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds); | 245 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void next(const SkPoint& loc, int u, int v, SkPath* dst) const SK_OVERRIDE { | 248 void next(const SkPoint& loc, int u, int v, SkPath* dst) const override { |
| 249 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst); | 249 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst); |
| 250 } | 250 } |
| 251 | 251 |
| 252 private: | 252 private: |
| 253 void setUVBounds(const SkIRect& uvBounds) { | 253 void setUVBounds(const SkIRect& uvBounds) { |
| 254 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), | 254 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), |
| 255 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); | 255 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); |
| 256 } | 256 } |
| 257 | 257 |
| 258 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) { | 258 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) { |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 516 |
| 517 void InitializeSkExtraPathEffects(SkAnimator* animator) { | 517 void InitializeSkExtraPathEffects(SkAnimator* animator) { |
| 518 animator->addExtras(new SkExtraPathEffects()); | 518 animator->addExtras(new SkExtraPathEffects()); |
| 519 } | 519 } |
| 520 | 520 |
| 521 //////////////// | 521 //////////////// |
| 522 | 522 |
| 523 | 523 |
| 524 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { | 524 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { |
| 525 } | 525 } |
| OLD | NEW |