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 SkDebugf("dur=\"%g\" ", dur * 0.001); 43 } 44 //don't want double />\n's 45 SkDebugf("/>\n"); 46 47 } 48 #endif 49 50 void SkSet::refresh(SkAnimateMaker& maker) { 51 fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, nullptr, 52 fFieldInfo->getType(), to); 53 } 54 55 void SkSet::onEndElement(SkAnimateMaker& maker) { 56 if (resolveCommon(maker) == false) 57 return; 58 if (fFieldInfo == nullptr) { 59 maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); 60 return; 61 } 62 fReset = dur != 1; 63 SkDisplayTypes outType = fFieldInfo->getType(); 64 int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 : 65 (int)fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int); 66 if (fValues.getType() == SkType_Unknown) { 67 fValues.setType(outType); 68 fValues.setCount(comps); 69 if (outType == SkType_String || outType == SkType_DynamicString) 70 fValues[0].fString = new SkString; 71 else 72 memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0])); 73 } else { 74 SkASSERT(fValues.getType() == outType); 75 if (fFieldInfo->fType == SkType_Array) 76 comps = fValues.count(); 77 else { 78 SkASSERT(fValues.count() == comps); 79 } 80 } 81 if (formula.size() > 0) { 82 comps = 1; 83 outType = SkType_MSec; 84 } 85 fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to); 86 fComponents = fValues.count(); 87 } 88