WorkerAnimationController.h [plain text]
#pragma once
#if ENABLE(OFFSCREEN_CANVAS)
#include "ActiveDOMObject.h"
#include "DOMHighResTimeStamp.h"
#include "PlatformScreen.h"
#include "Timer.h"
#include <wtf/ThreadSafeRefCounted.h>
namespace WebCore {
class RequestAnimationFrameCallback;
class WorkerGlobalScope;
class WorkerAnimationController final : public ThreadSafeRefCounted<WorkerAnimationController>, public ActiveDOMObject {
public:
static Ref<WorkerAnimationController> create(WorkerGlobalScope&);
~WorkerAnimationController();
int requestAnimationFrame(Ref<RequestAnimationFrameCallback>&&);
void cancelAnimationFrame(int);
using ThreadSafeRefCounted::ref;
using ThreadSafeRefCounted::deref;
private:
WorkerAnimationController(WorkerGlobalScope&);
const char* activeDOMObjectName() const final;
bool virtualHasPendingActivity() const final;
void stop() final;
void suspend(ReasonForSuspension) final;
void resume() final;
void scheduleAnimation();
void animationTimerFired();
void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
WorkerGlobalScope& m_workerGlobalScope;
typedef Vector<RefPtr<RequestAnimationFrameCallback>> CallbackList;
CallbackList m_animationCallbacks;
typedef int CallbackId;
CallbackId m_nextAnimationCallbackId { 0 };
Timer m_animationTimer;
DOMHighResTimeStamp m_lastAnimationFrameTimestamp { 0 };
bool m_savedIsActive { false };
};
}
#endif