Skip to content

Commit

Permalink
restore pdf_coord__equal
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Sep 15, 2019
1 parent 65de0bb commit b7c3a27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
5 changes: 0 additions & 5 deletions dpx/src/dpx_pdfdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,6 @@ impl pdf_coord {
Self { x: 0., y: 0. }
}
}
impl PartialEq for pdf_coord {
fn eq(&self, other: &Self) -> bool {
(self.x - other.x).abs() < 1e-7 && (self.y - other.y).abs() < 1e-7
}
}

#[derive(Copy, Clone, Default)]
#[repr(C)]
Expand Down
16 changes: 10 additions & 6 deletions dpx/src/dpx_pdfdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ pub struct LineDash {
pub offset: f64,
}

fn pdf_coord__equal(p1: &pdf_coord, p2: &pdf_coord) -> bool {
((p1.x - p2.x).abs() < 1e-7) && ((p1.y - p2.y).abs() < 1e-7)
}

unsafe extern "C" fn inversematrix(mut W: &mut pdf_tmatrix, mut M: &pdf_tmatrix) -> i32 {
let mut det: f64 = 0.;
det = M.a * M.d - M.b * M.c;
Expand Down Expand Up @@ -283,21 +287,21 @@ unsafe extern "C" fn pdf_path__next_pe<'a>(
pe.p[0] = *cp;
}
PeType::LINETO => {
if &pe.p[0] != cp {
if !pdf_coord__equal(&pe.p[0], cp) {
let mut pe = pa_elem::default();
pe.p[0] = *cp;
pa.path.push(pe);
}
}
PeType::CURVETO => {
if &pe.p[2] != cp {
if !pdf_coord__equal(&pe.p[2], cp) {
let mut pe = pa_elem::default();
pe.p[0] = *cp;
pa.path.push(pe);
}
}
PeType::CURVETO_Y | PeType::CURVETO_V => {
if &pe.p[1] != cp {
if !pdf_coord__equal(&pe.p[1], cp) {
let mut pe = pa_elem::default();
pe.p[0] = *cp;
pa.path.push(pe);
Expand Down Expand Up @@ -358,12 +362,12 @@ unsafe extern "C" fn pdf_path__curveto(
p2: &pdf_coord,
) -> i32 {
let pe = pdf_path__next_pe(pa, cp);
if cp == p0 {
if pdf_coord__equal(cp, p0) {
pe.typ = PeType::CURVETO_V;
pe.p[0] = *p1;
*cp = *p2;
pe.p[1] = *cp;
} else if p1 == p2 {
} else if pdf_coord__equal(p1, p2) {
pe.typ = PeType::CURVETO_Y;
pe.p[0] = *p0;
*cp = *p1;
Expand Down Expand Up @@ -449,7 +453,7 @@ unsafe extern "C" fn pdf_path__elliptarc(
p0.y += ca.y;
if pa.path.is_empty() {
pdf_path__moveto(pa, cp, &mut p0);
} else if cp != &p0 {
} else if !pdf_coord__equal(cp, &p0) {
pdf_path__lineto(pa, cp, &mut p0);
/* add line seg */
}
Expand Down

0 comments on commit b7c3a27

Please sign in to comment.