Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/utils/SkInterpolator.cpp

Issue 1548223002: remove cruft from SkTypes.h, including SkBool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/views/SkView.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 = (SkScalar)(time - prevTime) / (SkScalar)(nextTime - prevTime);
66 return blend ? 66 return blend ?
67 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t; 67 SkUnitCubicInterp(t, blend[0], blend[1], blend[2], blend[3]) : t;
68 } 68 }
69 69
70 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T, 70 SkInterpolatorBase::Result SkInterpolatorBase::timeToT(SkMSec time, SkScalar* T,
71 int* indexPtr, SkBool* exactPtr) const { 71 int* indexPtr, bool* exactPtr) const {
72 SkASSERT(fFrameCount > 0); 72 SkASSERT(fFrameCount > 0);
73 Result result = kNormal_Result; 73 Result result = kNormal_Result;
74 if (fRepeat != SK_Scalar1) { 74 if (fRepeat != SK_Scalar1) {
75 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning 75 SkMSec startTime = 0, endTime = 0; // initialize to avoid warning
76 this->getDuration(&startTime, &endTime); 76 this->getDuration(&startTime, &endTime);
77 SkMSec totalTime = endTime - startTime; 77 SkMSec totalTime = endTime - startTime;
78 SkMSec offsetTime = time - startTime; 78 SkMSec offsetTime = time - startTime;
79 endTime = SkScalarFloorToInt(fRepeat * totalTime); 79 endTime = SkScalarFloorToInt(fRepeat * totalTime);
80 if (offsetTime >= endTime) { 80 if (offsetTime >= endTime) {
81 SkScalar fraction = SkScalarFraction(fRepeat); 81 SkScalar fraction = SkScalarFraction(fRepeat);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 SkScalar* dst = &fValues[fElemCount * index]; 175 SkScalar* dst = &fValues[fElemCount * index];
176 memcpy(dst, values, fElemCount * sizeof(SkScalar)); 176 memcpy(dst, values, fElemCount * sizeof(SkScalar));
177 } 177 }
178 return success; 178 return success;
179 } 179 }
180 180
181 SkInterpolator::Result SkInterpolator::timeToValues(SkMSec time, 181 SkInterpolator::Result SkInterpolator::timeToValues(SkMSec time,
182 SkScalar values[]) const { 182 SkScalar values[]) const {
183 SkScalar T; 183 SkScalar T;
184 int index; 184 int index;
185 SkBool exact; 185 bool exact;
186 Result result = timeToT(time, &T, &index, &exact); 186 Result result = timeToT(time, &T, &index, &exact);
187 if (values) { 187 if (values) {
188 const SkScalar* nextSrc = &fValues[index * fElemCount]; 188 const SkScalar* nextSrc = &fValues[index * fElemCount];
189 189
190 if (exact) { 190 if (exact) {
191 memcpy(values, nextSrc, fElemCount * sizeof(SkScalar)); 191 memcpy(values, nextSrc, fElemCount * sizeof(SkScalar));
192 } else { 192 } else {
193 SkASSERT(index > 0); 193 SkASSERT(index > 0);
194 194
195 const SkScalar* prevSrc = nextSrc - fElemCount; 195 const SkScalar* prevSrc = nextSrc - fElemCount;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 // 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
264 b = pin_and_convert(by); 264 b = pin_and_convert(by);
265 c = pin_and_convert(cy); 265 c = pin_and_convert(cy);
266 A = 3*b; 266 A = 3*b;
267 B = 3*(c - 2*b); 267 B = 3*(c - 2*b);
268 C = 3*(b - c) + Dot14_ONE; 268 C = 3*(b - c) + Dot14_ONE;
269 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2); 269 return SkFixedToScalar(eval_cubic(t, A, B, C) << 2);
270 } 270 }
OLDNEW
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | src/views/SkView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698