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

Side by Side Diff: src/pathops/SkPathOpsPoint.h

Issue 19203002: fix linux point compare (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/PathOpsSimplifyTest.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 #ifndef SkPathOpsPoint_DEFINED 7 #ifndef SkPathOpsPoint_DEFINED
8 #define SkPathOpsPoint_DEFINED 8 #define SkPathOpsPoint_DEFINED
9 9
10 #include "SkPathOpsTypes.h" 10 #include "SkPathOpsTypes.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 fX -= v.fX; 95 fX -= v.fX;
96 fY -= v.fY; 96 fY -= v.fY;
97 } 97 }
98 98
99 // note: this can not be implemented with 99 // note: this can not be implemented with
100 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX); 100 // return approximately_equal(a.fY, fY) && approximately_equal(a.fX, fX);
101 // because that will not take the magnitude of the values 101 // because that will not take the magnitude of the values
102 bool approximatelyEqual(const SkDPoint& a) const { 102 bool approximatelyEqual(const SkDPoint& a) const {
103 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY), 103 double denom = SkTMax(fabs(fX), SkTMax(fabs(fY),
104 SkTMax(fabs(a.fX), fabs(a.fY)))); 104 SkTMax(fabs(a.fX), fabs(a.fY))));
105 if (denom == 0) { 105 if (precisely_zero(denom)) {
106 return true; 106 return true;
107 } 107 }
108 double inv = 1 / denom; 108 double inv = 1 / denom;
109 return approximately_equal(fX * inv, a.fX * inv) 109 return approximately_equal(fX * inv, a.fX * inv)
110 && approximately_equal(fY * inv, a.fY * inv); 110 && approximately_equal(fY * inv, a.fY * inv);
111 } 111 }
112 112
113 bool approximatelyEqual(const SkPoint& a) const { 113 bool approximatelyEqual(const SkPoint& a) const {
114 return AlmostEqualUlps(SkDoubleToScalar(fX), a.fX) 114 return AlmostEqualUlps(SkDoubleToScalar(fX), a.fX)
115 && AlmostEqualUlps(SkDoubleToScalar(fY), a.fY); 115 && AlmostEqualUlps(SkDoubleToScalar(fY), a.fY);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 double moreRoughlyEqual(const SkDPoint& a) const { 155 double moreRoughlyEqual(const SkDPoint& a) const {
156 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX); 156 return more_roughly_equal(a.fY, fY) && more_roughly_equal(a.fX, fX);
157 } 157 }
158 158
159 double roughlyEqual(const SkDPoint& a) const { 159 double roughlyEqual(const SkDPoint& a) const {
160 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX); 160 return roughly_equal(a.fY, fY) && roughly_equal(a.fX, fX);
161 } 161 }
162 }; 162 };
163 163
164 #endif 164 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/PathOpsSimplifyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698