| 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 "SkAnimator.h" | 10 #include "SkAnimator.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 SkFieldType SkAnimator::getFieldType(const SkMemberInfo* ai) { | 216 SkFieldType SkAnimator::getFieldType(const SkMemberInfo* ai) { |
| 217 const SkMemberInfo* info = (const SkMemberInfo*) ai; | 217 const SkMemberInfo* info = (const SkMemberInfo*) ai; |
| 218 return (SkFieldType) info->getType(); | 218 return (SkFieldType) info->getType(); |
| 219 } | 219 } |
| 220 | 220 |
| 221 SkFieldType SkAnimator::getFieldType(const char* id, const char* fieldID) { | 221 SkFieldType SkAnimator::getFieldType(const char* id, const char* fieldID) { |
| 222 const SkMemberInfo* field = getField(id, fieldID); | 222 const SkMemberInfo* field = getField(id, fieldID); |
| 223 return getFieldType(field); | 223 return getFieldType(field); |
| 224 } | 224 } |
| 225 | 225 |
| 226 static bool getArrayCommon(const SkDisplayable* ae, const SkMemberInfo* ai, | 226 static bool getArrayCommon(const SkDisplayable* ae, const SkMemberInfo* ai, |
| 227 int index, SkOperand* operand, SkDisplayTypes type) { | 227 int index, SkOperand* operand) { |
| 228 const SkDisplayable* element = (const SkDisplayable*) ae; | 228 const SkDisplayable* element = (const SkDisplayable*) ae; |
| 229 const SkMemberInfo* info = (const SkMemberInfo*) ai; | 229 const SkMemberInfo* info = (const SkMemberInfo*) ai; |
| 230 SkASSERT(info->fType == SkType_Array); | 230 SkASSERT(info->fType == SkType_Array); |
| 231 return info->getArrayValue(element, index, operand); | 231 return info->getArrayValue(element, index, operand); |
| 232 } | 232 } |
| 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, SkType_Int); | 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 == NULL) |
| 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 == NULL) |
| 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, SkType_Float); | 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 == NULL) |
| 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 == NULL) |
| 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, SkType_String); | 271 bool result = getArrayCommon(ae, ai, index, &operand); |
| 272 return result ? operand.fString->c_str() : NULL; | 272 return result ? operand.fString->c_str() : NULL; |
| 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 == NULL) |
| 278 return NULL; | 278 return NULL; |
| 279 const SkMemberInfo* field = getField(element, fieldID); | 279 const SkMemberInfo* field = getField(element, fieldID); |
| 280 if (field == NULL) | 280 if (field == NULL) |
| 281 return NULL; | 281 return NULL; |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 #ifdef SK_SUPPORT_UNITTEST | 667 #ifdef SK_SUPPORT_UNITTEST |
| 668 #include "SkAnimatorScript.h" | 668 #include "SkAnimatorScript.h" |
| 669 #include "SkBase64.h" | 669 #include "SkBase64.h" |
| 670 #include "SkParse.h" | 670 #include "SkParse.h" |
| 671 #include "SkMemberInfo.h" | 671 #include "SkMemberInfo.h" |
| 672 | 672 |
| 673 #define unittestline(type) { #type , type::UnitTest } | 673 #define unittestline(type) { #type , type::UnitTest } |
| 674 #endif | 674 #endif |
| 675 | 675 |
| 676 | 676 |
| 677 #ifdef SK_SUPPORT_UNITTEST |
| 677 void SkAnimator::Init(bool runUnitTests) { | 678 void SkAnimator::Init(bool runUnitTests) { |
| 678 #ifdef SK_SUPPORT_UNITTEST | |
| 679 if (runUnitTests == false) | 679 if (runUnitTests == false) |
| 680 return; | 680 return; |
| 681 static const struct { | 681 static const struct { |
| 682 const char* fTypeName; | 682 const char* fTypeName; |
| 683 void (*fUnitTest)( ); | 683 void (*fUnitTest)( ); |
| 684 } gUnitTests[] = { | 684 } gUnitTests[] = { |
| 685 unittestline(SkBase64), | 685 unittestline(SkBase64), |
| 686 unittestline(SkDisplayType), | 686 unittestline(SkDisplayType), |
| 687 unittestline(SkParse), | 687 unittestline(SkParse), |
| 688 unittestline(SkScriptEngine), | 688 unittestline(SkScriptEngine), |
| 689 // unittestline(SkScriptEngine2), // compiled script experiment | 689 // unittestline(SkScriptEngine2), // compiled script experiment |
| 690 unittestline(SkAnimatorScript) | 690 unittestline(SkAnimatorScript) |
| 691 }; | 691 }; |
| 692 for (int i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++) | 692 for (int i = 0; i < (int)SK_ARRAY_COUNT(gUnitTests); i++) |
| 693 { | 693 { |
| 694 SkDebugf("SkAnimator: Running UnitTest for %s\n", gUnitTests[i].fTypeNam
e); | 694 SkDebugf("SkAnimator: Running UnitTest for %s\n", gUnitTests[i].fTypeNam
e); |
| 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 } |
| 699 #else |
| 700 void SkAnimator::Init(bool) {} |
| 698 #endif | 701 #endif |
| 699 } | |
| 700 | 702 |
| 701 void SkAnimator::Term() { | 703 void SkAnimator::Term() { |
| 702 } | 704 } |
| OLD | NEW |