1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/*
3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com *
5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com */
8ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateSet.h"
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateMaker.h"
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkAnimateProperties.h"
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkParse.h"
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#if SK_USE_CONDENSED_INFO == 0
168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comconst SkMemberInfo SkSet::fInfo[] = {
188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(begin, MSec),
198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(dur, MSec),
208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(dynamic, Boolean),
218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(field, String),
228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  SK_MEMBER(formula, DynamicString),
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(lval, DynamicString),
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//  SK_MEMBER_PROPERTY(reset, Boolean),
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER_PROPERTY(step, Int),
268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(target, DynamicString),
278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SK_MEMBER(to, DynamicString)
288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comDEFINE_GET_MEMBER(SkSet);
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comSkSet::SkSet() {
35d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    dur = 1;
368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifdef SK_DUMP_ENABLED
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkSet::dump(SkAnimateMaker* maker) {
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    INHERITED::dump(maker);
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (dur != 1) {
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    //don't want double />\n's
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDebugf("/>\n");
468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkSet::refresh(SkAnimateMaker& maker) {
51d6176b0dcacb124539e0cfd051e6d93a9782f020rmistry@google.com    fFieldInfo->setValue(maker, &fValues, 0, fFieldInfo->fCount, NULL,
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fFieldInfo->getType(), to);
538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comvoid SkSet::onEndElement(SkAnimateMaker& maker) {
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (resolveCommon(maker) == false)
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return;
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (fFieldInfo == NULL) {
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return;
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fReset = dur != 1;
638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDisplayTypes outType = fFieldInfo->getType();
648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int comps = outType == SkType_String || outType == SkType_DynamicString ? 1 :
6592f93264e760b74cc706d01b2d0fcfaa3d857f51commit-bot@chromium.org        (int)fFieldInfo->getSize((const SkDisplayable*) fTarget) / sizeof(int);
668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (fValues.getType() == SkType_Unknown) {
678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fValues.setType(outType);
688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fValues.setCount(comps);
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        if (outType == SkType_String || outType == SkType_DynamicString)
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            fValues[0].fString = SkNEW(SkString);
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        else
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            memset(fValues.begin(), 0, fValues.count() * sizeof(fValues.begin()[0]));
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    } else {
748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkASSERT(fValues.getType() == outType);
758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        if (fFieldInfo->fType == SkType_Array)
768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            comps = fValues.count();
77a7ed3cc6371e50a5beb3750c475fe23665dafa7dtomhudson@google.com        else {
788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            SkASSERT(fValues.count() == comps);
79a7ed3cc6371e50a5beb3750c475fe23665dafa7dtomhudson@google.com        }
808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    if (formula.size() > 0) {
828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        comps = 1;
838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        outType = SkType_MSec;
848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fFieldInfo->setValue(maker, &fValues, fFieldOffset, comps, this, outType, formula.size() > 0 ? formula : to);
868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    fComponents = fValues.count();
878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}
88