Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1146 SkScalar fpow2 = SkScalarLog2((x * x + y * y) / tol2) * 0.25f; | 1146 SkScalar fpow2 = SkScalarLog2((x * x + y * y) / tol2) * 0.25f; |
| 1147 int altPow2 = SkScalarCeilToInt(fpow2); | 1147 int altPow2 = SkScalarCeilToInt(fpow2); |
| 1148 if (altPow2 != pow2) { | 1148 if (altPow2 != pow2) { |
| 1149 SkDebugf("pow2 %d altPow2 %d fbits %g err %g tol %g\n", pow2, altPow 2, fpow2, err, tol); | 1149 SkDebugf("pow2 %d altPow2 %d fbits %g err %g tol %g\n", pow2, altPow 2, fpow2, err, tol); |
| 1150 } | 1150 } |
| 1151 pow2 = altPow2; | 1151 pow2 = altPow2; |
| 1152 } | 1152 } |
| 1153 return pow2; | 1153 return pow2; |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 // returns true if (a <= b <= c) || (a >= b >= c) | |
| 1157 static bool between(SkScalar a, SkScalar b, SkScalar c) { | |
|
reed1
2016/09/20 17:33:25
This is super cool (assuming it works). Seems to w
caryclark
2016/09/21 14:37:48
It works. I've been testing it for years in pathop
| |
| 1158 return (a - b) * (c - b) <= 0; | |
| 1159 } | |
| 1160 | |
| 1156 static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) { | 1161 static SkPoint* subdivide(const SkConic& src, SkPoint pts[], int level) { |
| 1157 SkASSERT(level >= 0); | 1162 SkASSERT(level >= 0); |
| 1158 | 1163 |
| 1159 if (0 == level) { | 1164 if (0 == level) { |
| 1160 memcpy(pts, &src.fPts[1], 2 * sizeof(SkPoint)); | 1165 memcpy(pts, &src.fPts[1], 2 * sizeof(SkPoint)); |
| 1161 return pts + 2; | 1166 return pts + 2; |
| 1162 } else { | 1167 } else { |
| 1163 SkConic dst[2]; | 1168 SkConic dst[2]; |
| 1164 src.chop(dst); | 1169 src.chop(dst); |
| 1170 if (between(src.fPts[0].fY, src.fPts[1].fY, src.fPts[2].fY)) { | |
|
reed1
2016/09/20 17:33:25
// Need to ensure that after a chop of a monotonic
caryclark
2016/09/21 14:37:48
Added comments.
| |
| 1171 if (!between(dst[0].fPts[0].fY, dst[0].fPts[1].fY, dst[0].fPts[2].fY )) { | |
| 1172 dst[0].fPts[1].fY = dst[0].fPts[0].fY; | |
| 1173 } | |
| 1174 if (!between(dst[0].fPts[1].fY, dst[1].fPts[0].fY, dst[1].fPts[1].fY )) { | |
|
reed1
2016/09/20 17:33:25
Each of these 3 seem to be the same...
ensure_mon
caryclark
2016/09/21 14:37:48
The intention of moving it to one side was for con
| |
| 1175 dst[1].fPts[0].fY = dst[0].fPts[1].fY; | |
| 1176 } | |
| 1177 if (!between(dst[1].fPts[0].fY, dst[1].fPts[1].fY, dst[1].fPts[2].fY )) { | |
| 1178 dst[1].fPts[1].fY = dst[1].fPts[0].fY; | |
| 1179 } | |
| 1180 } | |
| 1165 --level; | 1181 --level; |
| 1166 pts = subdivide(dst[0], pts, level); | 1182 pts = subdivide(dst[0], pts, level); |
| 1167 return subdivide(dst[1], pts, level); | 1183 return subdivide(dst[1], pts, level); |
| 1168 } | 1184 } |
| 1169 } | 1185 } |
| 1170 | 1186 |
| 1171 int SkConic::chopIntoQuadsPOW2(SkPoint pts[], int pow2) const { | 1187 int SkConic::chopIntoQuadsPOW2(SkPoint pts[], int pow2) const { |
| 1172 SkASSERT(pow2 >= 0); | 1188 SkASSERT(pow2 >= 0); |
| 1173 *pts = fPts[0]; | 1189 *pts = fPts[0]; |
| 1174 SkDEBUGCODE(SkPoint* endPts); | 1190 SkDEBUGCODE(SkPoint* endPts); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1365 matrix.preScale(SK_Scalar1, -SK_Scalar1); | 1381 matrix.preScale(SK_Scalar1, -SK_Scalar1); |
| 1366 } | 1382 } |
| 1367 if (userMatrix) { | 1383 if (userMatrix) { |
| 1368 matrix.postConcat(*userMatrix); | 1384 matrix.postConcat(*userMatrix); |
| 1369 } | 1385 } |
| 1370 for (int i = 0; i < conicCount; ++i) { | 1386 for (int i = 0; i < conicCount; ++i) { |
| 1371 matrix.mapPoints(dst[i].fPts, 3); | 1387 matrix.mapPoints(dst[i].fPts, 3); |
| 1372 } | 1388 } |
| 1373 return conicCount; | 1389 return conicCount; |
| 1374 } | 1390 } |
| OLD | NEW |