From ca71dbd9d399414e06c42007a7cb53759eeb5ea3 Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Fri, 29 May 2026 09:47:55 +0300 Subject: [PATCH] Fixed path write issue --- src/CanvasComponents/MeshCanvasComponent.cpp | 8 +++++--- src/DrawingProgram/Tools/BrushTool.cpp | 4 +--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/CanvasComponents/MeshCanvasComponent.cpp b/src/CanvasComponents/MeshCanvasComponent.cpp index 0b56a8a..31b95dc 100644 --- a/src/CanvasComponents/MeshCanvasComponent.cpp +++ b/src/CanvasComponents/MeshCanvasComponent.cpp @@ -58,15 +58,17 @@ template void skpath_write(const SkPath& p, Archive& a) { break; } } - a(contourSizes); + a(p.getFillType() == SkPathFillType::kEvenOdd, contourSizes); for(const SkPoint& p : points) a(p); } template SkPath skpath_read(Archive& a) { + bool isEvenOdd; SkPathBuilder builder; std::vector contourSizes; - a(contourSizes); + a(isEvenOdd, contourSizes); + builder.setFillType(isEvenOdd ? SkPathFillType::kEvenOdd : SkPathFillType::kWinding); for(uint32_t contourSize : contourSizes) { SkPoint p; if(contourSize == 0) @@ -289,7 +291,7 @@ std::vector MeshCanvasComponent::attempt_split(Drawin clipper.AddSubject(clippingSubjects); clipper.AddClip(clippingSubjects); - clipper.Execute(ClipType::Union, FillRule::EvenOdd, solutionTree); + clipper.Execute(ClipType::Union, d.meshPath.getFillType() == SkPathFillType::kEvenOdd ? FillRule::EvenOdd : FillRule::NonZero, solutionTree); std::vector splitPaths; diff --git a/src/DrawingProgram/Tools/BrushTool.cpp b/src/DrawingProgram/Tools/BrushTool.cpp index 8b54abc..4b7c2d7 100644 --- a/src/DrawingProgram/Tools/BrushTool.cpp +++ b/src/DrawingProgram/Tools/BrushTool.cpp @@ -84,9 +84,7 @@ void BrushTool::commit_data(bool final) { MeshCanvasComponent& newMesh = static_cast(containerPtr->get_comp()); newMesh.d.meshPath = BrushComponentCode::brush_stroke_to_skpath(genData.brushPoints, drawP.world.main.toolConfig.brush.hasRoundCaps); if(final) { - std::optional simplified = Simplify(newMesh.d.meshPath); - if(simplified.has_value()) - newMesh.d.meshPath = simplified.value(); + containerPtr->get_comp().simplify_paths(); containerPtr->normalize_object_coordinates(); } containerPtr->commit_update(drawP);