1 /* libs/graphics/animator/SkAnimateActive.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 SkAnimateActive_DEFINED 19 #define SkAnimateActive_DEFINED 20 21 #include "SkDisplayApply.h" 22 #include "SkOperandInterpolator.h" 23 #include "SkIntArray.h" 24 25 class SkAnimateMaker; 26 27 class SkActive { 28 public: 29 SkActive(SkApply& , SkAnimateMaker& ); 30 ~SkActive(); 31 void advance(); 32 void append(SkApply* ); 33 void calcDurations(int index); 34 void create(SkDrawable* scope, SkMSec time); 35 bool draw() { return immediate(false); } 36 bool enable() { return immediate(true); } 37 void init( ); 38 SkMSec getTime(SkMSec inTime, int animatorIndex); 39 void pickUp(SkActive* existing); 40 void reset() { fDrawIndex = 0; } 41 void setInterpolator(int index, SkOperand* from); 42 void start(); 43 #ifdef SK_DEBUG 44 void validate(); 45 #endif 46 private: 47 void appendSave(int oldCount); 48 void fixInterpolator(SkBool save); 49 bool immediate(bool enable); 50 bool initializeSave(); 51 void initState(SkApply* , int offset); 52 void resetInterpolators(); 53 void resetState(); 54 void restoreInterpolatorValues(int index); 55 void saveInterpolatorValues(int index); 56 void setSteps(int steps); 57 struct SkState { 58 // void bumpSave(); 59 SkMSec getRelativeTime(SkMSec time); 60 SkApply::Mode fMode; 61 SkApply::Transition fTransition; 62 SkBool8 fPickup; 63 SkBool8 fRestore; 64 SkBool8 fStarted; 65 SkBool8 fUnpostedEndEvent; 66 int32_t fSteps; 67 SkMSec fBegin; 68 SkMSec fStartTime; 69 SkMSec fDuration; 70 SkMSec fSave; 71 SkMSec fTicks; 72 }; 73 SkActive& operator= (const SkActive& ); 74 SkTDArray<SkOperandInterpolator*> fInterpolators; 75 SkApply& fApply; 76 SkTDArray<SkState> fState; // one per animator 77 SkTDOperandPtrArray fSaveRestore; // if apply has restore="true" 78 SkTDOperandPtrArray fSaveInterpolators; 79 SkTDAnimateArray fAnimators; 80 SkMSec fMaxTime; // greatest of all animation durations; only used by immediate mode 81 SkAnimateMaker& fMaker; 82 int fDrawIndex; 83 int fDrawMax; 84 friend class SkApply; 85 }; 86 87 #endif // SkAnimateActive_DEFINED 88