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

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

Issue 1138263002: Revert of stop calling SkScalarDiv (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 7 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/animator/SkScriptRuntime.cpp ('k') | src/core/SkPaint.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 #include "SkGeometry.h" 8 #include "SkGeometry.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkNx.h" 10 #include "SkNx.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 if (numer < 0) { 56 if (numer < 0) {
57 numer = -numer; 57 numer = -numer;
58 denom = -denom; 58 denom = -denom;
59 } 59 }
60 60
61 if (denom == 0 || numer == 0 || numer >= denom) { 61 if (denom == 0 || numer == 0 || numer >= denom) {
62 return 0; 62 return 0;
63 } 63 }
64 64
65 SkScalar r = numer / denom; 65 SkScalar r = SkScalarDiv(numer, denom);
66 if (SkScalarIsNaN(r)) { 66 if (SkScalarIsNaN(r)) {
67 return 0; 67 return 0;
68 } 68 }
69 SkASSERTF(r >= 0 && r < SK_Scalar1, "numer %f, denom %f, r %f", numer, denom , r); 69 SkASSERTF(r >= 0 && r < SK_Scalar1, "numer %f, denom %f, r %f", numer, denom , r);
70 if (r == 0) { // catch underflow if numer <<<< denom 70 if (r == 0) { // catch underflow if numer <<<< denom
71 return 0; 71 return 0;
72 } 72 }
73 *ratio = r; 73 *ratio = r;
74 return 1; 74 return 1;
75 } 75 }
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1142 SkScalar C = src[0]; 1142 SkScalar C = src[0];
1143 SkScalar A = src[4] - 2 * src2w + C; 1143 SkScalar A = src[4] - 2 * src2w + C;
1144 SkScalar B = 2 * (src2w - C); 1144 SkScalar B = 2 * (src2w - C);
1145 SkScalar numer = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); 1145 SkScalar numer = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C);
1146 1146
1147 B = 2 * (w - SK_Scalar1); 1147 B = 2 * (w - SK_Scalar1);
1148 C = SK_Scalar1; 1148 C = SK_Scalar1;
1149 A = -B; 1149 A = -B;
1150 SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C); 1150 SkScalar denom = SkScalarMulAdd(SkScalarMulAdd(A, t, B), t, C);
1151 1151
1152 return numer / denom; 1152 return SkScalarDiv(numer, denom);
1153 } 1153 }
1154 1154
1155 // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w) 1155 // F' = 2 (C t (1 + t (-1 + w)) - A (-1 + t) (t (-1 + w) - w) + B (1 - 2 t) w)
1156 // 1156 //
1157 // t^2 : (2 P0 - 2 P2 - 2 P0 w + 2 P2 w) 1157 // t^2 : (2 P0 - 2 P2 - 2 P0 w + 2 P2 w)
1158 // t^1 : (-2 P0 + 2 P2 + 4 P0 w - 4 P1 w) 1158 // t^1 : (-2 P0 + 2 P2 + 4 P0 w - 4 P1 w)
1159 // t^0 : -2 P0 w + 2 P1 w 1159 // t^0 : -2 P0 w + 2 P1 w
1160 // 1160 //
1161 // We disregard magnitude, so we can freely ignore the denominator of F', and 1161 // We disregard magnitude, so we can freely ignore the denominator of F', and
1162 // divide the numerator by 2 1162 // divide the numerator by 2
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1577 matrix.preScale(SK_Scalar1, -SK_Scalar1); 1577 matrix.preScale(SK_Scalar1, -SK_Scalar1);
1578 } 1578 }
1579 if (userMatrix) { 1579 if (userMatrix) {
1580 matrix.postConcat(*userMatrix); 1580 matrix.postConcat(*userMatrix);
1581 } 1581 }
1582 for (int i = 0; i < conicCount; ++i) { 1582 for (int i = 0; i < conicCount; ++i) {
1583 matrix.mapPoints(dst[i].fPts, 3); 1583 matrix.mapPoints(dst[i].fPts, 3);
1584 } 1584 }
1585 return conicCount; 1585 return conicCount;
1586 } 1586 }
OLDNEW
« no previous file with comments | « src/animator/SkScriptRuntime.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698