feat(libcairo): implement six region exports #14329
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14329"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-01T09:31:35Z.
What
Implement six previously throwing
libcairoregion exports with typed guest SysV ABI:cairo_region_create,cairo_region_reference,cairo_region_destroy,cairo_region_union_rectangle,cairo_region_get_rectangle, andcairo_region_num_rectangles.Regions are refcounted; rectangle union uses Cairo/Pixman's canonical representation of nonoverlapping sorted horizontal bands, merging touching and overlapping x intervals and vertically coalescing matching bands. Integer endpoint/span guards return a persistent
CAIRO_STATUS_INVALID_SIZEwhere conversion to Pixman signed coordinates would be nonportable. Zero/negative extent rectangles contribute no area. Invalid rectangle indices produce an empty rectangle (native Cairo leaves those indices unspecified). The behavior follows the public Cairo region implementation and Pixman region algorithm, with divergence described in the libcairo debt file.Measured progress: 0/161 -> 6/161 (3.73%) callable libcairo exports. The 155 remaining exports still throw. No third-party dependency added.
Open PRs #14258 (matrix), #14327 (image/surface) and #14308 (general unimplemented-return fixes) touch shared
Export.cpp, headers or libcairo CMake integration. Their implemented exports are disjoint. The CMake additions and stub deletions may need routine conflict resolution if those PRs merge first.Coordinated landing order: #14258 (matrix) -> #14327 (image surfaces) -> #14328 (font options) -> #14329 (regions). Symbol implementations are disjoint but the PRs share Cairo export inventory, CMake, and technical-debt files. Each later PR will integrate earlier merged changes before landing; standalone branches are not yet a single integrated Cairo build.
Tested
-Wall -Wextra -Werror).-O1 -g -fsanitize=address,undefined -fno-omit-frame-pointer -Wall -Wextra -Werror).Export.cppcompilation under Windows MinGW and Ubuntu GCC.python tools/tests/test_progress.py(57 tests);python core/libs/tests/test_public_headers.py --audit-only(398 libraries, 26,175 exports);python tools/progress.py --module libcairo(6/161);python tools/check_conventions.py --base upstream/main;git diff --check;python tools/pr_overlap.py --branch feat/libcairo-regions(shared-file overlaps documented above).python tools/check_conventions.py --base origin/mainreports unrelated inherited unknown-NID/commit-subject errors because forkorigin/main(df9cf83c41) is behind current upstream/main (26fa1212b8). Against current upstream/main, conventions pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T06:16:30Z.
Review: COMMENTED
Reviewed — no blocking findings
This implements six libcairo region exports (
cairo_region_create,reference,destroy,union_rectangle,get_rectangleandnum_rectangles) in a newRegion.cpp, with the stubs removed fromExport.cpp. The union keeps the region as canonical bands, and a model-based test checks it: 250 random unions against a coverage grid, with the band invariants checked on every step. The Windows CTest run passedguest_cairo_regions.What I ran
65dd172d0d341cfe59d34e7feb94b7f8b7a8343f; base26fa1212b82f76dd49cf12d65e445d6ff3e0844c. 6 files, +413/-37:libcairo/Region.cpp(new, 201 lines),libcairo/CMakeLists.txt(new, registersguest_cairo_regions),libcairo/Export.cpp(six stubs removed),libcairo/include/InventoryExports.hpp(six declarations with parameters),core/libs/tests/GuestCairoRegions.cpp(new, 179 lines), anddocs/dev/debt/libcairo.md.Region.cppin full: the band merge (AppendBand), the union over band boundaries (UnionRectangle), the overflow and size checks (UnionSafelyand the bounds incairo_region_union_rectangle), and the accessors.Verifyhelper andTestRandomUnionsin full. The random test checks the banding invariants and compares every cell with a coverage grid.guest_cairo_regions(Test #2724, 0.04 s). The run reports 2595 cases, all passing.Results
x2andy2above INT32_MAX, and box widths or heights above INT_MAX, return the error statusTestRandomUnionschecks banding and coverage after each of 250 unionsguest_cairo_regions(hosted, Windows)Test #2724, 0.04 scairo_region_referenceon the error region returns nullRead-only check output
Precheck was not run: no PR-head code is run here. Diff check: passed. Conventions: passed. ABI audit: passed (161 symbols). Stack check: passed. Hosted:
gh api repos/boykopovar/AnyPS5/commits/65dd172d0d341cfe59d34e7feb94b7f8b7a8343f/check-runs, and the Windows job log.Negative control
Not run here. A negative control needs a local build, and code from this head is not run here.
Findings
Blocking
None.
Non-blocking
None.
Sources
github.com/boykopovar/AnyPS5@65dd172d0d/core/libs/prx/libcairo/Region.cppgithub.com/boykopovar/AnyPS5@65dd172d0d/core/libs/tests/GuestCairoRegions.cppgithub.com/boykopovar/AnyPS5@65dd172d0d/core/libs/prx/libcairo/include/InventoryExports.hppgithub.com/boykopovar/AnyPS5@65dd172d0d/core/libs/prx/libcairo/CMakeLists.txtwindowson65dd172d0dNot verified
cairo_region_referenceand the other accessors against cairo's own source.To get this to a good state