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

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

Issue 1092483003: Revert of Speeup hairline curves (quads and cubics) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 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/SkGeometry.h ('k') | src/core/SkScan_Hairline.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"
11 11
12 #if 0
13 static Sk2s from_point(const SkPoint& point) { 12 static Sk2s from_point(const SkPoint& point) {
14 return Sk2s::Load(&point.fX); 13 return Sk2s::Load(&point.fX);
15 } 14 }
16 15
17 static SkPoint to_point(const Sk2s& x) { 16 static SkPoint to_point(const Sk2s& x) {
18 SkPoint point; 17 SkPoint point;
19 x.store(&point.fX); 18 x.store(&point.fX);
20 return point; 19 return point;
21 } 20 }
22 #endif
23 21
24 static SkVector to_vector(const Sk2s& x) { 22 static SkVector to_vector(const Sk2s& x) {
25 SkVector vector; 23 SkVector vector;
26 x.store(&vector.fX); 24 x.store(&vector.fX);
27 return vector; 25 return vector;
28 } 26 }
29 27
30 /** If defined, this makes eval_quad and eval_cubic do more setup (sometimes 28 /** If defined, this makes eval_quad and eval_cubic do more setup (sometimes
31 involving integer multiplies by 2 or 3, but fewer calls to SkScalarMul. 29 involving integer multiplies by 2 or 3, but fewer calls to SkScalarMul.
32 May also introduce overflow of fixed when we compute our setup. 30 May also introduce overflow of fixed when we compute our setup.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 #endif 128 #endif
131 } 129 }
132 130
133 static SkScalar eval_quad_derivative(const SkScalar src[], SkScalar t) { 131 static SkScalar eval_quad_derivative(const SkScalar src[], SkScalar t) {
134 SkScalar A = src[4] - 2 * src[2] + src[0]; 132 SkScalar A = src[4] - 2 * src[2] + src[0];
135 SkScalar B = src[2] - src[0]; 133 SkScalar B = src[2] - src[0];
136 134
137 return 2 * SkScalarMulAdd(A, t, B); 135 return 2 * SkScalarMulAdd(A, t, B);
138 } 136 }
139 137
140 void SkQuadToCoeff(const SkPoint pts[3], SkPoint coeff[3]) {
141 Sk2s p0 = from_point(pts[0]);
142 Sk2s p1 = from_point(pts[1]);
143 Sk2s p2 = from_point(pts[2]);
144
145 Sk2s p1minus2 = p1 - p0;
146
147 coeff[0] = to_point(p2 - p1 - p1 + p0); // A * t^2
148 coeff[1] = to_point(p1minus2 + p1minus2); // B * t
149 coeff[2] = pts[0]; // C
150 }
151
152 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange nt) { 138 void SkEvalQuadAt(const SkPoint src[3], SkScalar t, SkPoint* pt, SkVector* tange nt) {
153 SkASSERT(src); 139 SkASSERT(src);
154 SkASSERT(t >= 0 && t <= SK_Scalar1); 140 SkASSERT(t >= 0 && t <= SK_Scalar1);
155 141
156 if (pt) { 142 if (pt) {
157 pt->set(eval_quad(&src[0].fX, t), eval_quad(&src[0].fY, t)); 143 pt->set(eval_quad(&src[0].fX, t), eval_quad(&src[0].fY, t));
158 } 144 }
159 if (tangent) { 145 if (tangent) {
160 tangent->set(eval_quad_derivative(&src[0].fX, t), 146 tangent->set(eval_quad_derivative(&src[0].fX, t),
161 eval_quad_derivative(&src[0].fY, t)); 147 eval_quad_derivative(&src[0].fY, t));
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 445
460 dst[0] = src[0]; 446 dst[0] = src[0];
461 dst[1] = to_point(ab); 447 dst[1] = to_point(ab);
462 dst[2] = to_point(abc); 448 dst[2] = to_point(abc);
463 dst[3] = to_point(abcd); 449 dst[3] = to_point(abcd);
464 dst[4] = to_point(bcd); 450 dst[4] = to_point(bcd);
465 dst[5] = to_point(cd); 451 dst[5] = to_point(cd);
466 dst[6] = src[3]; 452 dst[6] = src[3];
467 } 453 }
468 454
469 void SkCubicToCoeff(const SkPoint pts[4], SkPoint coeff[4]) {
470 Sk2s p0 = from_point(pts[0]);
471 Sk2s p1 = from_point(pts[1]);
472 Sk2s p2 = from_point(pts[2]);
473 Sk2s p3 = from_point(pts[3]);
474
475 const Sk2s three(3);
476 Sk2s p1minusp2 = p1 - p2;
477
478 Sk2s D = p0;
479 Sk2s A = p3 + three * p1minusp2 - D;
480 Sk2s B = three * (D - p1minusp2 - p1);
481 Sk2s C = three * (p1 - D);
482
483 coeff[0] = to_point(A);
484 coeff[1] = to_point(B);
485 coeff[2] = to_point(C);
486 coeff[3] = to_point(D);
487 }
488
489 /* http://code.google.com/p/skia/issues/detail?id=32 455 /* http://code.google.com/p/skia/issues/detail?id=32
490 456
491 This test code would fail when we didn't check the return result of 457 This test code would fail when we didn't check the return result of
492 valid_unit_divide in SkChopCubicAt(... tValues[], int roots). The reason is 458 valid_unit_divide in SkChopCubicAt(... tValues[], int roots). The reason is
493 that after the first chop, the parameters to valid_unit_divide are equal 459 that after the first chop, the parameters to valid_unit_divide are equal
494 (thanks to finite float precision and rounding in the subtracts). Thus 460 (thanks to finite float precision and rounding in the subtracts). Thus
495 even though the 2nd tValue looks < 1.0, after we renormalize it, we end 461 even though the 2nd tValue looks < 1.0, after we renormalize it, we end
496 up with 1.0, hence the need to check and just return the last cubic as 462 up with 1.0, hence the need to check and just return the last cubic as
497 a degenerate clump of 4 points in the sampe place. 463 a degenerate clump of 4 points in the sampe place.
498 464
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 matrix.preScale(SK_Scalar1, -SK_Scalar1); 1534 matrix.preScale(SK_Scalar1, -SK_Scalar1);
1569 } 1535 }
1570 if (userMatrix) { 1536 if (userMatrix) {
1571 matrix.postConcat(*userMatrix); 1537 matrix.postConcat(*userMatrix);
1572 } 1538 }
1573 for (int i = 0; i < conicCount; ++i) { 1539 for (int i = 0; i < conicCount; ++i) {
1574 matrix.mapPoints(dst[i].fPts, 3); 1540 matrix.mapPoints(dst[i].fPts, 3);
1575 } 1541 }
1576 return conicCount; 1542 return conicCount;
1577 } 1543 }
OLDNEW
« no previous file with comments | « src/core/SkGeometry.h ('k') | src/core/SkScan_Hairline.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698