blob: 09557b90fb754fd143f0f6ab585faf162fb4b545 [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001
reed@google.comac10a2d2010-12-22 21:39:39 +00002/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00003 * Copyright 2010 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00007 */
8
9
epoger@google.comec3ed6a2011-07-28 14:26:00 +000010
reed@google.comac10a2d2010-12-22 21:39:39 +000011#ifndef SkFlingState_DEFINED
12#define SkFlingState_DEFINED
13
14#include "SkScalar.h"
15#include "SkPoint.h"
16
17class SkMatrix;
18
19struct FlingState {
20 FlingState() : fActive(false) {}
21
22 bool isActive() const { return fActive; }
23 void stop() { fActive = false; }
24
25 void reset(float sx, float sy);
26 bool evaluateMatrix(SkMatrix* matrix);
27
28private:
29 SkPoint fDirection;
30 SkScalar fSpeed0;
31 double fTime0;
32 bool fActive;
33};
34
35class GrAnimateFloat {
36public:
37 GrAnimateFloat();
38
39 void start(float v0, float v1, float duration);
40 bool isActive() const { return fTime0 != 0; }
41 void stop() { fTime0 = 0; }
42
43 float evaluate();
44
45private:
46 float fValue0, fValue1, fDuration;
47 SkMSec fTime0;
48};
49
50#endif
51