| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 1 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 2 | /* |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 3 | * 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.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | |
| epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame^] | 10 | |
| reed@google.com | ac10a2d | 2010-12-22 21:39:39 +0000 | [diff] [blame] | 11 | #ifndef SkFlingState_DEFINED |
| 12 | #define SkFlingState_DEFINED |
| 13 | |
| 14 | #include "SkScalar.h" |
| 15 | #include "SkPoint.h" |
| 16 | |
| 17 | class SkMatrix; |
| 18 | |
| 19 | struct 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 | |
| 28 | private: |
| 29 | SkPoint fDirection; |
| 30 | SkScalar fSpeed0; |
| 31 | double fTime0; |
| 32 | bool fActive; |
| 33 | }; |
| 34 | |
| 35 | class GrAnimateFloat { |
| 36 | public: |
| 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 | |
| 45 | private: |
| 46 | float fValue0, fValue1, fDuration; |
| 47 | SkMSec fTime0; |
| 48 | }; |
| 49 | |
| 50 | #endif |
| 51 | |