CCLayerAnimationController.h [plain text]
#ifndef CCLayerAnimationController_h
#define CCLayerAnimationController_h
#include "cc/CCActiveAnimation.h"
#include "cc/CCAnimationCurve.h"
#include "cc/CCAnimationEvents.h"
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class Animation;
class IntSize;
class KeyframeValueList;
class TransformationMatrix;
class CCLayerAnimationControllerClient {
public:
virtual ~CCLayerAnimationControllerClient() { }
virtual int id() const = 0;
virtual void setOpacityFromAnimation(float) = 0;
virtual float opacity() const = 0;
virtual void setTransformFromAnimation(const TransformationMatrix&) = 0;
virtual const TransformationMatrix& transform() const = 0;
virtual const IntSize& bounds() const = 0;
};
class CCLayerAnimationController {
WTF_MAKE_NONCOPYABLE(CCLayerAnimationController);
public:
static PassOwnPtr<CCLayerAnimationController> create(CCLayerAnimationControllerClient*);
virtual ~CCLayerAnimationController();
virtual bool addAnimation(const KeyframeValueList&, const IntSize& boxSize, const Animation*, int animationId, int groupId, double timeOffset);
virtual void pauseAnimation(int animationId, double timeOffset);
virtual void removeAnimation(int animationId);
virtual void suspendAnimations(double monotonicTime);
virtual void resumeAnimations(double monotonicTime);
virtual void pushAnimationUpdatesTo(CCLayerAnimationController*);
void animate(double monotonicTime, CCAnimationEventsVector*);
void add(PassOwnPtr<CCActiveAnimation>);
CCActiveAnimation* getActiveAnimation(int groupId, CCActiveAnimation::TargetProperty) const;
bool hasActiveAnimation() const;
bool isAnimatingProperty(CCActiveAnimation::TargetProperty) const;
void notifyAnimationStarted(const CCAnimationEvent&);
protected:
explicit CCLayerAnimationController(CCLayerAnimationControllerClient*);
private:
typedef HashSet<int> TargetProperties;
void pushNewAnimationsToImplThread(CCLayerAnimationController*) const;
void removeAnimationsCompletedOnMainThread(CCLayerAnimationController*) const;
void pushPropertiesToImplThread(CCLayerAnimationController*) const;
void startAnimationsWaitingForNextTick(double monotonicTime, CCAnimationEventsVector*);
void startAnimationsWaitingForStartTime(double monotonicTime, CCAnimationEventsVector*);
void startAnimationsWaitingForTargetAvailability(double monotonicTime, CCAnimationEventsVector*);
void resolveConflicts(double monotonicTime);
void purgeFinishedAnimations(double monotonicTime, CCAnimationEventsVector*);
void tickAnimations(double monotonicTime);
CCLayerAnimationControllerClient* m_client;
Vector<OwnPtr<CCActiveAnimation> > m_activeAnimations;
};
}
#endif // CCLayerAnimationController_h