OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 static inline FloatSize outwardEdgeNormal(const FloatPolygonEdge& edge) { | 48 static inline FloatSize outwardEdgeNormal(const FloatPolygonEdge& edge) { |
49 return -inwardEdgeNormal(edge); | 49 return -inwardEdgeNormal(edge); |
50 } | 50 } |
51 | 51 |
52 static inline bool overlapsYRange(const FloatRect& rect, float y1, float y2) { | 52 static inline bool overlapsYRange(const FloatRect& rect, float y1, float y2) { |
53 return !rect.isEmpty() && y2 >= y1 && y2 >= rect.y() && y1 <= rect.maxY(); | 53 return !rect.isEmpty() && y2 >= y1 && y2 >= rect.y() && y1 <= rect.maxY(); |
54 } | 54 } |
55 | 55 |
56 float OffsetPolygonEdge::xIntercept(float y) const { | 56 float OffsetPolygonEdge::xIntercept(float y) const { |
57 ASSERT(y >= minY() && y <= maxY()); | 57 DCHECK_GE(y, minY()); |
| 58 DCHECK_LE(y, maxY()); |
58 | 59 |
59 if (vertex1().y() == vertex2().y() || vertex1().x() == vertex2().x()) | 60 if (vertex1().y() == vertex2().y() || vertex1().x() == vertex2().x()) |
60 return minX(); | 61 return minX(); |
61 if (y == minY()) | 62 if (y == minY()) |
62 return vertex1().y() < vertex2().y() ? vertex1().x() : vertex2().x(); | 63 return vertex1().y() < vertex2().y() ? vertex1().x() : vertex2().x(); |
63 if (y == maxY()) | 64 if (y == maxY()) |
64 return vertex1().y() > vertex2().y() ? vertex1().x() : vertex2().x(); | 65 return vertex1().y() > vertex2().y() ? vertex1().x() : vertex2().x(); |
65 | 66 |
66 return vertex1().x() + | 67 return vertex1().x() + |
67 ((y - vertex1().y()) * (vertex2().x() - vertex1().x()) / | 68 ((y - vertex1().y()) * (vertex2().x() - vertex1().x()) / |
(...skipping 20 matching lines...) Expand all Loading... |
88 } else { | 89 } else { |
89 minYVertex = vertex2(); | 90 minYVertex = vertex2(); |
90 maxYVertex = vertex1(); | 91 maxYVertex = vertex1(); |
91 } | 92 } |
92 float xForY1 = (minYVertex.y() < y1) ? xIntercept(y1) : minYVertex.x(); | 93 float xForY1 = (minYVertex.y() < y1) ? xIntercept(y1) : minYVertex.x(); |
93 float xForY2 = (maxYVertex.y() > y2) ? xIntercept(y2) : maxYVertex.x(); | 94 float xForY2 = (maxYVertex.y() > y2) ? xIntercept(y2) : maxYVertex.x(); |
94 return FloatShapeInterval(std::min(xForY1, xForY2), std::max(xForY1, xForY2)); | 95 return FloatShapeInterval(std::min(xForY1, xForY2), std::max(xForY1, xForY2)); |
95 } | 96 } |
96 | 97 |
97 static float circleXIntercept(float y, float radius) { | 98 static float circleXIntercept(float y, float radius) { |
98 ASSERT(radius > 0); | 99 DCHECK_GT(radius, 0); |
99 return radius * sqrt(1 - (y * y) / (radius * radius)); | 100 return radius * sqrt(1 - (y * y) / (radius * radius)); |
100 } | 101 } |
101 | 102 |
102 static FloatShapeInterval clippedCircleXRange(const FloatPoint& center, | 103 static FloatShapeInterval clippedCircleXRange(const FloatPoint& center, |
103 float radius, | 104 float radius, |
104 float y1, | 105 float y1, |
105 float y2) { | 106 float y2) { |
106 if (y1 >= center.y() + radius || y2 <= center.y() - radius) | 107 if (y1 >= center.y() + radius || y2 <= center.y() - radius) |
107 return FloatShapeInterval(); | 108 return FloatShapeInterval(); |
108 | 109 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const { | 169 void PolygonShape::buildDisplayPaths(DisplayPaths& paths) const { |
169 if (!m_polygon.numberOfVertices()) | 170 if (!m_polygon.numberOfVertices()) |
170 return; | 171 return; |
171 paths.shape.moveTo(m_polygon.vertexAt(0)); | 172 paths.shape.moveTo(m_polygon.vertexAt(0)); |
172 for (size_t i = 1; i < m_polygon.numberOfVertices(); ++i) | 173 for (size_t i = 1; i < m_polygon.numberOfVertices(); ++i) |
173 paths.shape.addLineTo(m_polygon.vertexAt(i)); | 174 paths.shape.addLineTo(m_polygon.vertexAt(i)); |
174 paths.shape.closeSubpath(); | 175 paths.shape.closeSubpath(); |
175 } | 176 } |
176 | 177 |
177 } // namespace blink | 178 } // namespace blink |
OLD | NEW |