| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |