OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkDrawExtraPathEffect.h" | 10 #include "SkDrawExtraPathEffect.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 SkDrawMatrix* matrix; | 121 SkDrawMatrix* matrix; |
122 if (fDraw->addMatrix->getType() == SkType_Matrix) | 122 if (fDraw->addMatrix->getType() == SkType_Matrix) |
123 matrix = (SkDrawMatrix*) fDraw->addMatrix; | 123 matrix = (SkDrawMatrix*) fDraw->addMatrix; |
124 else { | 124 else { |
125 SkApply* apply = (SkApply*) fDraw->addMatrix; | 125 SkApply* apply = (SkApply*) fDraw->addMatrix; |
126 apply->refresh(*fMaker); | 126 apply->refresh(*fMaker); |
127 apply->activate(*fMaker); | 127 apply->activate(*fMaker); |
128 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000)); | 128 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000)); |
129 matrix = (SkDrawMatrix*) apply->getScope(); | 129 matrix = (SkDrawMatrix*) apply->getScope(); |
130 } | 130 } |
| 131 if (matrix) { |
| 132 m = matrix->getMatrix(); |
| 133 } |
131 } | 134 } |
132 SkScalar result = 0; | 135 SkScalar result = 0; |
133 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), &
result); | 136 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), &
result); |
134 if (drawPath) | 137 if (drawPath) |
135 dst->addPath(drawPath->getPath(), m); | 138 dst->addPath(drawPath->getPath(), m); |
136 fMaker->clearExtraPropertyCallBack(fDraw->fType); | 139 fMaker->clearExtraPropertyCallBack(fDraw->fType); |
137 return result; | 140 return result; |
138 } | 141 } |
139 | 142 |
140 private: | 143 private: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 224 |
222 ////////// SkShape2DPathEffect | 225 ////////// SkShape2DPathEffect |
223 | 226 |
224 class SkShape2DPathEffect : public Sk2DPathEffect { | 227 class SkShape2DPathEffect : public Sk2DPathEffect { |
225 public: | 228 public: |
226 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, | 229 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, |
227 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { | 230 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma
ker) { |
228 } | 231 } |
229 | 232 |
230 protected: | 233 protected: |
231 virtual void begin(const SkIRect& uvBounds, SkPath* ) | 234 virtual void begin(const SkIRect& uvBounds, SkPath*) const SK_OVERRIDE { |
232 { | 235 const_cast<SkShape2DPathEffect*>(this)->setUVBounds(uvBounds); |
| 236 } |
| 237 |
| 238 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const SK_OV
ERRIDE { |
| 239 const_cast<SkShape2DPathEffect*>(this)->addPath(loc, u, v, dst); |
| 240 } |
| 241 |
| 242 private: |
| 243 void setUVBounds(const SkIRect& uvBounds) { |
233 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), | 244 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop
), |
234 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); | 245 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)); |
235 } | 246 } |
236 | 247 |
237 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) | 248 void addPath(const SkPoint& loc, int u, int v, SkPath* dst) { |
238 { | |
239 fLoc = loc; | 249 fLoc = loc; |
240 fU = u; | 250 fU = u; |
241 fV = v; | 251 fV = v; |
242 SkDrawPath* drawPath; | 252 SkDrawPath* drawPath; |
243 fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this); | 253 fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this); |
244 if (fDraw->addPath->isPath()) { | 254 if (fDraw->addPath->isPath()) { |
245 drawPath = (SkDrawPath*) fDraw->addPath; | 255 drawPath = (SkDrawPath*) fDraw->addPath; |
246 } else { | 256 } else { |
247 SkApply* apply = (SkApply*) fDraw->addPath; | 257 SkApply* apply = (SkApply*) fDraw->addPath; |
248 apply->refresh(*fMaker); | 258 apply->refresh(*fMaker); |
(...skipping 16 matching lines...) Expand all Loading... |
265 if (matrix) { | 275 if (matrix) { |
266 dst->addPath(drawPath->getPath(), matrix->getMatrix()); | 276 dst->addPath(drawPath->getPath(), matrix->getMatrix()); |
267 goto clearCallBack; | 277 goto clearCallBack; |
268 } | 278 } |
269 } | 279 } |
270 dst->addPath(drawPath->getPath()); | 280 dst->addPath(drawPath->getPath()); |
271 clearCallBack: | 281 clearCallBack: |
272 fMaker->clearExtraPropertyCallBack(fDraw->fType); | 282 fMaker->clearExtraPropertyCallBack(fDraw->fType); |
273 } | 283 } |
274 | 284 |
275 private: | |
276 | |
277 static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* v
alue) { | 285 static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* v
alue) { |
278 static const char match[] = "locX|locY|left|top|right|bottom|u|v" ; | 286 static const char match[] = "locX|locY|left|top|right|bottom|u|v" ; |
279 SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D; | 287 SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D; |
280 int index; | 288 int index; |
281 if (SkAnimatorScript::MapEnums(match, token, len, &index) == false) | 289 if (SkAnimatorScript::MapEnums(match, token, len, &index) == false) |
282 return false; | 290 return false; |
283 SkASSERT((sizeof(SkPoint) + sizeof(SkRect)) / sizeof(SkScalar) == 6)
; | 291 SkASSERT((sizeof(SkPoint) + sizeof(SkRect)) / sizeof(SkScalar) == 6)
; |
284 if (index < 6) { | 292 if (index < 6) { |
285 value->fType = SkType_Float; | 293 value->fType = SkType_Float; |
286 value->fOperand.fScalar = (&shape2D->fLoc.fX)[index]; | 294 value->fOperand.fScalar = (&shape2D->fLoc.fX)[index]; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 | 507 |
500 void InitializeSkExtraPathEffects(SkAnimator* animator) { | 508 void InitializeSkExtraPathEffects(SkAnimator* animator) { |
501 animator->addExtras(new SkExtraPathEffects(animator)); | 509 animator->addExtras(new SkExtraPathEffects(animator)); |
502 } | 510 } |
503 | 511 |
504 //////////////// | 512 //////////////// |
505 | 513 |
506 | 514 |
507 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { | 515 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { |
508 } | 516 } |
OLD | NEW |