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

Side by Side Diff: Source/core/rendering/shapes/PolygonShape.cpp

Issue 170453004: Add constant twoPiDouble/twoPiFloat to MathExtras.h (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add constant values to header Created 6 years, 10 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
« no previous file with comments | « Source/core/html/canvas/CanvasPathMethods.cpp ('k') | Source/core/svg/SVGPathParser.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 (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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 static inline FloatSize outwardEdgeNormal(const FloatPolygonEdge& edge) 108 static inline FloatSize outwardEdgeNormal(const FloatPolygonEdge& edge)
109 { 109 {
110 return -inwardEdgeNormal(edge); 110 return -inwardEdgeNormal(edge);
111 } 111 }
112 112
113 static inline void appendArc(Vector<FloatPoint>& vertices, const FloatPoint& arc Center, float arcRadius, const FloatPoint& startArcVertex, const FloatPoint& end ArcVertex, bool padding) 113 static inline void appendArc(Vector<FloatPoint>& vertices, const FloatPoint& arc Center, float arcRadius, const FloatPoint& startArcVertex, const FloatPoint& end ArcVertex, bool padding)
114 { 114 {
115 float startAngle = atan2(startArcVertex.y() - arcCenter.y(), startArcVertex. x() - arcCenter.x()); 115 float startAngle = atan2(startArcVertex.y() - arcCenter.y(), startArcVertex. x() - arcCenter.x());
116 float endAngle = atan2(endArcVertex.y() - arcCenter.y(), endArcVertex.x() - arcCenter.x()); 116 float endAngle = atan2(endArcVertex.y() - arcCenter.y(), endArcVertex.x() - arcCenter.x());
117 const float twoPI = piFloat * 2;
118 if (startAngle < 0) 117 if (startAngle < 0)
119 startAngle += twoPI; 118 startAngle += twoPiFloat;
120 if (endAngle < 0) 119 if (endAngle < 0)
121 endAngle += twoPI; 120 endAngle += twoPiFloat;
122 float angle = (startAngle > endAngle) ? (startAngle - endAngle) : (startAngl e + twoPI - endAngle); 121 float angle = (startAngle > endAngle) ? (startAngle - endAngle) : (startAngl e + twoPiFloat - endAngle);
123 const float arcSegmentCount = 6; // An even number so that one arc vertex wi ll be eactly arcRadius from arcCenter. 122 const float arcSegmentCount = 6; // An even number so that one arc vertex wi ll be eactly arcRadius from arcCenter.
124 float arcSegmentAngle = ((padding) ? -angle : twoPI - angle) / arcSegmentCo unt; 123 float arcSegmentAngle = ((padding) ? -angle : twoPiFloat - angle) / arcSegm entCount;
125 124
126 vertices.append(startArcVertex); 125 vertices.append(startArcVertex);
127 for (unsigned i = 1; i < arcSegmentCount; ++i) { 126 for (unsigned i = 1; i < arcSegmentCount; ++i) {
128 float angle = startAngle + arcSegmentAngle * i; 127 float angle = startAngle + arcSegmentAngle * i;
129 vertices.append(arcCenter + FloatPoint(cos(angle) * arcRadius, sin(angle ) * arcRadius)); 128 vertices.append(arcCenter + FloatPoint(cos(angle) * arcRadius, sin(angle ) * arcRadius));
130 } 129 }
131 vertices.append(endArcVertex); 130 vertices.append(endArcVertex);
132 } 131 }
133 132
134 static inline void snapVerticesToLayoutUnitGrid(Vector<FloatPoint>& vertices) 133 static inline void snapVerticesToLayoutUnitGrid(Vector<FloatPoint>& vertices)
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 521 }
523 } 522 }
524 } 523 }
525 524
526 if (firstFitFound) 525 if (firstFitFound)
527 result = LayoutUnit::fromFloatCeil(firstFitRect.y()); 526 result = LayoutUnit::fromFloatCeil(firstFitRect.y());
528 return firstFitFound; 527 return firstFitFound;
529 } 528 }
530 529
531 } // namespace WebCore 530 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/html/canvas/CanvasPathMethods.cpp ('k') | Source/core/svg/SVGPathParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698