From 47a6129332b81665389fc6cf796816df1a646ad8 Mon Sep 17 00:00:00 2001 From: pylbrecht Date: Sun, 1 Sep 2019 19:22:20 +0200 Subject: [PATCH] Use raqote's implementation of Path::contains_point() --- Cargo.lock | 2 +- components/canvas/raqote_backend.rs | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 268d829cedbe..f5704962d552 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3712,7 +3712,7 @@ dependencies = [ [[package]] name = "raqote" version = "0.6.2-alpha.0" -source = "git+https://github.com/jrmuizel/raqote#b3675e6cc1ac1d854605918f6613b64636d5e47b" +source = "git+https://github.com/jrmuizel/raqote#b1437ce88d27d376520485a1f8d60c5a480be5c1" dependencies = [ "euclid 0.20.0 (registry+https://github.com/rust-lang/crates.io-index)", "font-kit 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/canvas/raqote_backend.rs b/components/canvas/raqote_backend.rs index 1bbc23a983f7..4534077b0dd0 100644 --- a/components/canvas/raqote_backend.rs +++ b/components/canvas/raqote_backend.rs @@ -185,14 +185,8 @@ impl Path { } pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D) -> bool { - self.as_raqote().ops.iter().any(|op| match op { - PathOp::MoveTo(point) | PathOp::LineTo(point) => { - point.x as f64 == x && point.y as f64 == y - }, - PathOp::QuadTo(_, point) => point.x as f64 == x && point.y as f64 == y, - PathOp::CubicTo(_, _, point) => point.x as f64 == x && point.y as f64 == y, - _ => false, - }) + let path = self.as_raqote(); + path.contains_point(0.1, path.winding, x as f32, y as f32) } pub fn copy_to_builder(&self) -> Box {