gfx/skia/trunk/src/animator/SkAnimateSet.cpp

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

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

mercurial