diff --git a/content/src/clip.rs b/content/src/clip.rs index c5d4aa70..d74d3960 100644 --- a/content/src/clip.rs +++ b/content/src/clip.rs @@ -41,38 +41,6 @@ impl TEdge for Edge { } } -#[derive(Clone, Copy, Debug)] -enum AxisAlignedEdge { - Left(f32), - Top(f32), - Right(f32), - Bottom(f32), -} - -impl TEdge for AxisAlignedEdge { - #[inline] - fn point_is_inside(&self, point: Vector2F) -> bool { - match *self { - AxisAlignedEdge::Left(x) => point.x() >= x, - AxisAlignedEdge::Top(y) => point.y() >= y, - AxisAlignedEdge::Right(x) => point.x() <= x, - AxisAlignedEdge::Bottom(y) => point.y() <= y, - } - } - - fn intersect_line_segment(&self, segment: LineSegment2F) -> ArrayVec<[f32; 3]> { - let mut results = ArrayVec::new(); - let t = match *self { - AxisAlignedEdge::Left(x) | AxisAlignedEdge::Right(x) => segment.solve_t_for_x(x), - AxisAlignedEdge::Top(y) | AxisAlignedEdge::Bottom(y) => segment.solve_t_for_y(y), - }; - if t >= 0.0 && t <= 1.0 { - results.push(t); - } - results - } -} - trait TEdge: Debug { fn point_is_inside(&self, point: Vector2F) -> bool; fn intersect_line_segment(&self, segment: LineSegment2F) -> ArrayVec<[f32; 3]>; @@ -340,42 +308,6 @@ enum EdgeRelativeLocation { Outside, } -// Fast axis-aligned box 2D clipping - -pub(crate) struct ContourRectClipper { - clip_rect: RectF, - contour: Contour, -} - -impl ContourClipper for ContourRectClipper { - type Edge = AxisAlignedEdge; - - #[inline] - fn contour_mut(&mut self) -> &mut Contour { - &mut self.contour - } -} - -impl ContourRectClipper { - #[inline] - pub(crate) fn new(clip_rect: RectF, contour: Contour) -> ContourRectClipper { - ContourRectClipper { clip_rect, contour } - } - - pub(crate) fn clip(mut self) -> Contour { - if self.clip_rect.contains_rect(self.contour.bounds()) { - return self.contour; - } - - self.clip_against(AxisAlignedEdge::Left(self.clip_rect.min_x())); - self.clip_against(AxisAlignedEdge::Top(self.clip_rect.min_y())); - self.clip_against(AxisAlignedEdge::Right(self.clip_rect.max_x())); - self.clip_against(AxisAlignedEdge::Bottom(self.clip_rect.max_y())); - - self.contour - } -} - // 3D quad clipping pub struct PolygonClipper3D { diff --git a/content/src/outline.rs b/content/src/outline.rs index da11969f..8cb4f229 100644 --- a/content/src/outline.rs +++ b/content/src/outline.rs @@ -10,7 +10,7 @@ //! A compressed in-memory representation of paths. -use crate::clip::{self, ContourPolygonClipper, ContourRectClipper}; +use crate::clip::{self, ContourPolygonClipper}; use crate::dilation::ContourDilator; use crate::orientation::Orientation; use crate::segment::{Segment, SegmentFlags, SegmentKind}; @@ -214,16 +214,6 @@ impl Outline { } } - pub fn clip_against_rect(&mut self, clip_rect: RectF) { - if clip_rect.contains_rect(self.bounds) { - return; - } - - for contour in mem::replace(&mut self.contours, vec![]) { - self.push_contour(ContourRectClipper::new(clip_rect, contour).clip()); - } - } - #[inline] pub fn close_all_contours(&mut self) { self.contours.iter_mut().for_each(|contour| contour.close()); diff --git a/renderer/src/scene.rs b/renderer/src/scene.rs index 7b934096..29bcef6c 100644 --- a/renderer/src/scene.rs +++ b/renderer/src/scene.rs @@ -185,8 +185,6 @@ impl Scene { original_outline: &Outline, options: &PreparedBuildOptions, ) -> Outline { - let effective_view_box = self.effective_view_box(options); - let mut outline; match options.transform { PreparedRenderTransform::Perspective { @@ -220,7 +218,6 @@ impl Scene { } outline.transform(&transform); } - outline.clip_against_rect(effective_view_box); } }