reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame^] | 1 | /* libs/graphics/animator/SkAnimateBase.h |
| 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 | #ifndef SkAnimateBase_DEFINED |
| 19 | #define SkAnimateBase_DEFINED |
| 20 | |
| 21 | #include "SkDisplayable.h" |
| 22 | #include "SkMath.h" |
| 23 | #include "SkMemberInfo.h" |
| 24 | #include "SkTypedArray.h" |
| 25 | |
| 26 | class SkApply; |
| 27 | class SkDrawable; |
| 28 | |
| 29 | class SkAnimateBase : public SkDisplayable { |
| 30 | public: |
| 31 | DECLARE_MEMBER_INFO(AnimateBase); |
| 32 | SkAnimateBase(); |
| 33 | virtual ~SkAnimateBase(); |
| 34 | virtual int components(); |
| 35 | virtual SkDisplayable* deepCopy(SkAnimateMaker* ); |
| 36 | virtual void dirty(); |
| 37 | #ifdef SK_DUMP_ENABLED |
| 38 | virtual void dump(SkAnimateMaker* ); |
| 39 | #endif |
| 40 | int entries() { return fValues.count() / components(); } |
| 41 | virtual bool hasExecute() const; |
| 42 | bool isDynamic() const { return SkToBool(fDynamic); } |
| 43 | virtual SkDisplayable* getParent() const; |
| 44 | virtual bool getProperty(int index, SkScriptValue* value) const; |
| 45 | SkMSec getStart() const { return fStart; } |
| 46 | SkOperand* getValues() { return fValues.begin(); } |
| 47 | SkDisplayTypes getValuesType() { return fValues.getType(); } |
| 48 | virtual void onEndElement(SkAnimateMaker& ); |
| 49 | void packARGB(SkScalar [], int count, SkTDOperandArray* ); |
| 50 | virtual void refresh(SkAnimateMaker& ); |
| 51 | void setChanged(bool changed) { fChanged = changed; } |
| 52 | void setHasEndEvent() { fHasEndEvent = true; } |
| 53 | virtual bool setParent(SkDisplayable* ); |
| 54 | virtual bool setProperty(int index, SkScriptValue& value); |
| 55 | void setTarget(SkAnimateMaker& ); |
| 56 | virtual bool targetNeedsInitialization() const; |
| 57 | protected: |
| 58 | SkMSec begin; |
| 59 | SkTDScalarArray blend; |
| 60 | SkMSec dur; |
| 61 | // !!! make field part of a union with fFieldInfo, or fValues, something known later? |
| 62 | SkString field; // temporary; once target is known, this is reset |
| 63 | SkString formula; |
| 64 | SkString from; |
| 65 | SkString lval; |
| 66 | SkScalar repeat; |
| 67 | SkString target; // temporary; once target is known, this is reset |
| 68 | SkString to; |
| 69 | SkApply* fApply; |
| 70 | const SkMemberInfo* fFieldInfo; |
| 71 | int fFieldOffset; |
| 72 | SkMSec fStart; // corrected time when this apply was enabled |
| 73 | SkDrawable* fTarget; |
| 74 | SkTypedArray fValues; |
| 75 | unsigned fChanged : 1; // true when value referenced by script has changed |
| 76 | unsigned fDelayed : 1; // enabled, but undrawn pending delay |
| 77 | unsigned fDynamic : 1; |
| 78 | unsigned fHasEndEvent : 1; |
| 79 | unsigned fHasValues : 1; // set if 'values' passed instead of 'to' |
| 80 | unsigned fMirror : 1; |
| 81 | unsigned fReset : 1; |
| 82 | unsigned fResetPending : 1; |
| 83 | unsigned fTargetIsScope : 1; |
| 84 | private: |
| 85 | typedef SkDisplayable INHERITED; |
| 86 | friend class SkActive; |
| 87 | friend class SkApply; |
| 88 | friend class SkDisplayList; |
| 89 | }; |
| 90 | |
| 91 | #endif // SkAnimateBase_DEFINED |