10910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project/* libs/graphics/animator/SkAnimateBase.cpp 20910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** 30910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** Copyright 2006, The Android Open Source Project 40910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** 50910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** Licensed under the Apache License, Version 2.0 (the "License"); 60910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** you may not use this file except in compliance with the License. 70910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** You may obtain a copy of the License at 80910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** 90910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** http://www.apache.org/licenses/LICENSE-2.0 100910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** 110910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** Unless required by applicable law or agreed to in writing, software 120910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** distributed under the License is distributed on an "AS IS" BASIS, 130910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 140910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** See the License for the specific language governing permissions and 150910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project** limitations under the License. 160910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project*/ 170910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 180910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkAnimateBase.h" 190910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkAnimateMaker.h" 200910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkAnimateProperties.h" 210910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkAnimatorScript.h" 220910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkDisplayApply.h" 230910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#include "SkDrawable.h" 240910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 250910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#if SK_USE_CONDENSED_INFO == 0 260910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 270910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectconst SkMemberInfo SkAnimateBase::fInfo[] = { 280910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(begin, MSec), 290910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_ARRAY(blend, Float), 300910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(dur, MSec), 310910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_PROPERTY(dynamic, Boolean), 320910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(field, String), // name of member info in target 330910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(formula, DynamicString), 340910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(from, DynamicString), 350910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(lval, DynamicString), 360910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_PROPERTY(mirror, Boolean), 370910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(repeat, Float), 380910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_PROPERTY(reset, Boolean), 390910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_PROPERTY(step, Int), 400910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(target, DynamicString), 410910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER(to, DynamicString), 420910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SK_MEMBER_PROPERTY(values, DynamicString) 430910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project}; 440910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 450910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#endif 460910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 470910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectDEFINE_GET_MEMBER(SkAnimateBase); 480910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 490910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectSkAnimateBase::SkAnimateBase() : begin(0), dur(1), repeat(SK_Scalar1), 500910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fApply(NULL), fFieldInfo(NULL), fFieldOffset(0), fStart((SkMSec) -1), fTarget(NULL), 510910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fChanged(0), fDelayed(0), fDynamic(0), fHasEndEvent(0), fHasValues(0), 520910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fMirror(0), fReset(0), fResetPending(0), fTargetIsScope(0) { 530910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project blend.setCount(1); 540910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project blend[0] = SK_Scalar1; 550910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 560910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 570910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectSkAnimateBase::~SkAnimateBase() { 580910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDisplayTypes type = fValues.getType(); 590910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (type == SkType_String || type == SkType_DynamicString) { 600910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(fValues.count() == 1); 610910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project delete fValues[0].fString; 620910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 630910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 640910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 650910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectint SkAnimateBase::components() { 660910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return 1; 670910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 680910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 690910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectSkDisplayable* SkAnimateBase::deepCopy(SkAnimateMaker* maker) { 700910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkAnimateBase* result = (SkAnimateBase*) INHERITED::deepCopy(maker); 710910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project result->fApply = fApply; 720910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project result->fFieldInfo =fFieldInfo; 730910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project result->fHasValues = false; 740910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return result; 750910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 760910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 770910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::dirty() { 780910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fChanged = true; 790910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 800910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 810910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#ifdef SK_DUMP_ENABLED 820910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::dump(SkAnimateMaker* maker) { 830910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project dumpBase(maker); 840910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (target.size() > 0) 850910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("target=\"%s\" ", target.c_str()); 860910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project else if (fTarget && strcmp(fTarget->id, "")) 870910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("target=\"%s\" ", fTarget->id); 880910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (lval.size() > 0) 890910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("lval=\"%s\" ", lval.c_str()); 900910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (field.size() > 0) 910910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("field=\"%s\" ", field.c_str()); 920910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project else if (fFieldInfo) 930910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("field=\"%s\" ", fFieldInfo->fName); 940910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (formula.size() > 0) 950910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("formula=\"%s\" ", formula.c_str()); 960910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project else { 970910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (from.size() > 0) 980910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("from=\"%s\" ", from.c_str()); 990910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("to=\"%s\" ", to.c_str()); 1000910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 1010910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (begin != 0) { 1020910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#ifdef SK_CAN_USE_FLOAT 1030910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("begin=\"%g\" ", SkScalarToFloat(SkScalarDiv(begin,1000))); 1040910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#else 1050910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkDebugf("begin=\"%x\" ", SkScalarDiv(begin,1000)); 1060910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#endif 1070910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 1080910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1090910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project#endif 1100910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1110910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectSkDisplayable* SkAnimateBase::getParent() const { 1120910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return (SkDisplayable*) fApply; 1130910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1140910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1150910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectbool SkAnimateBase::getProperty(int index, SkScriptValue* value) const { 1160910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project int boolResult; 1170910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project switch (index) { 1180910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(dynamic): 1190910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project boolResult = fDynamic; 1200910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project goto returnBool; 1210910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(mirror): 1220910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project boolResult = fMirror; 1230910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project goto returnBool; 1240910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(reset): 1250910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project boolResult = fReset; 1260910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectreturnBool: 1270910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project value->fOperand.fS32 = SkToBool(boolResult); 1280910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project value->fType = SkType_Boolean; 1290910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project break; 1300910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(step): 1310910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (fApply == NULL) 1320910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; // !!! notify there's an error? 1330910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fApply->getStep(value); 1340910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project break; 1350910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(values): 1360910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project value->fOperand.fString = (SkString*) &to; 1370910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project value->fType = SkType_String; 1380910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project break; 1390910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project default: 1400910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(0); 1410910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; 1420910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 1430910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return true; 1440910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1450910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1460910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectbool SkAnimateBase::hasExecute() const 1470910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project{ 1480910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; 1490910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1500910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1510910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::onEndElement(SkAnimateMaker& maker) { 1520910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fChanged = false; 1530910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project setTarget(maker); 1540910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (field.size()) { 1550910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(fTarget); 1560910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fFieldInfo = fTarget->getMember(field.c_str()); 1570910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project field.reset(); 1580910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 1590910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (lval.size()) { 1600910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project // lval must be of the form x[y] 1610910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project const char* lvalStr = lval.c_str(); 1620910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project const char* arrayEnd = strchr(lvalStr, '['); 1630910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (arrayEnd == NULL) 1640910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return; //should this return an error? 1650910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project size_t arrayNameLen = arrayEnd - lvalStr; 1660910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkString arrayStr(lvalStr, arrayNameLen); 1670910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(fTarget); //this return an error? 1680910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fFieldInfo = fTarget->getMember(arrayStr.c_str()); 1690910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkString scriptStr(arrayEnd + 1, lval.size() - arrayNameLen - 2); 1700910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkAnimatorScript::EvaluateInt(maker, this, scriptStr.c_str(), &fFieldOffset); 1710910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 1720910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1730910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1740910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::packARGB(SkScalar array[], int count, SkTDOperandArray* converted) 1750910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project{ 1760910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(count == 4); 1770910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project converted->setCount(1); 1780910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkColor color = SkColorSetARGB(SkScalarRound(array[0]), SkScalarRound(array[1]), 1790910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkScalarRound(array[2]), SkScalarRound(array[3])); 1800910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project (*converted)[0].fS32 = color; 1810910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1820910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1830910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1840910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1850910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::refresh(SkAnimateMaker& ) { 1860910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1870910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1880910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectbool SkAnimateBase::setParent(SkDisplayable* apply) { 1890910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(apply->isApply()); 1900910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fApply = (SkApply*) apply; 1910910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; 1920910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 1930910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 1940910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectbool SkAnimateBase::setProperty(int index, SkScriptValue& value) { 1950910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project bool boolValue = SkToBool(value.fOperand.fS32); 1960910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project switch (index) { 1970910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(dynamic): 1980910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fDynamic = boolValue; 1990910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project goto checkForBool; 2000910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(values): 2010910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fHasValues = true; 2020910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(value.fType == SkType_String); 2030910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project to = *value.fOperand.fString; 2040910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project break; 2050910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(mirror): 2060910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fMirror = boolValue; 2070910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project goto checkForBool; 2080910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project case SK_PROPERTY(reset): 2090910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fReset = boolValue; 2100910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source ProjectcheckForBool: 2110910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkASSERT(value.fType == SkType_Boolean); 2120910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project break; 2130910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project default: 2140910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; 2150910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 2160910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return true; 2170910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 2180910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 2190910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectvoid SkAnimateBase::setTarget(SkAnimateMaker& maker) { 2200910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (target.size()) { 2210910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkAnimatorScript engine(maker, this, SkType_Displayable); 2220910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project const char* script = target.c_str(); 2230910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project SkScriptValue scriptValue; 2240910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project bool success = engine.evaluateScript(&script, &scriptValue); 2250910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (success && scriptValue.fType == SkType_Displayable) 2260910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project fTarget = scriptValue.fOperand.fDrawable; 2270910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project else if (maker.find(target.c_str(), (SkDisplayable**) &fTarget) == false) { 2280910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (fApply->getMode() == SkApply::kMode_create) 2290910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return; // may not be an error 2300910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (engine.getError() != SkScriptEngine::kNoError) 2310910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project maker.setScriptError(engine); 2320910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project else { 2330910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project maker.setErrorNoun(target); 2340910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project maker.setErrorCode(SkDisplayXMLParserError::kTargetIDNotFound); 2350910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 2360910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return; 2370910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 2380910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project if (fApply && fApply->getMode() != SkApply::kMode_create) 2390910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project target.reset(); 2400910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project } 2410910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 2420910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 2430910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Projectbool SkAnimateBase::targetNeedsInitialization() const { 2440910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project return false; 2450910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project} 2460910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 2470910916c0f7b951ee55c4b7c6358295b9bca0565The Android Open Source Project 248