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

Side by Side Diff: src/core/SkScalar.cpp

Issue 1316233002: Style Change: NULL->nullptr (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-08-27 (Thursday) 10:25:06 EDT Created 5 years, 3 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/core/SkResourceCache.cpp ('k') | src/core/SkScalerContext.h » ('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 2010 The Android Open Source Project 3 * Copyright 2010 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 "SkMath.h" 10 #include "SkMath.h"
11 #include "SkScalar.h" 11 #include "SkScalar.h"
12 12
13 SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], 13 SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
14 const SkScalar values[], int length) { 14 const SkScalar values[], int length) {
15 SkASSERT(length > 0); 15 SkASSERT(length > 0);
16 SkASSERT(keys != NULL); 16 SkASSERT(keys != nullptr);
17 SkASSERT(values != NULL); 17 SkASSERT(values != nullptr);
18 #ifdef SK_DEBUG 18 #ifdef SK_DEBUG
19 for (int i = 1; i < length; i++) 19 for (int i = 1; i < length; i++)
20 SkASSERT(keys[i] >= keys[i-1]); 20 SkASSERT(keys[i] >= keys[i-1]);
21 #endif 21 #endif
22 int right = 0; 22 int right = 0;
23 while (right < length && searchKey > keys[right]) 23 while (right < length && searchKey > keys[right])
24 right++; 24 right++;
25 // Could use sentinel values to eliminate conditionals, but since the 25 // Could use sentinel values to eliminate conditionals, but since the
26 // tables are taken as input, a simpler format is better. 26 // tables are taken as input, a simpler format is better.
27 if (length == right) 27 if (length == right)
28 return values[length-1]; 28 return values[length-1];
29 if (0 == right) 29 if (0 == right)
30 return values[0]; 30 return values[0];
31 // Otherwise, interpolate between right - 1 and right. 31 // Otherwise, interpolate between right - 1 and right.
32 SkScalar rightKey = keys[right]; 32 SkScalar rightKey = keys[right];
33 SkScalar leftKey = keys[right-1]; 33 SkScalar leftKey = keys[right-1];
34 SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey); 34 SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey);
35 return SkScalarInterp(values[right-1], values[right], fract); 35 return SkScalarInterp(values[right-1], values[right], fract);
36 } 36 }
OLDNEW
« no previous file with comments | « src/core/SkResourceCache.cpp ('k') | src/core/SkScalerContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698