Remove unused `monotonic` module

This commit is contained in:
Patrick Walton 2019-05-08 13:37:17 -07:00
parent b557cdf20f
commit 5568e6f64f
3 changed files with 2 additions and 81 deletions

View File

@ -20,7 +20,6 @@ extern crate log;
pub mod basic; pub mod basic;
pub mod clip; pub mod clip;
pub mod color; pub mod color;
pub mod monotonic;
pub mod orientation; pub mod orientation;
pub mod outline; pub mod outline;
pub mod segment; pub mod segment;

View File

@ -1,78 +0,0 @@
// pathfinder/geometry/src/monotonic.rs
//
// Copyright © 2019 The Pathfinder Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<I>
where
I: Iterator<Item = Segment>,
{
iter: I,
buffer: ArrayVec<[Segment; 2]>,
}
impl<I> Iterator for MonotonicConversionIter<I>
where
I: Iterator<Item = Segment>,
{
type Item = Segment;
#[inline]
fn next(&mut self) -> Option<Segment> {
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<I> MonotonicConversionIter<I>
where
I: Iterator<Item = Segment>,
{
#[inline]
pub fn new(iter: I) -> MonotonicConversionIter<I> {
MonotonicConversionIter {
iter,
buffer: ArrayVec::new(),
}
}
pub fn handle_cubic(&mut self, segment: &Segment) -> Option<Segment> {
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),
}
}
}

View File

@ -480,8 +480,8 @@ impl Contour {
if contour_is_monotonic { if contour_is_monotonic {
if self.point_is_endpoint(point_index) { if self.point_is_endpoint(point_index) {
if let Some(last_endpoint_index) = last_endpoint_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; contour_is_monotonic = false;
} }
} }