diff --git a/geometry/src/lib.rs b/geometry/src/lib.rs index a84a2ce5..9019d760 100644 --- a/geometry/src/lib.rs +++ b/geometry/src/lib.rs @@ -20,7 +20,6 @@ extern crate log; pub mod basic; pub mod clip; pub mod color; -pub mod monotonic; pub mod orientation; pub mod outline; pub mod segment; diff --git a/geometry/src/monotonic.rs b/geometry/src/monotonic.rs deleted file mode 100644 index 6cb0c04d..00000000 --- a/geometry/src/monotonic.rs +++ /dev/null @@ -1,78 +0,0 @@ -// pathfinder/geometry/src/monotonic.rs -// -// Copyright © 2019 The Pathfinder Project Developers. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! Converts paths to monotonically increasing/decreasing segments in Y. - -use crate::segment::{Segment, SegmentKind}; -use arrayvec::ArrayVec; - -pub struct MonotonicConversionIter -where - I: Iterator, -{ - iter: I, - buffer: ArrayVec<[Segment; 2]>, -} - -impl Iterator for MonotonicConversionIter -where - I: Iterator, -{ - type Item = Segment; - - #[inline] - fn next(&mut self) -> Option { - if let Some(segment) = self.buffer.pop() { - return Some(segment); - } - - let segment = self.iter.next()?; - match segment.kind { - SegmentKind::None => self.next(), - SegmentKind::Line => Some(segment), - SegmentKind::Cubic => self.handle_cubic(&segment), - SegmentKind::Quadratic => { - // TODO(pcwalton): Don't degree elevate! - self.handle_cubic(&segment.to_cubic()) - } - } - } -} - -impl MonotonicConversionIter -where - I: Iterator, -{ - #[inline] - pub fn new(iter: I) -> MonotonicConversionIter { - MonotonicConversionIter { - iter, - buffer: ArrayVec::new(), - } - } - - pub fn handle_cubic(&mut self, segment: &Segment) -> Option { - match segment.as_cubic_segment().y_extrema() { - (Some(t0), Some(t1)) => { - let (segments_01, segment_2) = segment.as_cubic_segment().split(t1); - self.buffer.push(segment_2); - let (segment_0, segment_1) = segments_01.as_cubic_segment().split(t0 / t1); - self.buffer.push(segment_1); - Some(segment_0) - } - (Some(t0), None) | (None, Some(t0)) => { - let (segment_0, segment_1) = segment.as_cubic_segment().split(t0); - self.buffer.push(segment_1); - Some(segment_0) - } - (None, None) => Some(*segment), - } - } -} diff --git a/geometry/src/outline.rs b/geometry/src/outline.rs index 632c9134..e9b46806 100644 --- a/geometry/src/outline.rs +++ b/geometry/src/outline.rs @@ -480,8 +480,8 @@ impl Contour { if contour_is_monotonic { if self.point_is_endpoint(point_index) { if let Some(last_endpoint_index) = last_endpoint_index { - if !self.curve_with_endpoints_is_monotonic(last_endpoint_index, point_index) - { + if !self.curve_with_endpoints_is_monotonic(last_endpoint_index, + point_index) { contour_is_monotonic = false; } }