michael@0: michael@0: /* michael@0: * Copyright 2006 The Android Open Source Project michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: michael@0: #include "SkAnimateSet.h" michael@0: #include "SkAnimateMaker.h" michael@0: #include "SkAnimateProperties.h" michael@0: #include "SkParse.h" michael@0: michael@0: #if SK_USE_CONDENSED_INFO == 0 michael@0: michael@0: const SkMemberInfo SkSet::fInfo[] = { michael@0: SK_MEMBER(begin, MSec), michael@0: SK_MEMBER(dur, MSec), michael@0: SK_MEMBER_PROPERTY(dynamic, Boolean), michael@0: SK_MEMBER(field, String), michael@0: // SK_MEMBER(formula, DynamicString), michael@0: SK_MEMBER(lval, DynamicString), michael@0: // SK_MEMBER_PROPERTY(reset, Boolean), michael@0: SK_MEMBER_PROPERTY(step, Int), michael@0: SK_MEMBER(target, DynamicString), michael@0: SK_MEMBER(to, DynamicString) michael@0: }; michael@0: michael@0: #endif michael@0: michael@0: DEFINE_GET_MEMBER(SkSet); michael@0: michael@0: SkSet::SkSet() { michael@0: dur = 1; michael@0: } michael@0: michael@0: #ifdef SK_DUMP_ENABLED michael@0: void SkSet::dump(SkAnimateMaker* maker) { michael@0: INHERITED::dump(maker); michael@0: if (dur != 1) { michael@0: SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000))); michael@0: } michael@0: //don't want double />\n's michael@0: SkDebugf("/>\n"); michael@0: michael@0: } michael@0: #endif michael@0: michael@0: void SkSet::refresh(SkAnimateMaker& maker) { michael@0: fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, NULL, michael@0: fFieldInfo->getType(), to); michael@0: } michael@0: michael@0: void SkSet::onEndElement(SkAnimateMaker& maker) { michael@0: if (resolveCommon(maker) == false) michael@0: return; michael@0: if (fFieldInfo == NULL) { michael@0: maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); michael@0: return; michael@0: } michael@0: fReset = dur != 1; michael@0: SkDisplayTypes outType = fFieldInfo->getType(); michael@0: int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 : michael@0: fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int); michael@0: if (fValues.getType() == SkType_Unknown) { michael@0: fValues.setType(outType); michael@0: fValues.setCount(comps); michael@0: if (outType == SkType_String || outType == SkType_DynamicString) michael@0: fValues[0].fString = SkNEW(SkString); michael@0: else michael@0: memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0])); michael@0: } else { michael@0: SkASSERT(fValues.getType() == outType); michael@0: if (fFieldInfo->fType == SkType_Array) michael@0: comps = fValues.count(); michael@0: else { michael@0: SkASSERT(fValues.count() == comps); michael@0: } michael@0: } michael@0: if (formula.size() > 0) { michael@0: comps = 1; michael@0: outType = SkType_MSec; michael@0: } michael@0: fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to); michael@0: fComponents = fValues.count(); michael@0: }