feat(libcairo): compute quantized path extents #15675

Closed
hyvvs wants to merge 14 commits from upstream-pr/15675 into main
hyvvs commented 2026-11-04 03:17:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-04T03:17:54Z.


What

Implement one additional, previously throwing libcairo export, cairo_path_extents, with its typed guest System V ABI, using the existing path-storage implementation of #15430. The function ignores isolated moves, includes the endpoints of actual line segments, finds interior cubic Bezier extrema by solving the derivative quadratics, and reports path bounds in current user coordinates after device 24.8 quantization, CTM inversion and surface-device scaling. It does not pretend to rasterize; stroke/fill/arc exports remain unimplemented. The technical debt reflects one fewer throwing NID (85 on this stacked branch). The PS5 library's actual implementation has not been verified on hardware.

This branch is explicitly built on #15430 (whose ancestry includes #15324); it adds one new functional export, not 76 newly implemented exports versus main.

Tested

  • Windows 11 MinGW GCC 15.2 -O2 -DNDEBUG -Wall -Wextra -Werror -pedantic: source-linked GuestCairoPathExtents, GuestCairoGeometry, GuestCairoPath and GuestCairoContext all pass.
  • WSL Ubuntu Linux GCC source-linked test also passes with AddressSanitizer, UndefinedBehaviorSanitizer, detect_leaks=1 and halt-on-error.
  • Same GuestCairoPathExtents regression source compiled and run against native Cairo 1.18.0 (libcairo.so.2): matches ten fixed expected path-bounds scenarios, including empty/move-only, move-and-close, negative line, cubic extrema with fractional 24.8 rounding, open/closed polyline and rotated CTM. Additional seeded differential: 1,500 randomized path sequences across mixed translate/rotate/scale, rectangle, negative lines, cubic curves, close path and device-scale cases, with zero mismatches at relative tolerance 1e-5 after the fixed-point and move-close corrections.
  • Negative control: mutate AddCubicRange to omit interior extrema, build and run the checked-in test; it fails because curve maximum y becomes 0 instead of 75.
  • Public header audit verified 405 libraries and 27,906 exports, no duplicate declarations. python tools/progress.py --module libcairo: 76/161 callable on this branch vs 75/161 on parent #15430. Strict conventions and diff checks run on the exact commit. A complete project-integrated CMake/CTest build and a console run were not performed locally.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #15430
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5148241407 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15675). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-11-04T03:17:54Z. --- ### What Implement one additional, previously throwing `libcairo` export, `cairo_path_extents`, with its typed guest System V ABI, using the existing path-storage implementation of #15430. The function ignores isolated moves, includes the endpoints of actual line segments, finds interior cubic Bezier extrema by solving the derivative quadratics, and reports path bounds in current user coordinates after device 24.8 quantization, CTM inversion and surface-device scaling. It does not pretend to rasterize; stroke/fill/arc exports remain unimplemented. The technical debt reflects one fewer throwing NID (85 on this stacked branch). The PS5 library's actual implementation has not been verified on hardware. This branch is explicitly built on #15430 (whose ancestry includes #15324); it adds **one new functional export**, not 76 newly implemented exports versus main. ### Tested - Windows 11 MinGW GCC 15.2 `-O2 -DNDEBUG -Wall -Wextra -Werror -pedantic`: source-linked GuestCairoPathExtents, GuestCairoGeometry, GuestCairoPath and GuestCairoContext all pass. - WSL Ubuntu Linux GCC source-linked test also passes with AddressSanitizer, UndefinedBehaviorSanitizer, `detect_leaks=1` and halt-on-error. - Same GuestCairoPathExtents regression source compiled and run against **native Cairo 1.18.0** (`libcairo.so.2`): matches ten fixed expected path-bounds scenarios, including empty/move-only, move-and-close, negative line, cubic extrema with fractional 24.8 rounding, open/closed polyline and rotated CTM. Additional seeded differential: 1,500 randomized path sequences across mixed translate/rotate/scale, rectangle, negative lines, cubic curves, close path and device-scale cases, with **zero mismatches at relative tolerance 1e-5** after the fixed-point and move-close corrections. - Negative control: mutate `AddCubicRange` to omit interior extrema, build and run the checked-in test; it fails because `curve` maximum y becomes 0 instead of 75. - Public header audit verified 405 libraries and 27,906 exports, no duplicate declarations. `python tools/progress.py --module libcairo`: 76/161 callable on this branch vs 75/161 on parent #15430. Strict conventions and diff checks run on the exact commit. A complete project-integrated CMake/CTest build and a console run were not performed locally. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #15430 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!15675
No description provided.