180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/* 380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project 480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * 580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be 680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file. 780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */ 880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAnimateSet.h" 1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAnimateMaker.h" 1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkAnimateProperties.h" 1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkParse.h" 1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#if SK_USE_CONDENSED_INFO == 0 1680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruconst SkMemberInfo SkSet::fInfo[] = { 1880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(begin, MSec), 1980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(dur, MSec), 2080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER_PROPERTY(dynamic, Boolean), 2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(field, String), 2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// SK_MEMBER(formula, DynamicString), 2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(lval, DynamicString), 2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru// SK_MEMBER_PROPERTY(reset, Boolean), 2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER_PROPERTY(step, Int), 2680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(target, DynamicString), 2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SK_MEMBER(to, DynamicString) 2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru}; 2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruDEFINE_GET_MEMBER(SkSet); 3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste QueruSkSet::SkSet() { 3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru dur = 1; 3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_DUMP_ENABLED 3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkSet::dump(SkAnimateMaker* maker) { 4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru INHERITED::dump(maker); 4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (dur != 1) { 4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000))); 4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru //don't want double />\n's 4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDebugf("/>\n"); 4680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 4780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif 4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkSet::refresh(SkAnimateMaker& maker) { 5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, NULL, 5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFieldInfo->getType(), to); 5380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru 5580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruvoid SkSet::onEndElement(SkAnimateMaker& maker) { 5680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (resolveCommon(maker) == false) 5780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return; 5880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fFieldInfo == NULL) { 5980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget); 6080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru return; 6180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 6280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fReset = dur != 1; 6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkDisplayTypes outType = fFieldInfo->getType(); 6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 : 6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int); 6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fValues.getType() == SkType_Unknown) { 6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fValues.setType(outType); 6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fValues.setCount(comps); 6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (outType == SkType_String || outType == SkType_DynamicString) 7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fValues[0].fString = SkNEW(SkString); 7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru else 7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0])); 7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } else { 7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkASSERT(fValues.getType() == outType); 7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (fFieldInfo->fType == SkType_Array) 7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru comps = fValues.count(); 7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru else { 7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru SkASSERT(fValues.count() == comps); 7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru if (formula.size() > 0) { 8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru comps = 1; 8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru outType = SkType_MSec; 8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru } 8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to); 8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru fComponents = fValues.count(); 8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru} 88