epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
| 3 | * Copyright 2006 The Android Open Source Project |
| 4 | * |
| 5 | * Use of this source code is governed by a BSD-style license that can be |
| 6 | * found in the LICENSE file. |
| 7 | */ |
| 8 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 9 | |
| 10 | #include "SkPostParts.h" |
| 11 | #include "SkDisplayPost.h" |
| 12 | |
| 13 | #if SK_USE_CONDENSED_INFO == 0 |
| 14 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 15 | const SkMemberInfo SkDataInput::fInfo[] = { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 16 | SK_MEMBER_INHERITED |
| 17 | }; |
| 18 | |
| 19 | #endif |
| 20 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 21 | DEFINE_GET_MEMBER(SkDataInput); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 22 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 23 | SkDataInput::SkDataInput() : fParent(NULL) {} |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 25 | bool SkDataInput::add() { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | SkASSERT(name.size() > 0); |
| 27 | const char* dataName = name.c_str(); |
| 28 | if (fInt != (int) SK_NaN32) |
| 29 | fParent->fEvent.setS32(dataName, fInt); |
| 30 | else if (SkScalarIsNaN(fFloat) == false) |
| 31 | fParent->fEvent.setScalar(dataName, fFloat); |
| 32 | else if (string.size() > 0) |
| 33 | fParent->fEvent.setString(dataName, string); |
| 34 | // else |
| 35 | // SkASSERT(0); |
| 36 | return false; |
| 37 | } |
| 38 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 39 | void SkDataInput::dirty() { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | fParent->dirty(); |
| 41 | } |
| 42 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 43 | SkDisplayable* SkDataInput::getParent() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | return fParent; |
| 45 | } |
| 46 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 47 | bool SkDataInput::setParent(SkDisplayable* displayable) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 48 | if (displayable->isPost() == false) |
| 49 | return true; |
| 50 | fParent = (SkPost*) displayable; |
| 51 | return false; |
| 52 | } |
| 53 | |
reed@google.com | 8d0b577 | 2011-06-24 13:07:31 +0000 | [diff] [blame] | 54 | void SkDataInput::onEndElement(SkAnimateMaker&) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 55 | add(); |
| 56 | } |
| 57 | |