1 2 /* 3 * Copyright 2006 The Android Open Source Project 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 10 #include "SkAnimateSet.h" 11 #include "SkAnimateMaker.h" 12 #include "SkAnimateProperties.h" 13 #include "SkParse.h" 14 15 #if SK_USE_CONDENSED_INFO == 0 16 17 const SkMemberInfo SkSet::fInfo[] = { 18 SK_MEMBER(begin, MSec), 19 SK_MEMBER(dur, MSec), 20 SK_MEMBER_PROPERTY(dynamic, Boolean), 21 SK_MEMBER(field, String), 22 // SK_MEMBER(formula, DynamicString), 23 SK_MEMBER(lval, DynamicString), 24 // SK_MEMBER_PROPERTY(reset, Boolean), 25 SK_MEMBER_PROPERTY(step, Int), 26 SK_MEMBER(target, DynamicString), 27 SK_MEMBER(to, DynamicString) 28 }; 29 30 #endif 31 32 DEFINE_GET_MEMBER(SkSet); 33 34 SkSet::SkSet() { 35 dur = 1; 36 } 37 38 #ifdef SK_DUMP_ENABLED 39 void SkSet::dump(SkAnimateMaker* maker) { 40 INHERITED::dump(maker); 41 if (dur != 1) { 42 #ifdef SK_CAN_USE_FLOAT 43 SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000))); 44 #else 45 SkDebugf("dur=\"%x\" ", SkScalarDiv(dur,1000)); 46 #endif 47 } 48 //don't want double />\n's 49 SkDebugf("/>\n"); 50 51 } 52 #endif 53 54 void SkSet::refresh(SkAnimateMaker& maker) { 55 fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, NULL, 56 fFieldInfo->getType(), to); 57 } 58 59 void SkSet::onEndElement(SkAnimateMaker& maker) { 60 if (resolveCommon(maker) == false) 61 return; 62 if (fFieldInfo == NULL) { 63 maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); 64 return; 65 } 66 fReset = dur != 1; 67 SkDisplayTypes outType = fFieldInfo->getType(); 68 int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 : 69 fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int); 70 if (fValues.getType() == SkType_Unknown) { 71 fValues.setType(outType); 72 fValues.setCount(comps); 73 if (outType == SkType_String || outType == SkType_DynamicString) 74 fValues[0].fString = SkNEW(SkString); 75 else 76 memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0])); 77 } else { 78 SkASSERT(fValues.getType() == outType); 79 if (fFieldInfo->fType == SkType_Array) 80 comps = fValues.count(); 81 else { 82 SkASSERT(fValues.count() == comps); 83 } 84 } 85 if (formula.size() > 0) { 86 comps = 1; 87 outType = SkType_MSec; 88 } 89 fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to); 90 fComponents = fValues.count(); 91 } 92