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

Side by Side Diff: src/utils/SkCurveMeasure.cpp

Issue 2242603002: Fix bug in cubic derivative coefficient with missing parens (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove extra .0f. Also 2*3 = 6 Created 4 years, 4 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 | « no previous file | no next file » | 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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 "SkCurveMeasure.h" 8 #include "SkCurveMeasure.h"
9 #include "SkGeometry.h" 9 #include "SkGeometry.h"
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 switch (fSegType) { 99 switch (fSegType) {
100 case kQuad_SegType: { 100 case kQuad_SegType: {
101 float Ax = pts[0].x(); 101 float Ax = pts[0].x();
102 float Bx = pts[1].x(); 102 float Bx = pts[1].x();
103 float Cx = pts[2].x(); 103 float Cx = pts[2].x();
104 float Ay = pts[0].y(); 104 float Ay = pts[0].y();
105 float By = pts[1].y(); 105 float By = pts[1].y();
106 float Cy = pts[2].y(); 106 float Cy = pts[2].y();
107 107
108 // precompute coefficients for derivative 108 // precompute coefficients for derivative
109 xCoeff[0] = Sk8f(2.0f*(Ax - 2*Bx + Cx)); 109 xCoeff[0] = Sk8f(2*(Ax - 2*Bx + Cx));
110 xCoeff[1] = Sk8f(2.0f*(Bx - Ax)); 110 xCoeff[1] = Sk8f(2*(Bx - Ax));
111 111
112 yCoeff[0] = Sk8f(2.0f*(Ay - 2*By + Cy)); 112 yCoeff[0] = Sk8f(2*(Ay - 2*By + Cy));
113 yCoeff[1] = Sk8f(2.0f*(By - Ay)); 113 yCoeff[1] = Sk8f(2*(By - Ay));
114 } 114 }
115 break; 115 break;
116 case kCubic_SegType: 116 case kCubic_SegType:
117 { 117 {
118 float Ax = pts[0].x(); 118 float Ax = pts[0].x();
119 float Bx = pts[1].x(); 119 float Bx = pts[1].x();
120 float Cx = pts[2].x(); 120 float Cx = pts[2].x();
121 float Dx = pts[3].x(); 121 float Dx = pts[3].x();
122 float Ay = pts[0].y(); 122 float Ay = pts[0].y();
123 float By = pts[1].y(); 123 float By = pts[1].y();
124 float Cy = pts[2].y(); 124 float Cy = pts[2].y();
125 float Dy = pts[3].y(); 125 float Dy = pts[3].y();
126 126
127 // precompute coefficients for derivative 127 // precompute coefficients for derivative
128 xCoeff[0] = Sk8f(3.0f*(-Ax + 3.0f*(Bx - Cx) + Dx)); 128 xCoeff[0] = Sk8f(3*(-Ax + 3*(Bx - Cx) + Dx));
129 xCoeff[1] = Sk8f(3.0f*(2.0f*(Ax - 2.0f*Bx + Cx))); 129 xCoeff[1] = Sk8f(6*(Ax - 2*Bx + Cx));
130 xCoeff[2] = Sk8f(3.0f*(-Ax + Bx)); 130 xCoeff[2] = Sk8f(3*(-Ax + Bx));
131 131
132 yCoeff[0] = Sk8f(3.0f*(-Ay + 3.0f*(By - Cy) + Dy)); 132 yCoeff[0] = Sk8f(3*(-Ay + 3*(By - Cy) + Dy));
133 yCoeff[1] = Sk8f(3.0f * -Ay + By + 2.0f*(Ay - 2.0f*By + Cy)); 133 yCoeff[1] = Sk8f(6*(Ay - 2*By + Cy));
134 yCoeff[2] = Sk8f(3.0f*(-Ay + By)); 134 yCoeff[2] = Sk8f(3*(-Ay + By));
135 } 135 }
136 break; 136 break;
137 case kConic_SegType: 137 case kConic_SegType:
138 UNIMPLEMENTED; 138 UNIMPLEMENTED;
139 break; 139 break;
140 default: 140 default:
141 UNIMPLEMENTED; 141 UNIMPLEMENTED;
142 } 142 }
143 } 143 }
144 144
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (time) { 301 if (time) {
302 *time = t; 302 *time = t;
303 } 303 }
304 if (pos) { 304 if (pos) {
305 *pos = evaluate(fPts, fSegType, t); 305 *pos = evaluate(fPts, fSegType, t);
306 } 306 }
307 if (tan) { 307 if (tan) {
308 *tan = evaluateDerivative(fPts, fSegType, t); 308 *tan = evaluateDerivative(fPts, fSegType, t);
309 } 309 }
310 } 310 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698