Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(105)

Side by Side Diff: src/animator/SkDrawExtraPathEffect.cpp

Issue 12480002: Fixing some warnings on Linux (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 } else { 111 } else {
112 SkApply* apply = (SkApply*) fDraw->addPath; 112 SkApply* apply = (SkApply*) fDraw->addPath;
113 apply->refresh(*fMaker); 113 apply->refresh(*fMaker);
114 apply->activate(*fMaker); 114 apply->activate(*fMaker);
115 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000)); 115 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
116 drawPath = (SkDrawPath*) apply->getScope(); 116 drawPath = (SkDrawPath*) apply->getScope();
117 } 117 }
118 SkMatrix m; 118 SkMatrix m;
119 m.reset(); 119 m.reset();
120 if (fDraw->addMatrix) { 120 if (fDraw->addMatrix) {
121 SkDrawMatrix* matrix; 121 if (fDraw->addMatrix->getType() != SkType_Matrix) {
sugoi 2013/03/06 16:14:59 matrix is assigned, but unused, so it was deleted
122 if (fDraw->addMatrix->getType() == SkType_Matrix)
123 matrix = (SkDrawMatrix*) fDraw->addMatrix;
124 else {
125 SkApply* apply = (SkApply*) fDraw->addMatrix; 122 SkApply* apply = (SkApply*) fDraw->addMatrix;
126 apply->refresh(*fMaker); 123 apply->refresh(*fMaker);
127 apply->activate(*fMaker); 124 apply->activate(*fMaker);
128 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000)); 125 apply->interpolate(*fMaker, SkScalarMulRound(distance, 1000));
129 matrix = (SkDrawMatrix*) apply->getScope();
130 } 126 }
131 } 127 }
132 SkScalar result = 0; 128 SkScalar result = 0;
133 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), & result); 129 SkAnimatorScript::EvaluateFloat(*fMaker, NULL, fDraw->spacing.c_str(), & result);
134 if (drawPath) 130 if (drawPath)
135 dst->addPath(drawPath->getPath(), m); 131 dst->addPath(drawPath->getPath(), m);
136 fMaker->clearExtraPropertyCallBack(fDraw->fType); 132 fMaker->clearExtraPropertyCallBack(fDraw->fType);
137 return result; 133 return result;
138 } 134 }
139 135
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add e rror 213 maker.setErrorCode(SkDisplayXMLParserError::kUnknownError); // !!! add e rror
218 else 214 else
219 fPathEffect = new SkShape1DPathEffect(this, &maker); 215 fPathEffect = new SkShape1DPathEffect(this, &maker);
220 } 216 }
221 217
222 ////////// SkShape2DPathEffect 218 ////////// SkShape2DPathEffect
223 219
224 class SkShape2DPathEffect : public Sk2DPathEffect { 220 class SkShape2DPathEffect : public Sk2DPathEffect {
225 public: 221 public:
226 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker, 222 SkShape2DPathEffect(SkDrawShape2DPathEffect* draw, SkAnimateMaker* maker,
227 const SkMatrix& matrix) : Sk2DPathEffect(matrix), fDraw(draw), fMaker(ma ker) { 223 const SkMatrix& matrix) : Sk2DPathEffect(matrix) {
224 fData = new SkShape2DPathEffectData(draw, maker);
225 }
226 ~SkShape2DPathEffect() {
227 delete fData;
228 } 228 }
229 229
230 protected: 230 protected:
231 virtual void begin(const SkIRect& uvBounds, SkPath* ) 231 virtual void begin(const SkIRect& uvBounds, SkPath*) const {
sugoi 2013/03/06 16:14:59 These virtual functions are const in the base clas
232 { 232 fData->begin(uvBounds);
233 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds.fTop ),
234 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom));
235 } 233 }
236 234
237 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) 235 virtual void next(const SkPoint& loc, int u, int v, SkPath* dst) const {
238 { 236 fData->next(loc, u, v, dst);
239 fLoc = loc;
240 fU = u;
241 fV = v;
242 SkDrawPath* drawPath;
243 fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this);
244 if (fDraw->addPath->isPath()) {
245 drawPath = (SkDrawPath*) fDraw->addPath;
246 } else {
247 SkApply* apply = (SkApply*) fDraw->addPath;
248 apply->refresh(*fMaker);
249 apply->activate(*fMaker);
250 apply->interpolate(*fMaker, v);
251 drawPath = (SkDrawPath*) apply->getScope();
252 }
253 if (drawPath == NULL)
254 goto clearCallBack;
255 if (fDraw->matrix) {
256 SkDrawMatrix* matrix;
257 if (fDraw->matrix->getType() == SkType_Matrix)
258 matrix = (SkDrawMatrix*) fDraw->matrix;
259 else {
260 SkApply* apply = (SkApply*) fDraw->matrix;
261 apply->activate(*fMaker);
262 apply->interpolate(*fMaker, v);
263 matrix = (SkDrawMatrix*) apply->getScope();
264 }
265 if (matrix) {
266 dst->addPath(drawPath->getPath(), matrix->getMatrix());
267 goto clearCallBack;
268 }
269 }
270 dst->addPath(drawPath->getPath());
271 clearCallBack:
272 fMaker->clearExtraPropertyCallBack(fDraw->fType);
273 } 237 }
274 238
275 private: 239 private:
240 struct SkShape2DPathEffectData {
241 SkShape2DPathEffectData(SkDrawShape2DPathEffect* draw, SkAnimateMaker* m aker) :
242 fDraw(draw), fMaker(maker) {}
243
244 void begin(const SkIRect& uvBounds) {
245 fUVBounds.set(SkIntToScalar(uvBounds.fLeft), SkIntToScalar(uvBounds. fTop),
246 SkIntToScalar(uvBounds.fRight), SkIntToScalar(uvBounds.fBottom)) ;
247 }
248
249 void next(const SkPoint& loc, int u, int v, SkPath* dst) {
250 fLoc = loc;
251 fU = u;
252 fV = v;
253 SkDrawPath* drawPath;
254 fMaker->setExtraPropertyCallBack(fDraw->fType, Get2D, this);
255 if (fDraw->addPath->isPath()) {
256 drawPath = (SkDrawPath*) fDraw->addPath;
257 } else {
258 SkApply* apply = (SkApply*) fDraw->addPath;
259 apply->refresh(*fMaker);
260 apply->activate(*fMaker);
261 apply->interpolate(*fMaker, v);
262 drawPath = (SkDrawPath*) apply->getScope();
263 }
264 if (drawPath == NULL)
265 goto clearCallBack;
266 if (fDraw->matrix) {
267 SkDrawMatrix* matrix;
268 if (fDraw->matrix->getType() == SkType_Matrix)
269 matrix = (SkDrawMatrix*) fDraw->matrix;
270 else {
271 SkApply* apply = (SkApply*) fDraw->matrix;
272 apply->activate(*fMaker);
273 apply->interpolate(*fMaker, v);
274 matrix = (SkDrawMatrix*) apply->getScope();
275 }
276 if (matrix) {
277 dst->addPath(drawPath->getPath(), matrix->getMatrix());
278 goto clearCallBack;
279 }
280 }
281 dst->addPath(drawPath->getPath());
282 clearCallBack:
283 fMaker->clearExtraPropertyCallBack(fDraw->fType);
284 }
285
286 SkPoint fLoc;
287 SkRect fUVBounds;
288 int32_t fU;
289 int32_t fV;
290 SkDrawShape2DPathEffect* fDraw;
291 SkAnimateMaker* fMaker;
292 };
276 293
277 static bool Get2D(const char* token, size_t len, void* s2D, SkScriptValue* v alue) { 294 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" ; 295 static const char match[] = "locX|locY|left|top|right|bottom|u|v" ;
279 SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D; 296 SkShape2DPathEffect* shape2D = (SkShape2DPathEffect*) s2D;
280 int index; 297 int index;
281 if (SkAnimatorScript::MapEnums(match, token, len, &index) == false) 298 if (SkAnimatorScript::MapEnums(match, token, len, &index) == false)
282 return false; 299 return false;
283 SkASSERT((sizeof(SkPoint) + sizeof(SkRect)) / sizeof(SkScalar) == 6) ; 300 SkASSERT((sizeof(SkPoint) + sizeof(SkRect)) / sizeof(SkScalar) == 6) ;
284 if (index < 6) { 301 if (index < 6) {
285 value->fType = SkType_Float; 302 value->fType = SkType_Float;
286 value->fOperand.fScalar = (&shape2D->fLoc.fX)[index]; 303 value->fOperand.fScalar = (&shape2D->fData->fLoc.fX)[index];
287 } else { 304 } else {
288 value->fType = SkType_Int; 305 value->fType = SkType_Int;
289 value->fOperand.fS32 = (&shape2D->fU)[index - 6]; 306 value->fOperand.fS32 = (&shape2D->fData->fU)[index - 6];
290 } 307 }
291 return true; 308 return true;
292 } 309 }
293 310
294 SkPoint fLoc; 311 SkShape2DPathEffectData* fData;
295 SkRect fUVBounds;
296 int32_t fU;
297 int32_t fV;
298 SkDrawShape2DPathEffect* fDraw;
299 SkAnimateMaker* fMaker;
300 312
301 // illegal 313 // illegal
302 SkShape2DPathEffect(const SkShape2DPathEffect&); 314 SkShape2DPathEffect(const SkShape2DPathEffect&);
303 SkShape2DPathEffect& operator=(const SkShape2DPathEffect&); 315 SkShape2DPathEffect& operator=(const SkShape2DPathEffect&);
304 }; 316 };
305 317
306 ////////// SkDrawShape2DPathEffect 318 ////////// SkDrawShape2DPathEffect
307 319
308 #if SK_USE_CONDENSED_INFO == 0 320 #if SK_USE_CONDENSED_INFO == 0
309 321
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 511
500 void InitializeSkExtraPathEffects(SkAnimator* animator) { 512 void InitializeSkExtraPathEffects(SkAnimator* animator) {
501 animator->addExtras(new SkExtraPathEffects(animator)); 513 animator->addExtras(new SkExtraPathEffects(animator));
502 } 514 }
503 515
504 //////////////// 516 ////////////////
505 517
506 518
507 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) { 519 SkExtras::SkExtras() : fExtraCallBack(NULL), fExtraStorage(NULL) {
508 } 520 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698