summaryrefslogtreecommitdiffstats
path: root/cc/CCActiveGestureAnimation.cpp
blob: b8542e75306ad09e7bbaaaba3d24cd1ac1318bfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "config.h"

#include "CCActiveGestureAnimation.h"

#include "CCGestureCurve.h"
#include "TraceEvent.h"

namespace WebCore {

PassOwnPtr<CCActiveGestureAnimation> CCActiveGestureAnimation::create(PassOwnPtr<CCGestureCurve> curve, CCGestureCurveTarget* target)
{
    return adoptPtr(new CCActiveGestureAnimation(curve, target));
}

CCActiveGestureAnimation::CCActiveGestureAnimation(PassOwnPtr<CCGestureCurve> curve, CCGestureCurveTarget* target)
    : m_startTime(0)
    , m_waitingForFirstTick(true)
    , m_gestureCurve(curve)
    , m_gestureCurveTarget(target)
{
    TRACE_EVENT_ASYNC_BEGIN1("input", "GestureAnimation", this, "curve", m_gestureCurve->debugName());
}

CCActiveGestureAnimation::~CCActiveGestureAnimation()
{
    TRACE_EVENT_ASYNC_END0("input", "GestureAnimation", this);
}

bool CCActiveGestureAnimation::animate(double monotonicTime)
{
    if (m_waitingForFirstTick) {
        m_startTime = monotonicTime;
        m_waitingForFirstTick = false;
    }

    // CCGestureCurves used zero-based time, so subtract start-time.
    return m_gestureCurve->apply(monotonicTime - m_startTime, m_gestureCurveTarget);
}

} // namespace WebCore