SMIL:Animation Controller

From MozillaWiki
Jump to: navigation, search

We need the following features from a global animation controller:

  • Register and unregister active animations
  • Periodically invoke a callback on each active animation
  • Serves a timestamp that's fixed during each animation step
  • Self-tuning animation rate

Should it be per-document or per-view-manager-tree? I suspect per-document.

class nsPresContext {
public:
    nsAnimationController* AnimationController();
};

class nsAnimationController {
public:
    // Animations should be weakly referenced; if the animation object
    // goes away, then it's automatically unregistered
    void RegisterAnimation(nsIAnimation* aAnimation);
    void UnregisterAnimation(nsIAnimation* aAnimation);

    /**
     * This returns the timestamp of the current animation step. It's updated
     * just once per step. Should probably be callable anytime; if it's
     * not in an explicit animation step, we pretend that the current event
     * is an animation step --- that way, starting a bunch of animations
     * during the same event gives them all exactly the same start time.
     */
    PRTime GetCurrentTime();
};

class nsIAnimation : public nsISupportsWeakReference {
public:
    void NotifyAnimationStep();
}