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

Side by Side Diff: experimental/StrokePathRenderer/GrStrokePathRenderer.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 | « bench/GradientBench.cpp ('k') | gm/glyph_pos.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 2012 Google Inc. 2 * Copyright 2012 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 "GrStrokePathRenderer.h" 8 #include "GrStrokePathRenderer.h"
9 9
10 #include "GrDrawTarget.h" 10 #include "GrDrawTarget.h"
(...skipping 21 matching lines...) Expand all
32 SkScalar d = SkScalarMul(x1 - x2, y3 - y4) - SkScalarMul(y1 - y2, x3 - x4); 32 SkScalar d = SkScalarMul(x1 - x2, y3 - y4) - SkScalarMul(y1 - y2, x3 - x4);
33 // If d is zero, there is no intersection 33 // If d is zero, there is no intersection
34 if (SkScalarNearlyZero(d)) { 34 if (SkScalarNearlyZero(d)) {
35 return kNone_IntersectionType; 35 return kNone_IntersectionType;
36 } 36 }
37 37
38 // Get the x and y 38 // Get the x and y
39 SkScalar pre = SkScalarMul(x1, y2) - SkScalarMul(y1, x2), 39 SkScalar pre = SkScalarMul(x1, y2) - SkScalarMul(y1, x2),
40 post = SkScalarMul(x3, y4) - SkScalarMul(y3, x4); 40 post = SkScalarMul(x3, y4) - SkScalarMul(y3, x4);
41 // Compute the point of intersection 41 // Compute the point of intersection
42 res.set((SkScalarMul(pre, x3 - x4) - SkScalarMul(x1 - x2, post) / d, 42 res.set(SkScalarDiv(SkScalarMul(pre, x3 - x4) - SkScalarMul(x1 - x2, post), d),
43 (SkScalarMul(pre, y3 - y4) - SkScalarMul(y1 - y2, post) / d); 43 SkScalarDiv(SkScalarMul(pre, y3 - y4) - SkScalarMul(y1 - y2, post), d));
44 44
45 // Check if the x and y coordinates are within both lines 45 // Check if the x and y coordinates are within both lines
46 return (res.x() < GrMin(x1, x2) || res.x() > GrMax(x1, x2) || 46 return (res.x() < GrMin(x1, x2) || res.x() > GrMax(x1, x2) ||
47 res.x() < GrMin(x3, x4) || res.x() > GrMax(x3, x4) || 47 res.x() < GrMin(x3, x4) || res.x() > GrMax(x3, x4) ||
48 res.y() < GrMin(y1, y2) || res.y() > GrMax(y1, y2) || 48 res.y() < GrMin(y1, y2) || res.y() > GrMax(y1, y2) ||
49 res.y() < GrMin(y3, y4) || res.y() > GrMax(y3, y4)) ? 49 res.y() < GrMin(y3, y4) || res.y() > GrMax(y3, y4)) ?
50 kOut_IntersectionType : kIn_IntersectionType; 50 kOut_IntersectionType : kIn_IntersectionType;
51 } 51 }
52 52
53 GrStrokePathRenderer::GrStrokePathRenderer() { 53 GrStrokePathRenderer::GrStrokePathRenderer() {
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (sinHalfAngleSq >= invMiterLimitSq) { 177 if (sinHalfAngleSq >= invMiterLimitSq) {
178 // Find the miter point (or points i f it is further 178 // Find the miter point (or points i f it is further
179 // than the miter limit) 179 // than the miter limit)
180 const SkPoint pt2 = *pt0+v0, pt3 = * pt1+v1; 180 const SkPoint pt2 = *pt0+v0, pt3 = * pt1+v1;
181 if (intersection(*pt0, pt2, *pt1, pt 3, miterPt[0]) != 181 if (intersection(*pt0, pt2, *pt1, pt 3, miterPt[0]) !=
182 kNone_IntersectionType) { 182 kNone_IntersectionType) {
183 SkPoint miterPt0 = miterPt[0] - *pt0; 183 SkPoint miterPt0 = miterPt[0] - *pt0;
184 SkPoint miterPt1 = miterPt[0] - *pt1; 184 SkPoint miterPt1 = miterPt[0] - *pt1;
185 SkScalar sqDist0 = miterPt0.dot( miterPt0); 185 SkScalar sqDist0 = miterPt0.dot( miterPt0);
186 SkScalar sqDist1 = miterPt1.dot( miterPt1); 186 SkScalar sqDist1 = miterPt1.dot( miterPt1);
187 const SkScalar rSq = radius*radi us / sinHalfAngleSq; 187 const SkScalar rSq =
188 SkScalarDiv(SkScalarMul( radius, radius),
189 sinHalfAngle Sq);
188 const SkScalar sqRLimit = 190 const SkScalar sqRLimit =
189 SkScalarMul(sqMiterLimit , rSq); 191 SkScalarMul(sqMiterLimit , rSq);
190 if (sqDist0 > sqRLimit || sqDist 1 > sqRLimit) { 192 if (sqDist0 > sqRLimit || sqDist 1 > sqRLimit) {
191 if (sqDist1 > sqRLimit) { 193 if (sqDist1 > sqRLimit) {
192 v1.setLength(SkScalarSqr t(sqRLimit)); 194 v1.setLength(SkScalarSqr t(sqRLimit));
193 miterPt[1] = *pt1+v1; 195 miterPt[1] = *pt1+v1;
194 } else { 196 } else {
195 miterPt[1] = miterPt[0]; 197 miterPt[1] = miterPt[0];
196 } 198 }
197 if (sqDist0 > sqRLimit) { 199 if (sqDist0 > sqRLimit) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if (vCount > 0) { 291 if (vCount > 0) {
290 target->drawIndexed(kTriangles_GrPrimitiveType, 292 target->drawIndexed(kTriangles_GrPrimitiveType,
291 0, // start vertex 293 0, // start vertex
292 0, // start index 294 0, // start index
293 vCount, 295 vCount,
294 iCount); 296 iCount);
295 } 297 }
296 298
297 return true; 299 return true;
298 } 300 }
OLDNEW
« no previous file with comments | « bench/GradientBench.cpp ('k') | gm/glyph_pos.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698