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

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

Issue 1893433002: In SkDraw::drawRect, use SkPath for huge rects. Base URL: https://skia.googlesource.com/skia@fixed-assert
Patch Set: Created 4 years, 8 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/SkRect.cpp ('k') | src/core/SkScanPriv.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 * Copyright 2010 The Android Open Source Project 2 * Copyright 2010 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 8
9 #include "SkMath.h" 9 #include "SkMath.h"
10 #include "SkScalar.h" 10 #include "SkScalar.h"
11 11
12 static_assert(SK_MaxS32Scalar == SkIntToScalar(SkScalarTruncToInt(SK_MaxS32Scala r)),
13 "Value of SK_MaxS32Scalar is incorrect.");
14
12 SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[], 15 SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
13 const SkScalar values[], int length) { 16 const SkScalar values[], int length) {
14 SkASSERT(length > 0); 17 SkASSERT(length > 0);
15 SkASSERT(keys != nullptr); 18 SkASSERT(keys != nullptr);
16 SkASSERT(values != nullptr); 19 SkASSERT(values != nullptr);
17 #ifdef SK_DEBUG 20 #ifdef SK_DEBUG
18 for (int i = 1; i < length; i++) 21 for (int i = 1; i < length; i++)
19 SkASSERT(keys[i] >= keys[i-1]); 22 SkASSERT(keys[i] >= keys[i-1]);
20 #endif 23 #endif
21 int right = 0; 24 int right = 0;
22 while (right < length && searchKey > keys[right]) 25 while (right < length && searchKey > keys[right])
23 right++; 26 right++;
24 // Could use sentinel values to eliminate conditionals, but since the 27 // Could use sentinel values to eliminate conditionals, but since the
25 // tables are taken as input, a simpler format is better. 28 // tables are taken as input, a simpler format is better.
26 if (length == right) 29 if (length == right)
27 return values[length-1]; 30 return values[length-1];
28 if (0 == right) 31 if (0 == right)
29 return values[0]; 32 return values[0];
30 // Otherwise, interpolate between right - 1 and right. 33 // Otherwise, interpolate between right - 1 and right.
31 SkScalar rightKey = keys[right]; 34 SkScalar rightKey = keys[right];
32 SkScalar leftKey = keys[right-1]; 35 SkScalar leftKey = keys[right-1];
33 SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey); 36 SkScalar fract = (searchKey - leftKey) / (rightKey - leftKey);
34 return SkScalarInterp(values[right-1], values[right], fract); 37 return SkScalarInterp(values[right-1], values[right], fract);
35 } 38 }
OLDNEW
« no previous file with comments | « src/core/SkRect.cpp ('k') | src/core/SkScanPriv.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698