blob: a1da4fbc86708dd0420f821b6481757e47da73e1 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
2 Copyright 2010 Google Inc.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17
18#ifndef SkFlingState_DEFINED
19#define SkFlingState_DEFINED
20
21#include "SkScalar.h"
22#include "SkPoint.h"
23
24class SkMatrix;
25
26struct FlingState {
27 FlingState() : fActive(false) {}
28
29 bool isActive() const { return fActive; }
30 void stop() { fActive = false; }
31
32 void reset(float sx, float sy);
33 bool evaluateMatrix(SkMatrix* matrix);
34
35private:
36 SkPoint fDirection;
37 SkScalar fSpeed0;
38 double fTime0;
39 bool fActive;
40};
41
42class GrAnimateFloat {
43public:
44 GrAnimateFloat();
45
46 void start(float v0, float v1, float duration);
47 bool isActive() const { return fTime0 != 0; }
48 void stop() { fTime0 = 0; }
49
50 float evaluate();
51
52private:
53 float fValue0, fValue1, fDuration;
54 SkMSec fTime0;
55};
56
57#endif
58
59