Repository navigation
Add missing Geometry functionality - #23180
Conversation
There was a problem hiding this comment.
Pull request overview
This PR closes remaining WinUI parity gaps for Microsoft.UI.Xaml.Media.Geometry / Path on Skia by implementing missing members, fixing SVG path parsing/arc behavior, and adding runtime tests + SamplesApp visual parity pages.
Changes:
- Implement
Geometry.Empty,Geometry.StandardFlatteningTolerance, and SkiaBoundscomputation forPathGeometry/StreamGeometry. - Fix Skia
StreamGeometryContextgaps (ellipticalArcTo, poly-bezier APIs) and correct SVG smooth-curve reflection rules inPathMarkupParser. - Add runtime tests and SamplesApp showcase pages for geometry/path visual parity validation.
Reviewed changes
Copilot reviewed 27 out of 30 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.UI/UI/Xaml/Media/PathGeometry.skia.cs | Implements Skia ComputeBounds() for PathGeometry. |
| src/Uno.UI/UI/Xaml/Media/GeometryHelper.cs | Enables EllipseGeometry -> StreamGeometry writing (non-UIKit). |
| src/Uno.UI/UI/Xaml/Media/Geometry.cs | Adds Geometry.Empty + StandardFlatteningTolerance and wires Bounds through ComputeBounds(). |
| src/Uno.UI/UI/Xaml/Media/EllipseGeometry.cs | Introduces non-generated EllipseGeometry DPs/ctor for parity. |
| src/Uno.UI/Media/StreamGeometry.cs | Adds Skia ComputeBounds() for Uno.Media.StreamGeometry. |
| src/Uno.UI/Media/PathStreamGeometryContext.cs | Adds Skia implementation for elliptical ArcTo and poly bezier methods. |
| src/Uno.UI/Media/PathMarkupParser.cs | Fixes SVG smooth-curve reflection state handling per spec. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Media/Geometry.cs | Removes generated [NotImplemented] stubs for newly-implemented static members. |
| src/Uno.UI/Generated/3.0.0.0/Microsoft.UI.Xaml.Media/EllipseGeometry.cs | Removes generated [NotImplemented] surface now implemented manually. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Shapes/Given_Path.cs | Adds runtime tests for arcs, poly beziers, ellipse-to-stream conversion. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_PathMarkupParser.cs | Adds targeted tests for mini-language parsing and reflection behavior. |
| src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Media/Given_Geometry.cs | Updates/extends tests for Geometry.Empty and StandardFlatteningTolerance. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/PathTestsControl/Path_ArcTo_Gallery.xaml.cs | Adds manual sample page code-behind for arc visual verification. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Shapes/PathTestsControl/Path_ArcTo_Gallery.xaml | Adds arc-focused visual gallery XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_VisualParity_Notes.md | Documents visual parity verification protocol/pages. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_Transforms_Showcase.xaml.cs | Adds transforms showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_Transforms_Showcase.xaml | Adds transforms showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_Stroke_Showcase.xaml.cs | Adds stroke showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_Stroke_Showcase.xaml | Adds stroke showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_StreamGeometry_Showcase.xaml.cs | Adds stream-vs-path showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_StreamGeometry_Showcase.xaml | Adds stream-vs-path showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_SimpleTypes_Showcase.xaml.cs | Adds simple types showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_SimpleTypes_Showcase.xaml | Adds simple types showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_PathMarkup_Showcase.xaml.cs | Adds markup showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_PathMarkup_Showcase.xaml | Adds markup showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_GeometryGroup_FillRule_Showcase.xaml.cs | Adds fill-rule showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_GeometryGroup_FillRule_Showcase.xaml | Adds fill-rule showcase XAML. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_AllSegments_Showcase.xaml.cs | Adds all-segments showcase page registration. |
| src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/Geometry_AllSegments_Showcase.xaml | Adds all-segments showcase XAML. |
| src/SamplesApp/UITests.Shared/UITests.Shared.projitems | Wires new sample XAML/code-behind into the shared project items. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WinAppSDK sync generator drift detected on
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
|
The build 210445 did not find any UI Test snapshots differences. |
|
/apply-sync-gen |
|
Pushed GitHub does not re-trigger workflows for commits pushed by the default bot, so the WinAppSDK Sync Generator Check will not automatically re-run. To turn it green, push any additional commit (for example |
|
|
6f01248 to
d2e6eb1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 27 out of 30 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
|
The build 210538 did not find any UI Test snapshots differences. |
|
|
d2e6eb1 to
1ec3566
Compare
XAML Styler drift detected on
|
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
|
/apply-xaml-style |
|
Pushed GitHub does not re-trigger workflows for commits pushed by the default bot, so the XAML Style Check will not automatically re-run. To turn it green, push any additional commit (for example |
|
|
…ontext Skia branch now uses SkiaSharp's native SVG-arc overload, so paths with non-uniform radii (rx != ry) no longer throw. Implements PolyBezierTo and PolyQuadraticBezierTo on Skia by deferring to existing per-segment helpers. Re-enables EllipseGeometry -> StreamGeometry conversion for non-iOS platforms (iOS workaround for #6849 preserved). Closes #2228 on Skia. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
These are the only WinUI 3 Geometry static members previously stubbed as NotImplemented. Empty returns a cached empty PathGeometry; the standard flattening tolerance is 0.25 per WinUI documentation. Also adds a Skia ComputeBounds override on PathGeometry so Geometry.Empty.Bounds returns default(Rect) instead of throwing. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…ini-language Per SVG spec, the smooth-curve commands S/s and T/t reflect the prior control point only when the previous segment was of the matching curve family (C/c/S/s for S, Q/q/T/t for T). Otherwise the implicit control point coincides with the current point. The parser previously shared a single _previousControlPoint field across cubic and quadratic, and never cleared it after non-bezier commands -- causing S after Q (or after L/H/V/M) to incorrectly reflect a stale control point. Also implements StreamGeometry.ComputeBounds on Skia, which was previously inherited from the base Geometry stub (NotImplementedException). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds 7 SamplesApp pages in Windows_UI_Xaml_Media/Geometry/ that exercise all PathSegment subtypes, simple geometries, the SVG mini-language, stroke variations, geometry transforms, FillRule variants, and StreamGeometry vs PathGeometry equivalence. Each page is laid out as a labeled grid for side-by-side eyeball comparison against the same XAML running on native WinUI/WinAppSDK SamplesApp. A Geometry_VisualParity_Notes.md file documents the verification protocol and which pixel-level differences are acceptable D2D-vs-Skia rasterization divergences vs structural bugs. All pages registered in UITests.Shared.projitems and formatted with xstyler. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Renames EllipseGeometry.Properties.wasm.cs -> EllipseGeometry.cs so the DependencyProperty declarations and constructor are visible to all platforms, not just WASM. The Skia partial in EllipseGeometry.skia.cs already relied on these DPs at runtime, but the auto-generated Geometry metadata file was emitting [Uno.NotImplemented] attributes for __SKIA__ because no shared partial covered them. With the shared partial in place, the next regen of Generated/3.0.0.0/Microsoft.UI.Xaml.Media/EllipseGeometry.cs detects the overlap and emits "Forced skipping" comments instead -- this commit applies that expected output up front so the [NotImplemented] metadata is removed. No runtime behavior change on Skia or WASM; iOS/Android remain [NotImplemented] for the type as before. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
WinUI returns a fresh PathGeometry instance on every Geometry.Empty read (GeometryFactory::get_EmptyImpl). Drop Uno's singleton cache and update the runtime tests to assert the WinUI-correct invariants: the returned instance is an empty PathGeometry, and successive reads return distinct instances.
ccbe711 to
49a4b13
Compare
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
Geometry_Empty_Returns_Empty_PathGeometry asserts Figures.Count == 0 on the instance returned by Geometry.Empty, but native WinUI throws E_UNEXPECTED on PathGeometry.get_Figures for that instance. In WinUI, GeometryFactory::get_EmptyImpl creates the result as a raw ctl::ComObject<PathGeometry>, bypassing BetterCoreObjectActivationFactory and the DXamlCore peer setup. DP getters (Figures, Bounds, ...) route through GetValueByKnownIndex which needs the core peer and fails on the naked instance. Same root cause as EmptyGeometry_CheckBounds. Gate the test to Skia (matching the existing precedent) and document the WinUI behavior in a comment.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
|
The build 211785 found UI Test snapshots differences: Details
|
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23180/wasm-skia-net9/index.html |
|
The build 211832 found UI Test snapshots differences: Details
|
GitHub Issue: closes #23156, closes #2228
PR Type:
🐞 Bugfix / ✨ Feature
What changed? 🚀
Closes the largest gaps between Uno's Skia rendering of
Microsoft.UI.Xaml.Media.Geometry/Microsoft.UI.Xaml.Shapes.Pathand native WinUI 3. Five distinct areas:1.
StreamGeometryContextSkia gaps (fixes #2228)PathStreamGeometryContext.ArcToaccepted only circular arcs (rx == ry) and computed the center from points and a single radius. Replaced withSKPath.ArcTo(rx, ry, rotation, arcSize, direction, x, y), which natively supports SVG elliptical arcs.StreamGeometryContext.PolyBezierToandPolyQuadraticBezierTopreviously threwNotImplementedExceptionon Skia; both are now implemented.GeometryHelper.Write(EllipseGeometry)was commented out due to a historical iOS regression and silently dropped the geometry on Skia. Re-enabled for Skia soEllipseGeometry → StreamGeometryround-trips render.2.
Geometrystatic surfaceGeometry.EmptyandGeometry.StandardFlatteningTolerancewere[NotImplemented]stubs. Both implemented to match WinUI:StandardFlatteningTolerancereturns0.25.Emptyreturns a freshPathGeometryper call (verified against WinUI'sGeometryFactory::get_EmptyImpl, which usesctl::ComObject<PathGeometry>::CreateInstance— no caching).3.
PathGeometry/StreamGeometrybounds on SkiaPathGeometry.ComputeBoundsandStreamGeometry.ComputeBoundswere missing on Skia. AddedPathGeometry.skia.csand theStreamGeometryoverride so.Boundsno longer throws.4.
PathMarkupParsersmooth-curve reflectionThe shared
_previousControlPointwas reused across cubic and quadratic curves and never cleared by non-bezier commands, soSafterQ(or afterL/H/V/M) reflected a stale point. Now tracked per curve family, matching the SVG spec:S/sreflects only afterC/c/S/s,T/tonly afterQ/q/T/t; otherwise the implicit control point coincides with the current point.5.
EllipseGeometrygenerator metadataEllipseGeometrywas annotated[Uno.NotImplemented]for__SKIA__even thoughEllipseGeometry.skia.csrendered correctly. Root cause: DP declarations and constructor lived inEllipseGeometry.Properties.wasm.csonly, so the generator did not detect a hand-written partial covering Skia. The wasm-suffixed file is promoted to a sharedEllipseGeometry.cs; the generator now correctly omits theNotImplementedannotation.Tests and samples
Given_PathMarkupParserruntime tests (linear commands, implicit-repeat afterM,Z-then-command,S/Treflection both with and without matching prior segment,F0/F1).Given_Pathcases for SVG elliptical arcs,PolyBezierTo/PolyQuadraticBezierTo, andEllipseGeometry → StreamGeometryround-trip.Given_Geometrycases forEmpty,StandardFlatteningTolerance, and empty-bounds.Geometry_*_Showcasesample pages undersrc/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/Geometry/for side-by-side Skia/WinUI visual parity, plus aPath_ArcTo_Gallerypage.Out of scope
Microsoft.UI.Xaml.Media:CombinedGeometry,GeometryCombineMode,Geometry.Combine,GetFlattenedPathGeometry,GetWidenedPathGeometry,GetOutlinedPathGeometry,FillContainsWithDetail,StrokeContains,GetRenderBounds,GetArea,Pen,ToleranceType.PathStreamGeometryContext— unchanged.PathMarkupParserwholesale.PR Checklist ✅