| 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 = SkScalarDiv((SkScalar)(time - prevTime), | 65 SkScalar t = (SkScalar)(time - prevTime) / (SkScalar)(nextTime - prevTime); |
| 66 (SkScalar)(nextTime - prevTime)); | |
| 67 return blend ? | 66 return blend ? |
| 68 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; | 67 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; |
| 69 } | 68 } |
| 70 | 69 |
| 71 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, | 70 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, |
| 72 int* indexPtr, SkBool* exactPtr) const { | 71 int* indexPtr, SkBool* exactPtr) const { |
| 73 SkASSERT(fFrameCount > 0); | 72 SkASSERT(fFrameCount > 0); |
| 74 Result result = kNormal_Result; | 73 Result result = kNormal_Result; |
| 75 if (fRepeat != SK_Scalar1) { | 74 if (fRepeat != SK_Scalar1) { |
| 76 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning | 75 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 } | 261 } |
| 263 | 262 |
| 264 // Now we have t, so compute the coeff for Y and evaluate | 263 // Now we have t, so compute the coeff for Y and evaluate |
| 265 b = pin_and_convert(by); | 264 b = pin_and_convert(by); |
| 266 c = pin_and_convert(cy); | 265 c = pin_and_convert(cy); |
| 267 A = 3*b; | 266 A = 3*b; |
| 268 B = 3*(c - 2*b); | 267 B = 3*(c - 2*b); |
| 269 C = 3*(b - c) + Dot14_ONE; | 268 C = 3*(b - c) + Dot14_ONE; |
| 270 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2); | 269 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2); |
| 271 } | 270 } |
| OLD | NEW |