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 13 matching lines...) Expand all Loading... |
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 #include "config.h" | 27 #include "config.h" |
28 #include "platform/geometry/FloatPoint.h" | 28 #include "platform/geometry/FloatPoint.h" |
29 | 29 |
30 #include "SkPoint.h" | 30 #include "SkPoint.h" |
31 #include "platform/FloatConversion.h" | 31 #include "platform/FloatConversion.h" |
32 #include "platform/geometry/LayoutPoint.h" | 32 #include "platform/geometry/LayoutPoint.h" |
33 #include "platform/geometry/LayoutSize.h" | 33 #include "platform/geometry/LayoutSize.h" |
34 #include "platform/transforms/AffineTransform.h" | |
35 #include "platform/transforms/TransformationMatrix.h" | |
36 #include <limits> | 34 #include <limits> |
37 #include <math.h> | 35 #include <math.h> |
38 | 36 |
39 namespace WebCore { | 37 namespace WebCore { |
40 | 38 |
41 // Skia has problems when passed infinite, etc floats, filter them to 0. | 39 // Skia has problems when passed infinite, etc floats, filter them to 0. |
42 static inline SkScalar WebCoreFloatToSkScalar(float f) | 40 static inline SkScalar WebCoreFloatToSkScalar(float f) |
43 { | 41 { |
44 return SkFloatToScalar(std::isfinite(f) ? f : 0); | 42 return SkFloatToScalar(std::isfinite(f) ? f : 0); |
45 } | 43 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 m_x += point.x(); | 81 m_x += point.x(); |
84 m_y += point.y(); | 82 m_y += point.y(); |
85 } | 83 } |
86 | 84 |
87 FloatPoint::operator SkPoint() const | 85 FloatPoint::operator SkPoint() const |
88 { | 86 { |
89 SkPoint p = { WebCoreFloatToSkScalar(m_x), WebCoreFloatToSkScalar(m_y) }; | 87 SkPoint p = { WebCoreFloatToSkScalar(m_x), WebCoreFloatToSkScalar(m_y) }; |
90 return p; | 88 return p; |
91 } | 89 } |
92 | 90 |
93 FloatPoint FloatPoint::matrixTransform(const AffineTransform& transform) const | |
94 { | |
95 double newX, newY; | |
96 transform.map(static_cast<double>(m_x), static_cast<double>(m_y), newX, newY
); | |
97 return narrowPrecision(newX, newY); | |
98 } | |
99 | |
100 FloatPoint FloatPoint::matrixTransform(const TransformationMatrix& transform) co
nst | |
101 { | |
102 double newX, newY; | |
103 transform.map(static_cast<double>(m_x), static_cast<double>(m_y), newX, newY
); | |
104 return narrowPrecision(newX, newY); | |
105 } | |
106 | |
107 FloatPoint FloatPoint::narrowPrecision(double x, double y) | 91 FloatPoint FloatPoint::narrowPrecision(double x, double y) |
108 { | 92 { |
109 return FloatPoint(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)); | 93 return FloatPoint(narrowPrecisionToFloat(x), narrowPrecisionToFloat(y)); |
110 } | 94 } |
111 | 95 |
112 float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c) | 96 float findSlope(const FloatPoint& p1, const FloatPoint& p2, float& c) |
113 { | 97 { |
114 if (p2.x() == p1.x()) | 98 if (p2.x() == p1.x()) |
115 return std::numeric_limits<float>::infinity(); | 99 return std::numeric_limits<float>::infinity(); |
116 | 100 |
(...skipping 16 matching lines...) Expand all Loading... |
133 return false; | 117 return false; |
134 | 118 |
135 float param = ((d1.x() - p1.x()) * dyLength - (d1.y() - p1.y()) * dxLength)
/ denom; | 119 float param = ((d1.x() - p1.x()) * dyLength - (d1.y() - p1.y()) * dxLength)
/ denom; |
136 | 120 |
137 intersection.setX(p1.x() + param * pxLength); | 121 intersection.setX(p1.x() + param * pxLength); |
138 intersection.setY(p1.y() + param * pyLength); | 122 intersection.setY(p1.y() + param * pyLength); |
139 return true; | 123 return true; |
140 } | 124 } |
141 | 125 |
142 } | 126 } |
OLD | NEW |