1 /* libs/graphics/animator/SkPostParts.cpp 2 ** 3 ** Copyright 2006, The Android Open Source Project 4 ** 5 ** Licensed under the Apache License, Version 2.0 (the "License"); 6 ** you may not use this file except in compliance with the License. 7 ** You may obtain a copy of the License at 8 ** 9 ** http://www.apache.org/licenses/LICENSE-2.0 10 ** 11 ** Unless required by applicable law or agreed to in writing, software 12 ** distributed under the License is distributed on an "AS IS" BASIS, 13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 ** See the License for the specific language governing permissions and 15 ** limitations under the License. 16 */ 17 18 #include "SkPostParts.h" 19 #include "SkDisplayPost.h" 20 21 #if SK_USE_CONDENSED_INFO == 0 22 23 const SkMemberInfo SkData::fInfo[] = { 24 SK_MEMBER_INHERITED 25 }; 26 27 #endif 28 29 DEFINE_GET_MEMBER(SkData); 30 31 SkData::SkData() : fParent(NULL) {} 32 33 bool SkData::add() { 34 SkASSERT(name.size() > 0); 35 const char* dataName = name.c_str(); 36 if (fInt != (int) SK_NaN32) 37 fParent->fEvent.setS32(dataName, fInt); 38 else if (SkScalarIsNaN(fFloat) == false) 39 fParent->fEvent.setScalar(dataName, fFloat); 40 else if (string.size() > 0) 41 fParent->fEvent.setString(dataName, string); 42 // else 43 // SkASSERT(0); 44 return false; 45 } 46 47 void SkData::dirty() { 48 fParent->dirty(); 49 } 50 51 SkDisplayable* SkData::getParent() const { 52 return fParent; 53 } 54 55 bool SkData::setParent(SkDisplayable* displayable) { 56 if (displayable->isPost() == false) 57 return true; 58 fParent = (SkPost*) displayable; 59 return false; 60 } 61 62 void SkData::onEndElement(SkAnimateMaker&) { 63 add(); 64 } 65 66