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

Side by Side Diff: include/core/SkScalar.h

Issue 2198263002: Image filters: force near-zero floating point parameters to zero. Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 | « include/core/SkPoint3.h ('k') | src/core/SkPoint3.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 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkScalar_DEFINED 8 #ifndef SkScalar_DEFINED
9 #define SkScalar_DEFINED 9 #define SkScalar_DEFINED
10 10
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 SkASSERT(tolerance >= 0); 221 SkASSERT(tolerance >= 0);
222 return SkScalarAbs(x) <= tolerance; 222 return SkScalarAbs(x) <= tolerance;
223 } 223 }
224 224
225 static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y, 225 static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y,
226 SkScalar tolerance = SK_ScalarNearlyZero) { 226 SkScalar tolerance = SK_ScalarNearlyZero) {
227 SkASSERT(tolerance >= 0); 227 SkASSERT(tolerance >= 0);
228 return SkScalarAbs(x-y) <= tolerance; 228 return SkScalarAbs(x-y) <= tolerance;
229 } 229 }
230 230
231 static inline SkScalar SkScalarNormalize(SkScalar x)
reed1 2016/08/26 17:49:43 Given this name, should it trigger only when x is
232 {
233 return SkScalarNearlyZero(x) ? 0 : x;
234 }
235
231 /** Linearly interpolate between A and B, based on t. 236 /** Linearly interpolate between A and B, based on t.
232 If t is 0, return A 237 If t is 0, return A
233 If t is 1, return B 238 If t is 1, return B
234 else interpolate. 239 else interpolate.
235 t must be [0..SK_Scalar1] 240 t must be [0..SK_Scalar1]
236 */ 241 */
237 static inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t) { 242 static inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t) {
238 SkASSERT(t >= 0 && t <= SK_Scalar1); 243 SkASSERT(t >= 0 && t <= SK_Scalar1);
239 return A + (B - A) * t; 244 return A + (B - A) * t;
240 } 245 }
(...skipping 18 matching lines...) Expand all
259 SkASSERT(n >= 0); 264 SkASSERT(n >= 0);
260 for (int i = 0; i < n; ++i) { 265 for (int i = 0; i < n; ++i) {
261 if (a[i] != b[i]) { 266 if (a[i] != b[i]) {
262 return false; 267 return false;
263 } 268 }
264 } 269 }
265 return true; 270 return true;
266 } 271 }
267 272
268 #endif 273 #endif
OLDNEW
« no previous file with comments | « include/core/SkPoint3.h ('k') | src/core/SkPoint3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698