gfx/skia/trunk/src/animator/SkAnimateField.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 "SkAnimate.h"
michael@0 11 #include "SkAnimateMaker.h"
michael@0 12 #include "SkDrawable.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 SkAnimate::fInfo[] = {
michael@0 18 SK_MEMBER_INHERITED
michael@0 19 };
michael@0 20
michael@0 21 #endif
michael@0 22
michael@0 23 DEFINE_GET_MEMBER(SkAnimate);
michael@0 24
michael@0 25 SkAnimate::SkAnimate() : fComponents(0) {
michael@0 26 }
michael@0 27
michael@0 28 SkAnimate::~SkAnimate() {
michael@0 29 }
michael@0 30
michael@0 31 int SkAnimate::components() {
michael@0 32 return fComponents;
michael@0 33 }
michael@0 34
michael@0 35 #ifdef SK_DUMP_ENABLED
michael@0 36 void SkAnimate::dump(SkAnimateMaker* maker) {
michael@0 37 INHERITED::dump(maker); //from animateBase
michael@0 38 //SkSet inherits from this class
michael@0 39 if (getType() != SkType_Set) {
michael@0 40 if (fMirror)
michael@0 41 SkDebugf("mirror=\"true\" ");
michael@0 42 if (fReset)
michael@0 43 SkDebugf("reset=\"true\" ");
michael@0 44 SkDebugf("dur=\"%g\" ", SkScalarToFloat(SkScalarDiv(dur,1000)));
michael@0 45 if (repeat != SK_Scalar1)
michael@0 46 SkDebugf("repeat=\"%g\" ", SkScalarToFloat(repeat));
michael@0 47 //if (fHasValues)
michael@0 48 // SkDebugf("values=\"%s\" ", values);
michael@0 49 if (blend.count() != 1 || blend[0] != SK_Scalar1) {
michael@0 50 SkDebugf("blend=\"[");
michael@0 51 bool firstElem = true;
michael@0 52 for (int i = 0; i < blend.count(); i++) {
michael@0 53 if (!firstElem)
michael@0 54 SkDebugf(",");
michael@0 55 firstElem = false;
michael@0 56 SkDebugf("%g", SkScalarToFloat(blend[i]));
michael@0 57 }
michael@0 58 SkDebugf("]\" ");
michael@0 59 }
michael@0 60 SkDebugf("/>\n");//i assume that if it IS, we will do it separately
michael@0 61 }
michael@0 62 }
michael@0 63 #endif
michael@0 64
michael@0 65 bool SkAnimate::resolveCommon(SkAnimateMaker& maker) {
michael@0 66 if (fTarget == NULL) // if NULL, recall onEndElement after apply closes and sets target to scope
michael@0 67 return false;
michael@0 68 INHERITED::onEndElement(maker);
michael@0 69 return maker.hasError() == false;
michael@0 70 }
michael@0 71
michael@0 72 void SkAnimate::onEndElement(SkAnimateMaker& maker) {
michael@0 73 bool resolved = resolveCommon(maker);
michael@0 74 if (resolved && fFieldInfo == NULL) {
michael@0 75 maker.setErrorNoun(field);
michael@0 76 maker.setErrorCode(SkDisplayXMLParserError::kFieldNotInTarget);
michael@0 77 }
michael@0 78 if (resolved == false || fFieldInfo == NULL)
michael@0 79 return;
michael@0 80 SkDisplayTypes outType = fFieldInfo->getType();
michael@0 81 if (fHasValues) {
michael@0 82 SkASSERT(to.size() > 0);
michael@0 83 fFieldInfo->setValue(maker, &fValues, 0, 0, NULL, outType, to);
michael@0 84 SkASSERT(0);
michael@0 85 // !!! this needs to set fComponents
michael@0 86 return;
michael@0 87 }
michael@0 88 fComponents = fFieldInfo->getCount();
michael@0 89 if (fFieldInfo->fType == SkType_Array) {
michael@0 90 SkTypedArray* array = (SkTypedArray*) fFieldInfo->memberData(fTarget);
michael@0 91 int count = array->count();
michael@0 92 if (count > 0)
michael@0 93 fComponents = count;
michael@0 94 }
michael@0 95 if (outType == SkType_ARGB) {
michael@0 96 fComponents <<= 2; // four color components
michael@0 97 outType = SkType_Float;
michael@0 98 }
michael@0 99 fValues.setType(outType);
michael@0 100 if (formula.size() > 0){
michael@0 101 fComponents = 1;
michael@0 102 from.set("0");
michael@0 103 to.set("dur");
michael@0 104 outType = SkType_MSec;
michael@0 105 }
michael@0 106 int max = fComponents * 2;
michael@0 107 fValues.setCount(max);
michael@0 108 memset(fValues.begin(), 0, max * sizeof(fValues.begin()[0]));
michael@0 109 fFieldInfo->setValue(maker, &fValues, fFieldOffset, max, this, outType, from);
michael@0 110 fFieldInfo->setValue(maker, &fValues, fComponents + fFieldOffset, max, this, outType, to);
michael@0 111 }

mercurial