Skip to content

Commit 7e39c40

Browse files
authored
Mark some Ellipse methods as inline (#496)
We're especially interested in marking `Ellipse::radii` inline, motivated by linebender/vello#1180.
1 parent 1f31e44 commit 7e39c40

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ It was increased to support floating point math in const functions.
2727
incidentally also uses the usual definition of aspect ratio (where the old name didn't). ([#486][] by [@DJMcNab][])
2828
- Breaking change: The deprecated `offset::CubicOffset` has been removed, and replaced by
2929
`offset::offset_cubic`. ([#489][] by [@jneem][])
30+
- Inline some `Ellipse` methods. ([#496][] by [@tomcur][])
3031

3132
### Fixed
3233

@@ -200,6 +201,7 @@ Note: A changelog was not kept for or before this release
200201
[#488]: https://github.com/linebender/kurbo/pull/488
201202
[#489]: https://github.com/linebender/kurbo/pull/489
202203
[#490]: https://github.com/linebender/kurbo/pull/490
204+
[#496]: https://github.com/linebender/kurbo/pull/496
203205

204206
[Unreleased]: https://github.com/linebender/kurbo/compare/v0.11.3...HEAD
205207
[0.11.0]: https://github.com/linebender/kurbo/releases/tag/v0.11.0

kurbo/src/ellipse.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ impl Ellipse {
7575
}
7676

7777
/// Create a new `Ellipse` with the provided radii.
78+
#[inline]
7879
#[must_use]
7980
pub fn with_radii(self, new_radii: Vec2) -> Ellipse {
8081
let rotation = self.inner.svd().1;
@@ -87,6 +88,7 @@ impl Ellipse {
8788
///
8889
/// The rotation is clockwise, for a y-down coordinate system. For more
8990
/// on rotation, See [`Affine::rotate`].
91+
#[inline]
9092
#[must_use]
9193
pub fn with_rotation(self, rotation: f64) -> Ellipse {
9294
let scale = self.inner.svd().0;
@@ -118,6 +120,7 @@ impl Ellipse {
118120
///
119121
/// The first number is the horizontal radius and the second is the vertical
120122
/// radius, before rotation.
123+
#[inline]
121124
pub fn radii(&self) -> Vec2 {
122125
self.inner.svd().0
123126
}
@@ -126,13 +129,15 @@ impl Ellipse {
126129
///
127130
/// This allows all possible ellipses to be drawn by always starting with
128131
/// an ellipse with the two radii on the x and y axes.
132+
#[inline]
129133
pub fn rotation(&self) -> f64 {
130134
self.inner.svd().1
131135
}
132136

133137
/// Returns the radii and the rotation of this ellipse.
134138
///
135139
/// Equivalent to `(self.radii(), self.rotation())` but more efficient.
140+
#[inline]
136141
pub fn radii_and_rotation(&self) -> (Vec2, f64) {
137142
self.inner.svd()
138143
}
@@ -181,6 +186,7 @@ impl Sub<Vec2> for Ellipse {
181186

182187
impl Mul<Ellipse> for Affine {
183188
type Output = Ellipse;
189+
#[inline]
184190
fn mul(self, other: Ellipse) -> Self::Output {
185191
Ellipse {
186192
inner: self * other.inner,
@@ -189,6 +195,7 @@ impl Mul<Ellipse> for Affine {
189195
}
190196

191197
impl From<Circle> for Ellipse {
198+
#[inline]
192199
fn from(circle: Circle) -> Self {
193200
Ellipse::new(circle.center, Vec2::splat(circle.radius), 0.0)
194201
}
@@ -248,6 +255,7 @@ impl Shape for Ellipse {
248255
agm_elliptic_perimeter(accuracy, radii)
249256
}
250257

258+
#[inline]
251259
fn winding(&self, pt: Point) -> i32 {
252260
// Strategy here is to apply the inverse map to the point and see if it is in the unit
253261
// circle.

0 commit comments

Comments
 (0)