From 8a499bc50e92a798d6c29ae0996edd86e0bd4601 Mon Sep 17 00:00:00 2001 From: Ishi Tatsuyuki Date: Wed, 17 Mar 2021 00:51:13 +0900 Subject: [PATCH] Always close fill paths, fix #68 --- piet-gpu/src/render_ctx.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/piet-gpu/src/render_ctx.rs b/piet-gpu/src/render_ctx.rs index 73d1f27..419c9ec 100644 --- a/piet-gpu/src/render_ctx.rs +++ b/piet-gpu/src/render_ctx.rs @@ -303,6 +303,21 @@ impl PietGpuRenderContext { } fn encode_path(&mut self, path: impl Iterator, is_fill: bool) { + if is_fill { + self.encode_path_inner(path.flat_map(|el| { + match el { + PathEl::MoveTo(..) => { + Some(PathEl::ClosePath) + } + _ => None + }.into_iter().chain(Some(el)) + }).chain(Some(PathEl::ClosePath)), is_fill) + } else { + self.encode_path_inner(path, is_fill) + } + } + + fn encode_path_inner(&mut self, path: impl Iterator, is_fill: bool) { let flatten = false; if flatten { let mut start_pt = None;