ActivePlatformGestureAnimation.cpp [plain text]
#include "config.h"
#include "ActivePlatformGestureAnimation.h"
#include "PlatformGestureCurve.h"
#include "PlatformGestureCurveTarget.h"
#if PLATFORM(CHROMIUM)
#include "TraceEvent.h"
#endif
namespace WebCore {
PassOwnPtr<ActivePlatformGestureAnimation> ActivePlatformGestureAnimation::create(PassOwnPtr<PlatformGestureCurve> curve, PlatformGestureCurveTarget* target)
{
return adoptPtr(new ActivePlatformGestureAnimation(curve, target));
}
PassOwnPtr<ActivePlatformGestureAnimation> ActivePlatformGestureAnimation::create(PassOwnPtr<PlatformGestureCurve> curve, PlatformGestureCurveTarget* target, double startTime)
{
return adoptPtr(new ActivePlatformGestureAnimation(curve, target, startTime));
}
ActivePlatformGestureAnimation::~ActivePlatformGestureAnimation()
{
#if PLATFORM(CHROMIUM)
TRACE_EVENT_ASYNC_END0("input", "GestureAnimation", this);
#endif
}
ActivePlatformGestureAnimation::ActivePlatformGestureAnimation(PassOwnPtr<PlatformGestureCurve> curve, PlatformGestureCurveTarget* target)
: m_startTime(0)
, m_waitingForFirstTick(true)
, m_curve(curve)
, m_target(target)
{
#if PLATFORM(CHROMIUM)
TRACE_EVENT_ASYNC_BEGIN1("input", "GestureAnimation", this, "curve", m_curve->debugName());
#endif
}
ActivePlatformGestureAnimation::ActivePlatformGestureAnimation(PassOwnPtr<PlatformGestureCurve> curve, PlatformGestureCurveTarget* target, double startTime)
: m_startTime(startTime)
, m_waitingForFirstTick(false)
, m_curve(curve)
, m_target(target)
{
#if PLATFORM(CHROMIUM)
TRACE_EVENT_ASYNC_BEGIN1("input", "GestureAnimation", this, "curve", m_curve->debugName());
#endif
}
bool ActivePlatformGestureAnimation::animate(double time)
{
if (m_waitingForFirstTick) {
m_startTime = time;
m_waitingForFirstTick = false;
}
return m_curve->apply(time - m_startTime, m_target);
}
}