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

Side by Side Diff: src/pathops/SkReduceOrder.cpp

Issue 1522183002: only call scalar finite when necessary (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years 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
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 #include "SkReduceOrder.h" 7 #include "SkReduceOrder.h"
8 8
9 int SkReduceOrder::reduce(const SkDLine& line) { 9 int SkReduceOrder::reduce(const SkDLine& line) {
10 fLine[0] = line[0]; 10 fLine[0] = line[0];
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 // check to see if it is a quadratic or a line 121 // check to see if it is a quadratic or a line
122 static int check_quadratic(const SkDCubic& cubic, SkDCubic& reduction) { 122 static int check_quadratic(const SkDCubic& cubic, SkDCubic& reduction) {
123 double dx10 = cubic[1].fX - cubic[0].fX; 123 double dx10 = cubic[1].fX - cubic[0].fX;
124 double dx23 = cubic[2].fX - cubic[3].fX; 124 double dx23 = cubic[2].fX - cubic[3].fX;
125 double midX = cubic[0].fX + dx10 * 3 / 2; 125 double midX = cubic[0].fX + dx10 * 3 / 2;
126 double sideAx = midX - cubic[3].fX; 126 double sideAx = midX - cubic[3].fX;
127 double sideBx = dx23 * 3 / 2; 127 double sideBx = dx23 * 3 / 2;
128 if (approximately_zero(sideAx) ? !approximately_equal(sideAx, sideBx) 128 if (approximately_zero(sideAx) ? !approximately_equal(sideAx, sideBx)
129 : !AlmostEqualUlps(sideAx, sideBx)) { 129 : !AlmostEqualUlps_Pin(sideAx, sideBx)) {
130 return 0; 130 return 0;
131 } 131 }
132 double dy10 = cubic[1].fY - cubic[0].fY; 132 double dy10 = cubic[1].fY - cubic[0].fY;
133 double dy23 = cubic[2].fY - cubic[3].fY; 133 double dy23 = cubic[2].fY - cubic[3].fY;
134 double midY = cubic[0].fY + dy10 * 3 / 2; 134 double midY = cubic[0].fY + dy10 * 3 / 2;
135 double sideAy = midY - cubic[3].fY; 135 double sideAy = midY - cubic[3].fY;
136 double sideBy = dy23 * 3 / 2; 136 double sideBy = dy23 * 3 / 2;
137 if (approximately_zero(sideAy) ? !approximately_equal(sideAy, sideBy) 137 if (approximately_zero(sideAy) ? !approximately_equal(sideAy, sideBy)
138 : !AlmostEqualUlps(sideAy, sideBy)) { 138 : !AlmostEqualUlps_Pin(sideAy, sideBy)) {
139 return 0; 139 return 0;
140 } 140 }
141 reduction[0] = cubic[0]; 141 reduction[0] = cubic[0];
142 reduction[1].fX = midX; 142 reduction[1].fX = midX;
143 reduction[1].fY = midY; 143 reduction[1].fY = midY;
144 reduction[2] = cubic[3]; 144 reduction[2] = cubic[3];
145 return 3; 145 return 3;
146 } 146 }
147 147
148 static int check_linear(const SkDCubic& cubic, 148 static int check_linear(const SkDCubic& cubic,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 cubic.set(a); 271 cubic.set(a);
272 SkReduceOrder reducer; 272 SkReduceOrder reducer;
273 int order = reducer.reduce(cubic, kAllow_Quadratics); 273 int order = reducer.reduce(cubic, kAllow_Quadratics);
274 if (order == 2 || order == 3) { // cubic became line or quad 274 if (order == 2 || order == 3) { // cubic became line or quad
275 for (int index = 0; index < order; ++index) { 275 for (int index = 0; index < order; ++index) {
276 *reducePts++ = reducer.fQuad[index].asSkPoint(); 276 *reducePts++ = reducer.fQuad[index].asSkPoint();
277 } 277 }
278 } 278 }
279 return SkPathOpsPointsToVerb(order - 1); 279 return SkPathOpsPointsToVerb(order - 1);
280 } 280 }
OLDNEW
« src/pathops/SkPathOpsTypes.cpp ('K') | « src/pathops/SkPathOpsTypes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698