| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved. |
| 3 * 2006 Rob Buis <buis@kde.org> | 3 * 2006 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "Path.h" | 30 #include "Path.h" |
| 31 | 31 |
| 32 #include "FloatPoint.h" | 32 #include "FloatPoint.h" |
| 33 #include "FloatRect.h" | 33 #include "FloatRect.h" |
| 34 #include "PathTraversalState.h" | 34 #include "PathTraversalState.h" |
| 35 #include <math.h> | 35 #include <math.h> |
| 36 #include <wtf/MathExtras.h> | 36 #include <wtf/MathExtras.h> |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 #if !PLATFORM(OPENVG) && !PLATFORM(QT) | |
| 41 static void pathLengthApplierFunction(void* info, const PathElement* element) | 40 static void pathLengthApplierFunction(void* info, const PathElement* element) |
| 42 { | 41 { |
| 43 PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info)
; | 42 PathTraversalState& traversalState = *static_cast<PathTraversalState*>(info)
; |
| 44 if (traversalState.m_success) | 43 if (traversalState.m_success) |
| 45 return; | 44 return; |
| 46 FloatPoint* points = element->points; | 45 FloatPoint* points = element->points; |
| 47 float segmentLength = 0; | 46 float segmentLength = 0; |
| 48 switch (element->type) { | 47 switch (element->type) { |
| 49 case PathElementMoveToPoint: | 48 case PathElementMoveToPoint: |
| 50 segmentLength = traversalState.moveTo(points[0]); | 49 segmentLength = traversalState.moveTo(points[0]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 82 } |
| 84 | 83 |
| 85 float Path::normalAngleAtLength(float length, bool& ok) const | 84 float Path::normalAngleAtLength(float length, bool& ok) const |
| 86 { | 85 { |
| 87 PathTraversalState traversalState(PathTraversalState::TraversalNormalAngleAt
Length); | 86 PathTraversalState traversalState(PathTraversalState::TraversalNormalAngleAt
Length); |
| 88 traversalState.m_desiredLength = length ? length : std::numeric_limits<float
>::epsilon(); | 87 traversalState.m_desiredLength = length ? length : std::numeric_limits<float
>::epsilon(); |
| 89 apply(&traversalState, pathLengthApplierFunction); | 88 apply(&traversalState, pathLengthApplierFunction); |
| 90 ok = traversalState.m_success; | 89 ok = traversalState.m_success; |
| 91 return traversalState.m_normalAngle; | 90 return traversalState.m_normalAngle; |
| 92 } | 91 } |
| 93 #endif | |
| 94 | 92 |
| 95 void Path::addRoundedRect(const RoundedRect& r) | 93 void Path::addRoundedRect(const RoundedRect& r) |
| 96 { | 94 { |
| 97 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii(
).bottomLeft(), r.radii().bottomRight()); | 95 addRoundedRect(r.rect(), r.radii().topLeft(), r.radii().topRight(), r.radii(
).bottomLeft(), r.radii().bottomRight()); |
| 98 } | 96 } |
| 99 | 97 |
| 100 void Path::addRoundedRect(const FloatRect& rect, const FloatSize& roundingRadii,
RoundedRectStrategy strategy) | 98 void Path::addRoundedRect(const FloatRect& rect, const FloatSize& roundingRadii,
RoundedRectStrategy strategy) |
| 101 { | 99 { |
| 102 if (rect.isEmpty()) | 100 if (rect.isEmpty()) |
| 103 return; | 101 return; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 FloatPoint(rect.x(), rect.maxY() - bottomLeftRadius.height())); | 179 FloatPoint(rect.x(), rect.maxY() - bottomLeftRadius.height())); |
| 182 addLineTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height())); | 180 addLineTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height())); |
| 183 if (topLeftRadius.width() > 0 || topLeftRadius.height() > 0) | 181 if (topLeftRadius.width() > 0 || topLeftRadius.height() > 0) |
| 184 addBezierCurveTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height()
* gCircleControlPoint), | 182 addBezierCurveTo(FloatPoint(rect.x(), rect.y() + topLeftRadius.height()
* gCircleControlPoint), |
| 185 FloatPoint(rect.x() + topLeftRadius.width() * gCircleControlPoint, r
ect.y()), | 183 FloatPoint(rect.x() + topLeftRadius.width() * gCircleControlPoint, r
ect.y()), |
| 186 FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); | 184 FloatPoint(rect.x() + topLeftRadius.width(), rect.y())); |
| 187 | 185 |
| 188 closeSubpath(); | 186 closeSubpath(); |
| 189 } | 187 } |
| 190 | 188 |
| 191 #if !USE(CG) && !PLATFORM(QT) | 189 #if !USE(CG) |
| 192 FloatRect Path::fastBoundingRect() const | 190 FloatRect Path::fastBoundingRect() const |
| 193 { | 191 { |
| 194 return boundingRect(); | 192 return boundingRect(); |
| 195 } | 193 } |
| 196 #endif | 194 #endif |
| 197 | 195 |
| 198 } | 196 } |
| OLD | NEW |