ScriptedAnimationController.h [plain text]
#ifndef ScriptedAnimationController_h
#define ScriptedAnimationController_h
#if ENABLE(REQUEST_ANIMATION_FRAME)
#include "DOMTimeStamp.h"
#if USE(REQUEST_ANIMATION_FRAME_TIMER)
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
#include "Chrome.h"
#include "ChromeClient.h"
#include "DisplayRefreshMonitorClient.h"
#endif
#include "Timer.h"
#endif
#include "PlatformScreen.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
namespace WebCore {
class Document;
class RequestAnimationFrameCallback;
class ScriptedAnimationController : public RefCounted<ScriptedAnimationController>
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
, public DisplayRefreshMonitorClient
#endif
{
public:
static PassRefPtr<ScriptedAnimationController> create(Document* document, PlatformDisplayID displayID)
{
return adoptRef(new ScriptedAnimationController(document, displayID));
}
~ScriptedAnimationController();
void clearDocumentPointer() { m_document = 0; }
typedef int CallbackId;
CallbackId registerCallback(PassRefPtr<RequestAnimationFrameCallback>);
void cancelCallback(CallbackId);
void serviceScriptedAnimations(double monotonicTimeNow);
void suspend();
void resume();
void setThrottled(bool);
void windowScreenDidChange(PlatformDisplayID);
private:
ScriptedAnimationController(Document*, PlatformDisplayID);
typedef Vector<RefPtr<RequestAnimationFrameCallback>> CallbackList;
CallbackList m_callbacks;
Document* m_document;
CallbackId m_nextCallbackId;
int m_suspendCount;
void scheduleAnimation();
#if USE(REQUEST_ANIMATION_FRAME_TIMER)
void animationTimerFired(Timer&);
Timer m_animationTimer;
double m_lastAnimationFrameTimeMonotonic;
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
virtual void displayRefreshFired(double timestamp) override;
virtual PassRefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
bool m_isUsingTimer;
bool m_isThrottled;
#endif
#endif
};
}
#endif // ENABLE(REQUEST_ANIMATION_FRAME)
#endif // ScriptedAnimationController_h