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

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

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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
« no previous file with comments | « src/animator/SkAnimateSet.cpp ('k') | src/animator/SkAnimatorScript.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "SkAnimator.h" 10 #include "SkAnimator.h"
(...skipping 24 matching lines...) Expand all
35 #endif 35 #endif
36 36
37 _static const char gMathPrimerText[] = 37 _static const char gMathPrimerText[] =
38 "<screenplay>" 38 "<screenplay>"
39 "<Math id=\"Math\"/>" 39 "<Math id=\"Math\"/>"
40 "<Number id=\"Number\"/>" 40 "<Number id=\"Number\"/>"
41 "</screenplay>"; 41 "</screenplay>";
42 42
43 #define gMathPrimer gMathPrimerText 43 #define gMathPrimer gMathPrimerText
44 44
45 SkAnimator::SkAnimator() : fMaker(NULL) { 45 SkAnimator::SkAnimator() : fMaker(nullptr) {
46 initialize(); 46 initialize();
47 } 47 }
48 48
49 SkAnimator::~SkAnimator() { delete fMaker; } 49 SkAnimator::~SkAnimator() { delete fMaker; }
50 50
51 void SkAnimator::addExtras(SkExtras* extras) { 51 void SkAnimator::addExtras(SkExtras* extras) {
52 *fMaker->fExtras.append() = extras; 52 *fMaker->fExtras.append() = extras;
53 } 53 }
54 54
55 bool SkAnimator::appendStream(SkStream* stream) { 55 bool SkAnimator::appendStream(SkStream* stream) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 fMaker->notifyInval(); 137 fMaker->notifyInval();
138 return result; 138 return result;
139 } 139 }
140 140
141 bool SkAnimator::doUserEvent(const SkEvent& evt) { 141 bool SkAnimator::doUserEvent(const SkEvent& evt) {
142 fMaker->fEnableTime = fMaker->getAppTime(); 142 fMaker->fEnableTime = fMaker->getAppTime();
143 return onEvent(evt); 143 return onEvent(evt);
144 } 144 }
145 145
146 SkAnimator::DifferenceType SkAnimator::draw(SkCanvas* canvas, SkPaint* paint, Sk MSec time) { 146 SkAnimator::DifferenceType SkAnimator::draw(SkCanvas* canvas, SkPaint* paint, Sk MSec time) {
147 if (paint == NULL) 147 if (paint == nullptr)
148 return draw(canvas, time); 148 return draw(canvas, time);
149 fMaker->fScreenplay.time = time; 149 fMaker->fScreenplay.time = time;
150 fMaker->fCanvas = canvas; 150 fMaker->fCanvas = canvas;
151 fMaker->fPaint = paint; 151 fMaker->fPaint = paint;
152 fMaker->fDisplayList.fHasUnion = false; 152 fMaker->fDisplayList.fHasUnion = false;
153 int result = fMaker->fDisplayList.draw(*fMaker, time); 153 int result = fMaker->fDisplayList.draw(*fMaker, time);
154 if (result) 154 if (result)
155 result += fMaker->fDisplayList.fHasUnion; 155 result += fMaker->fDisplayList.fHasUnion;
156 return (DifferenceType) result; 156 return (DifferenceType) result;
157 } 157 }
(...skipping 14 matching lines...) Expand all
172 state.fX = x; 172 state.fX = x;
173 state.fY = y; 173 state.fY = y;
174 fMaker->fEnableTime = fMaker->getAppTime(); 174 fMaker->fEnableTime = fMaker->getAppTime();
175 bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kMouseDown, & state); 175 bool result = fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kMouseDown, & state);
176 fMaker->notifyInval(); 176 fMaker->notifyInval();
177 return result; 177 return result;
178 } 178 }
179 179
180 const SkAnimator* SkAnimator::getAnimator(const SkDisplayable* displayable) cons t { 180 const SkAnimator* SkAnimator::getAnimator(const SkDisplayable* displayable) cons t {
181 if (displayable->getType() != SkType_Movie) 181 if (displayable->getType() != SkType_Movie)
182 return NULL; 182 return nullptr;
183 const SkDisplayMovie* movie = (const SkDisplayMovie*) displayable; 183 const SkDisplayMovie* movie = (const SkDisplayMovie*) displayable;
184 return movie->getAnimator(); 184 return movie->getAnimator();
185 } 185 }
186 186
187 const SkDisplayable* SkAnimator::getElement(const char* id) { 187 const SkDisplayable* SkAnimator::getElement(const char* id) {
188 SkDisplayable* element; 188 SkDisplayable* element;
189 if (fMaker->find(id, &element) == false) 189 if (fMaker->find(id, &element) == false)
190 return NULL; 190 return nullptr;
191 return (const SkDisplayable*) element; 191 return (const SkDisplayable*) element;
192 } 192 }
193 193
194 SkElementType SkAnimator::getElementType(const SkDisplayable* ae) { 194 SkElementType SkAnimator::getElementType(const SkDisplayable* ae) {
195 SkDisplayable* element = (SkDisplayable*) ae; 195 SkDisplayable* element = (SkDisplayable*) ae;
196 const SkMemberInfo* info = SkDisplayType::GetMembers(fMaker, element->getTyp e(), NULL); 196 const SkMemberInfo* info = SkDisplayType::GetMembers(fMaker, element->getTyp e(), nullptr);
197 return (SkElementType) SkDisplayType::Find(fMaker, info); 197 return (SkElementType) SkDisplayType::Find(fMaker, info);
198 } 198 }
199 199
200 SkElementType SkAnimator::getElementType(const char* id) { 200 SkElementType SkAnimator::getElementType(const char* id) {
201 const SkDisplayable* element = getElement(id); 201 const SkDisplayable* element = getElement(id);
202 return getElementType(element); 202 return getElementType(element);
203 } 203 }
204 204
205 const SkMemberInfo* SkAnimator::getField(const SkDisplayable* ae, const char* fi eld) { 205 const SkMemberInfo* SkAnimator::getField(const SkDisplayable* ae, const char* fi eld) {
206 SkDisplayable* element = (SkDisplayable*) ae; 206 SkDisplayable* element = (SkDisplayable*) ae;
(...skipping 26 matching lines...) Expand all
233 233
234 int32_t SkAnimator::getArrayInt(const SkDisplayable* ae, 234 int32_t SkAnimator::getArrayInt(const SkDisplayable* ae,
235 const SkMemberInfo* ai, int index) { 235 const SkMemberInfo* ai, int index) {
236 SkOperand operand; 236 SkOperand operand;
237 bool result = getArrayCommon(ae, ai, index, &operand); 237 bool result = getArrayCommon(ae, ai, index, &operand);
238 return result ? operand.fS32 : SK_NaN32; 238 return result ? operand.fS32 : SK_NaN32;
239 } 239 }
240 240
241 int32_t SkAnimator::getArrayInt(const char* id, const char* fieldID, int index) { 241 int32_t SkAnimator::getArrayInt(const char* id, const char* fieldID, int index) {
242 const SkDisplayable* element = getElement(id); 242 const SkDisplayable* element = getElement(id);
243 if (element == NULL) 243 if (element == nullptr)
244 return SK_NaN32; 244 return SK_NaN32;
245 const SkMemberInfo* field = getField(element, fieldID); 245 const SkMemberInfo* field = getField(element, fieldID);
246 if (field == NULL) 246 if (field == nullptr)
247 return SK_NaN32; 247 return SK_NaN32;
248 return getArrayInt(element, field, index); 248 return getArrayInt(element, field, index);
249 } 249 }
250 250
251 SkScalar SkAnimator::getArrayScalar(const SkDisplayable* ae, 251 SkScalar SkAnimator::getArrayScalar(const SkDisplayable* ae,
252 const SkMemberInfo* ai, int index) { 252 const SkMemberInfo* ai, int index) {
253 SkOperand operand; 253 SkOperand operand;
254 bool result = getArrayCommon(ae, ai, index, &operand); 254 bool result = getArrayCommon(ae, ai, index, &operand);
255 return result ? operand.fScalar : SK_ScalarNaN; 255 return result ? operand.fScalar : SK_ScalarNaN;
256 } 256 }
257 257
258 SkScalar SkAnimator::getArrayScalar(const char* id, const char* fieldID, int ind ex) { 258 SkScalar SkAnimator::getArrayScalar(const char* id, const char* fieldID, int ind ex) {
259 const SkDisplayable* element = getElement(id); 259 const SkDisplayable* element = getElement(id);
260 if (element == NULL) 260 if (element == nullptr)
261 return SK_ScalarNaN; 261 return SK_ScalarNaN;
262 const SkMemberInfo* field = getField(element, fieldID); 262 const SkMemberInfo* field = getField(element, fieldID);
263 if (field == NULL) 263 if (field == nullptr)
264 return SK_ScalarNaN; 264 return SK_ScalarNaN;
265 return getArrayScalar(element, field, index); 265 return getArrayScalar(element, field, index);
266 } 266 }
267 267
268 const char* SkAnimator::getArrayString(const SkDisplayable* ae, 268 const char* SkAnimator::getArrayString(const SkDisplayable* ae,
269 const SkMemberInfo* ai, int index) { 269 const SkMemberInfo* ai, int index) {
270 SkOperand operand; 270 SkOperand operand;
271 bool result = getArrayCommon(ae, ai, index, &operand); 271 bool result = getArrayCommon(ae, ai, index, &operand);
272 return result ? operand.fString->c_str() : NULL; 272 return result ? operand.fString->c_str() : nullptr;
273 } 273 }
274 274
275 const char* SkAnimator::getArrayString(const char* id, const char* fieldID, int index) { 275 const char* SkAnimator::getArrayString(const char* id, const char* fieldID, int index) {
276 const SkDisplayable* element = getElement(id); 276 const SkDisplayable* element = getElement(id);
277 if (element == NULL) 277 if (element == nullptr)
278 return NULL; 278 return nullptr;
279 const SkMemberInfo* field = getField(element, fieldID); 279 const SkMemberInfo* field = getField(element, fieldID);
280 if (field == NULL) 280 if (field == nullptr)
281 return NULL; 281 return nullptr;
282 return getArrayString(element, field, index); 282 return getArrayString(element, field, index);
283 } 283 }
284 284
285 SkMSec SkAnimator::getInterval() { 285 SkMSec SkAnimator::getInterval() {
286 return fMaker->fMinimumInterval == (SkMSec) -1 ? 0 : fMaker->fMinimumInterva l; 286 return fMaker->fMinimumInterval == (SkMSec) -1 ? 0 : fMaker->fMinimumInterva l;
287 } 287 }
288 288
289 void SkAnimator::getInvalBounds(SkRect* inval) { 289 void SkAnimator::getInvalBounds(SkRect* inval) {
290 if (fMaker->fDisplayList.fHasUnion) { 290 if (fMaker->fDisplayList.fHasUnion) {
291 inval->fLeft = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fLeft); 291 inval->fLeft = SkIntToScalar(fMaker->fDisplayList.fInvalBounds.fLeft);
(...skipping 27 matching lines...) Expand all
319 } 319 }
320 SkScriptValue scriptValue; 320 SkScriptValue scriptValue;
321 bool success = element->getProperty(info->propertyIndex(), &scriptValue); 321 bool success = element->getProperty(info->propertyIndex(), &scriptValue);
322 if (success && scriptValue.fType == SkType_Int) 322 if (success && scriptValue.fType == SkType_Int)
323 return scriptValue.fOperand.fS32; 323 return scriptValue.fOperand.fS32;
324 return SK_NaN32; 324 return SK_NaN32;
325 } 325 }
326 326
327 int32_t SkAnimator::getInt(const char* id, const char* fieldID) { 327 int32_t SkAnimator::getInt(const char* id, const char* fieldID) {
328 const SkDisplayable* element = getElement(id); 328 const SkDisplayable* element = getElement(id);
329 if (element == NULL) 329 if (element == nullptr)
330 return SK_NaN32; 330 return SK_NaN32;
331 const SkMemberInfo* field = getField(element, fieldID); 331 const SkMemberInfo* field = getField(element, fieldID);
332 if (field == NULL) 332 if (field == nullptr)
333 return SK_NaN32; 333 return SK_NaN32;
334 return getInt(element, field); 334 return getInt(element, field);
335 } 335 }
336 336
337 SkScalar SkAnimator::getScalar(const SkDisplayable* element, const SkMemberInfo* info) { 337 SkScalar SkAnimator::getScalar(const SkDisplayable* element, const SkMemberInfo* info) {
338 if (info->fType != SkType_MemberProperty) { 338 if (info->fType != SkType_MemberProperty) {
339 SkOperand operand; 339 SkOperand operand;
340 if (info->getType() == SkType_Float) { 340 if (info->getType() == SkType_Float) {
341 info->getValue(element, &operand, 1); 341 info->getValue(element, &operand, 1);
342 return operand.fScalar; 342 return operand.fScalar;
343 } 343 }
344 return SK_ScalarNaN; 344 return SK_ScalarNaN;
345 } 345 }
346 SkScriptValue scriptValue; 346 SkScriptValue scriptValue;
347 bool success = element->getProperty(info->propertyIndex(), &scriptValue); 347 bool success = element->getProperty(info->propertyIndex(), &scriptValue);
348 if (success && scriptValue.fType == SkType_Float) 348 if (success && scriptValue.fType == SkType_Float)
349 return scriptValue.fOperand.fScalar; 349 return scriptValue.fOperand.fScalar;
350 return SK_ScalarNaN; 350 return SK_ScalarNaN;
351 } 351 }
352 352
353 SkScalar SkAnimator::getScalar(const char* id, const char* fieldID) { 353 SkScalar SkAnimator::getScalar(const char* id, const char* fieldID) {
354 const SkDisplayable* element = getElement(id); 354 const SkDisplayable* element = getElement(id);
355 if (element == NULL) 355 if (element == nullptr)
356 return SK_ScalarNaN; 356 return SK_ScalarNaN;
357 const SkMemberInfo* field = getField(element, fieldID); 357 const SkMemberInfo* field = getField(element, fieldID);
358 if (field == NULL) 358 if (field == nullptr)
359 return SK_ScalarNaN; 359 return SK_ScalarNaN;
360 return getScalar(element, field); 360 return getScalar(element, field);
361 } 361 }
362 362
363 const char* SkAnimator::getString(const SkDisplayable* ae, 363 const char* SkAnimator::getString(const SkDisplayable* ae,
364 const SkMemberInfo* ai) { 364 const SkMemberInfo* ai) {
365 const SkDisplayable* element = (const SkDisplayable*) ae; 365 const SkDisplayable* element = (const SkDisplayable*) ae;
366 const SkMemberInfo* info = (const SkMemberInfo*) ai; 366 const SkMemberInfo* info = (const SkMemberInfo*) ai;
367 SkString* temp; 367 SkString* temp;
368 info->getString(element, &temp); 368 info->getString(element, &temp);
369 return temp->c_str(); 369 return temp->c_str();
370 } 370 }
371 371
372 const char* SkAnimator::getString(const char* id, const char* fieldID) { 372 const char* SkAnimator::getString(const char* id, const char* fieldID) {
373 const SkDisplayable* element = getElement(id); 373 const SkDisplayable* element = getElement(id);
374 if (element == NULL) 374 if (element == nullptr)
375 return NULL; 375 return nullptr;
376 const SkMemberInfo* field = getField(element, fieldID); 376 const SkMemberInfo* field = getField(element, fieldID);
377 if (field == NULL) 377 if (field == nullptr)
378 return NULL; 378 return nullptr;
379 return getString(element, field); 379 return getString(element, field);
380 } 380 }
381 381
382 const char* SkAnimator::getURIBase() { 382 const char* SkAnimator::getURIBase() {
383 return fMaker->fPrefix.c_str(); 383 return fMaker->fPrefix.c_str();
384 } 384 }
385 385
386 void SkAnimator::initialize() { 386 void SkAnimator::initialize() {
387 delete fMaker; 387 delete fMaker;
388 fMaker = new SkAnimateMaker(this, NULL, NULL); 388 fMaker = new SkAnimateMaker(this, nullptr, nullptr);
389 decodeMemory(gMathPrimer, sizeof(gMathPrimer)-1); 389 decodeMemory(gMathPrimer, sizeof(gMathPrimer)-1);
390 #ifdef SK_BUILD_FOR_ANDROID 390 #ifdef SK_BUILD_FOR_ANDROID
391 InitializeSkExtraPathEffects(this); 391 InitializeSkExtraPathEffects(this);
392 #endif 392 #endif
393 } 393 }
394 394
395 395
396 #ifdef SK_DEBUG 396 #ifdef SK_DEBUG
397 bool SkAnimator::isTrackingEvents() { 397 bool SkAnimator::isTrackingEvents() {
398 return false; 398 return false;
399 } 399 }
400 #endif 400 #endif
401 401
402 bool SkAnimator::onEvent(const SkEvent& evt) { 402 bool SkAnimator::onEvent(const SkEvent& evt) {
403 #ifdef SK_DEBUG 403 #ifdef SK_DEBUG
404 SkAnimator* root = fMaker->getRoot(); 404 SkAnimator* root = fMaker->getRoot();
405 if (root == NULL) 405 if (root == nullptr)
406 root = this; 406 root = this;
407 if (root->isTrackingEvents()) 407 if (root->isTrackingEvents())
408 root->eventDone(evt); 408 root->eventDone(evt);
409 #endif 409 #endif
410 if (evt.isType(SK_EventType_OnEnd)) { 410 if (evt.isType(SK_EventType_OnEnd)) {
411 SkEventState eventState; 411 SkEventState eventState;
412 SkDEBUGCODE(bool success =) evt.findPtr("anim", (void**) &eventState.fDi splayable); 412 SkDEBUGCODE(bool success =) evt.findPtr("anim", (void**) &eventState.fDi splayable);
413 SkASSERT(success); 413 SkASSERT(success);
414 SkDEBUGCODE(success =) evt.findS32("time", (int32_t*) &fMaker->fEnableTi me); 414 SkDEBUGCODE(success =) evt.findS32("time", (int32_t*) &fMaker->fEnableTi me);
415 SkASSERT(success); 415 SkASSERT(success);
416 fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime; 416 fMaker->fAdjustedStart = fMaker->getAppTime() - fMaker->fEnableTime;
417 fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState); 417 fMaker->fEvents.doEvent(*fMaker, SkDisplayEvent::kOnEnd, &eventState);
418 fMaker->fAdjustedStart = 0; 418 fMaker->fAdjustedStart = 0;
419 goto inval; 419 goto inval;
420 } 420 }
421 if (evt.isType(SK_EventType_Delay)) { 421 if (evt.isType(SK_EventType_Delay)) {
422 fMaker->doDelayedEvent(); 422 fMaker->doDelayedEvent();
423 goto inval; 423 goto inval;
424 } 424 }
425 { 425 {
426 const char* id = evt.findString("id"); 426 const char* id = evt.findString("id");
427 if (id == NULL) 427 if (id == nullptr)
428 return false; 428 return false;
429 SkDisplayable** firstMovie = fMaker->fMovies.begin(); 429 SkDisplayable** firstMovie = fMaker->fMovies.begin();
430 SkDisplayable** endMovie = fMaker->fMovies.end(); 430 SkDisplayable** endMovie = fMaker->fMovies.end();
431 for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) { 431 for (SkDisplayable** ptr = firstMovie; ptr < endMovie; ptr++) {
432 SkDisplayMovie* movie = (SkDisplayMovie*) *ptr; 432 SkDisplayMovie* movie = (SkDisplayMovie*) *ptr;
433 movie->doEvent(evt); 433 movie->doEvent(evt);
434 } 434 }
435 { 435 {
436 SkDisplayable* event; 436 SkDisplayable* event;
437 if (fMaker->find(id, &event) == false) 437 if (fMaker->find(id, &event) == false)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 SkDisplayArray* dispArray = (SkDisplayArray*) element; 548 SkDisplayArray* dispArray = (SkDisplayArray*) element;
549 dispArray->values = array; 549 dispArray->values = array;
550 return true; 550 return true;
551 } 551 }
552 else 552 else
553 return false; //currently i don't care about this case 553 return false; //currently i don't care about this case
554 } 554 }
555 555
556 bool SkAnimator::setArray(const char* id, const char* fieldID, SkTypedArray arra y) { 556 bool SkAnimator::setArray(const char* id, const char* fieldID, SkTypedArray arra y) {
557 SkDisplayable* element = (SkDisplayable*) getElement(id); 557 SkDisplayable* element = (SkDisplayable*) getElement(id);
558 //should I go ahead and change all 'NULL's to 'NULL'? 558 //should I go ahead and change all 'nullptr's to 'nullptr'?
559 if (element == NULL) 559 if (element == nullptr)
560 return false; 560 return false;
561 const SkMemberInfo* field = getField(element, fieldID); 561 const SkMemberInfo* field = getField(element, fieldID);
562 if (field == NULL) 562 if (field == nullptr)
563 return false; 563 return false;
564 return setArray(element, field, array); 564 return setArray(element, field, array);
565 } 565 }
566 566
567 bool SkAnimator::setInt(SkDisplayable* element, const SkMemberInfo* info, int32_ t s32) { 567 bool SkAnimator::setInt(SkDisplayable* element, const SkMemberInfo* info, int32_ t s32) {
568 if (info->fType != SkType_MemberProperty) { 568 if (info->fType != SkType_MemberProperty) {
569 SkOperand operand; 569 SkOperand operand;
570 operand.fS32 = s32; 570 operand.fS32 = s32;
571 SkASSERT(info->getType() == SkType_Int); 571 SkASSERT(info->getType() == SkType_Int);
572 info->setValue(element, &operand, 1); 572 info->setValue(element, &operand, 1);
573 } else { 573 } else {
574 SkScriptValue scriptValue; 574 SkScriptValue scriptValue;
575 scriptValue.fType = SkType_Int; 575 scriptValue.fType = SkType_Int;
576 scriptValue.fOperand.fS32 = s32; 576 scriptValue.fOperand.fS32 = s32;
577 element->setProperty(info->propertyIndex(), scriptValue); 577 element->setProperty(info->propertyIndex(), scriptValue);
578 } 578 }
579 return true; 579 return true;
580 } 580 }
581 581
582 bool SkAnimator::setInt(const char* id, const char* fieldID, int32_t s32) { 582 bool SkAnimator::setInt(const char* id, const char* fieldID, int32_t s32) {
583 SkDisplayable* element = (SkDisplayable*) getElement(id); 583 SkDisplayable* element = (SkDisplayable*) getElement(id);
584 if (element == NULL) 584 if (element == nullptr)
585 return false; 585 return false;
586 const SkMemberInfo* field = getField(element, fieldID); 586 const SkMemberInfo* field = getField(element, fieldID);
587 if (field == NULL) 587 if (field == nullptr)
588 return false; 588 return false;
589 return setInt(element, field, s32); 589 return setInt(element, field, s32);
590 } 590 }
591 591
592 bool SkAnimator::setScalar(SkDisplayable* element, const SkMemberInfo* info, SkS calar scalar) { 592 bool SkAnimator::setScalar(SkDisplayable* element, const SkMemberInfo* info, SkS calar scalar) {
593 if (info->fType != SkType_MemberProperty) { 593 if (info->fType != SkType_MemberProperty) {
594 SkOperand operand; 594 SkOperand operand;
595 operand.fScalar = scalar; 595 operand.fScalar = scalar;
596 SkASSERT(info->getType() == SkType_Float); 596 SkASSERT(info->getType() == SkType_Float);
597 info->setValue(element, &operand, 1); 597 info->setValue(element, &operand, 1);
598 } else { 598 } else {
599 SkScriptValue scriptValue; 599 SkScriptValue scriptValue;
600 scriptValue.fType = SkType_Float; 600 scriptValue.fType = SkType_Float;
601 scriptValue.fOperand.fScalar = scalar; 601 scriptValue.fOperand.fScalar = scalar;
602 element->setProperty(info->propertyIndex(), scriptValue); 602 element->setProperty(info->propertyIndex(), scriptValue);
603 } 603 }
604 return true; 604 return true;
605 } 605 }
606 606
607 bool SkAnimator::setScalar(const char* id, const char* fieldID, SkScalar scalar) { 607 bool SkAnimator::setScalar(const char* id, const char* fieldID, SkScalar scalar) {
608 SkDisplayable* element = (SkDisplayable*) getElement(id); 608 SkDisplayable* element = (SkDisplayable*) getElement(id);
609 if (element == NULL) 609 if (element == nullptr)
610 return false; 610 return false;
611 const SkMemberInfo* field = getField(element, fieldID); 611 const SkMemberInfo* field = getField(element, fieldID);
612 if (field == NULL) 612 if (field == nullptr)
613 return false; 613 return false;
614 return setScalar(element, field, scalar); 614 return setScalar(element, field, scalar);
615 } 615 }
616 616
617 bool SkAnimator::setString(SkDisplayable* element, 617 bool SkAnimator::setString(SkDisplayable* element,
618 const SkMemberInfo* info, const char* str) { 618 const SkMemberInfo* info, const char* str) {
619 // !!! until this is fixed, can't call script with global references from he re 619 // !!! until this is fixed, can't call script with global references from he re
620 info->setValue(*fMaker, NULL, 0, info->fCount, element, info->getType(), str , strlen(str)); 620 info->setValue(*fMaker, nullptr, 0, info->fCount, element, info->getType(), str, strlen(str));
621 return true; 621 return true;
622 } 622 }
623 623
624 bool SkAnimator::setString(const char* id, const char* fieldID, const char* str) { 624 bool SkAnimator::setString(const char* id, const char* fieldID, const char* str) {
625 SkDisplayable* element = (SkDisplayable*) getElement(id); 625 SkDisplayable* element = (SkDisplayable*) getElement(id);
626 if (element == NULL) 626 if (element == nullptr)
627 return false; 627 return false;
628 const SkMemberInfo* field = getField(element, fieldID); 628 const SkMemberInfo* field = getField(element, fieldID);
629 if (field == NULL) 629 if (field == nullptr)
630 return false; 630 return false;
631 return setString(element, field, str); 631 return setString(element, field, str);
632 } 632 }
633 633
634 void SkAnimator::setTimeline(const Timeline& timeline) { 634 void SkAnimator::setTimeline(const Timeline& timeline) {
635 fMaker->fTimeline = &timeline; 635 fMaker->fTimeline = &timeline;
636 } 636 }
637 637
638 void SkAnimator::setURIBase(const char* uri) { 638 void SkAnimator::setURIBase(const char* uri) {
639 if (uri) 639 if (uri)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 gUnitTests[i].fUnitTest(); 695 gUnitTests[i].fUnitTest();
696 SkDebugf("SkAnimator: End UnitTest for %s\n", gUnitTests[i].fTypeName); 696 SkDebugf("SkAnimator: End UnitTest for %s\n", gUnitTests[i].fTypeName);
697 } 697 }
698 } 698 }
699 #else 699 #else
700 void SkAnimator::Init(bool) {} 700 void SkAnimator::Init(bool) {}
701 #endif 701 #endif
702 702
703 void SkAnimator::Term() { 703 void SkAnimator::Term() {
704 } 704 }
OLDNEW
« no previous file with comments | « src/animator/SkAnimateSet.cpp ('k') | src/animator/SkAnimatorScript.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698