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