| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2005 Nokia. All rights reserved. | 3 * Copyright (C) 2005 Nokia. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #ifndef FloatPoint_h | 27 #ifndef FloatPoint_h |
| 28 #define FloatPoint_h | 28 #define FloatPoint_h |
| 29 | 29 |
| 30 #include "core/platform/graphics/FloatSize.h" | 30 #include "core/platform/graphics/FloatSize.h" |
| 31 #include "core/platform/graphics/IntPoint.h" | 31 #include "core/platform/graphics/IntPoint.h" |
| 32 #include "wtf/MathExtras.h" | |
| 33 | 32 |
| 34 #if OS(DARWIN) | 33 #if OS(DARWIN) |
| 35 typedef struct CGPoint CGPoint; | 34 typedef struct CGPoint CGPoint; |
| 36 | 35 |
| 37 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES | 36 #ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES |
| 38 typedef struct CGPoint NSPoint; | 37 typedef struct CGPoint NSPoint; |
| 39 #else | 38 #else |
| 40 typedef struct _NSPoint NSPoint; | 39 typedef struct _NSPoint NSPoint; |
| 41 #endif | 40 #endif |
| 42 #endif | 41 #endif |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 { | 201 { |
| 203 return a.x() != b.x() || a.y() != b.y(); | 202 return a.x() != b.x() || a.y() != b.y(); |
| 204 } | 203 } |
| 205 | 204 |
| 206 inline float operator*(const FloatPoint& a, const FloatPoint& b) | 205 inline float operator*(const FloatPoint& a, const FloatPoint& b) |
| 207 { | 206 { |
| 208 // dot product | 207 // dot product |
| 209 return a.dot(b); | 208 return a.dot(b); |
| 210 } | 209 } |
| 211 | 210 |
| 212 inline IntPoint roundedIntPoint(const FloatPoint& p) | 211 IntPoint roundedIntPoint(const FloatPoint&); |
| 213 { | |
| 214 return IntPoint(clampToInteger(roundf(p.x())), clampToInteger(roundf(p.y()))
); | |
| 215 } | |
| 216 | 212 |
| 217 inline IntPoint flooredIntPoint(const FloatPoint& p) | 213 inline IntPoint flooredIntPoint(const FloatPoint& p) |
| 218 { | 214 { |
| 219 return IntPoint(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y()))
); | 215 return IntPoint(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y()))
); |
| 220 } | 216 } |
| 221 | 217 |
| 222 inline IntPoint ceiledIntPoint(const FloatPoint& p) | 218 inline IntPoint ceiledIntPoint(const FloatPoint& p) |
| 223 { | 219 { |
| 224 return IntPoint(clampToInteger(ceilf(p.x())), clampToInteger(ceilf(p.y()))); | 220 return IntPoint(clampToInteger(ceilf(p.x())), clampToInteger(ceilf(p.y()))); |
| 225 } | 221 } |
| 226 | 222 |
| 227 inline IntSize flooredIntSize(const FloatPoint& p) | 223 inline IntSize flooredIntSize(const FloatPoint& p) |
| 228 { | 224 { |
| 229 return IntSize(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y())))
; | 225 return IntSize(clampToInteger(floorf(p.x())), clampToInteger(floorf(p.y())))
; |
| 230 } | 226 } |
| 231 | 227 |
| 232 inline FloatSize toFloatSize(const FloatPoint& a) | 228 inline FloatSize toFloatSize(const FloatPoint& a) |
| 233 { | 229 { |
| 234 return FloatSize(a.x(), a.y()); | 230 return FloatSize(a.x(), a.y()); |
| 235 } | 231 } |
| 236 | 232 |
| 237 float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c); | 233 float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c); |
| 238 | 234 |
| 239 // Find point where lines through the two pairs of points intersect. Returns fal
se if the lines don't intersect. | 235 // Find point where lines through the two pairs of points intersect. Returns fal
se if the lines don't intersect. |
| 240 bool findIntersection(const FloatPoint& p1, const FloatPoint& p2, const FloatPoi
nt& d1, const FloatPoint& d2, FloatPoint& intersection); | 236 bool findIntersection(const FloatPoint& p1, const FloatPoint& p2, const FloatPoi
nt& d1, const FloatPoint& d2, FloatPoint& intersection); |
| 241 | 237 |
| 242 } | 238 } |
| 243 | 239 |
| 244 #endif | 240 #endif |
| OLD | NEW |