OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkInterpolator.h" | 10 #include "SkInterpolator.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 if (endTime) { | 55 if (endTime) { |
56 *endTime = fTimes[fFrameCount - 1].fTime; | 56 *endTime = fTimes[fFrameCount - 1].fTime; |
57 } | 57 } |
58 return true; | 58 return true; |
59 } | 59 } |
60 | 60 |
61 SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, | 61 SkScalar SkInterpolatorBase::ComputeRelativeT(SkMSec time, SkMSec prevTime, |
62 SkMSec nextTime, const SkScalar blend[4]) { | 62 SkMSec nextTime, const SkScalar blend[4]) { |
63 SkASSERT(time > prevTime && time < nextTime); | 63 SkASSERT(time > prevTime && time < nextTime); |
64 | 64 |
65 SkScalar t = (SkScalar)(time - prevTime) / (SkScalar)(nextTime - prevTime); | 65 SkScalar t = SkScalarDiv((SkScalar)(time - prevTime), |
| 66 (SkScalar)(nextTime - prevTime)); |
66 return blend ? | 67 return blend ? |
67 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; | 68 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; |
68 } | 69 } |
69 | 70 |
70 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, | 71 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, |
71 int* indexPtr, SkBool* exactPtr) const { | 72 int* indexPtr, SkBool* exactPtr) const { |
72 SkASSERT(fFrameCount > 0); | 73 SkASSERT(fFrameCount > 0); |
73 Result result = kNormal_Result; | 74 Result result = kNormal_Result; |
74 if (fRepeat != SK_Scalar1) { | 75 if (fRepeat != SK_Scalar1) { |
75 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning | 76 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 } | 262 } |
262 | 263 |
263 // Now we have t, so compute the coeff for Y and evaluate | 264 // Now we have t, so compute the coeff for Y and evaluate |
264 b = pin_and_convert(by); | 265 b = pin_and_convert(by); |
265 c = pin_and_convert(cy); | 266 c = pin_and_convert(cy); |
266 A = 3*b; | 267 A = 3*b; |
267 B = 3*(c - 2*b); | 268 B = 3*(c - 2*b); |
268 C = 3*(b - c) + Dot14_ONE; | 269 C = 3*(b - c) + Dot14_ONE; |
269 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2); | 270 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2); |
270 } | 271 } |
OLD | NEW |