feat(libcairo): implement ten Cairo affine matrix exports #14258

Merged
hyvvs merged 1 commit from upstream-pr/14258 into main 2026-11-02 19:47:22 +00:00
hyvvs commented 2026-11-01 04:47:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by hyvvs on 2026-11-01T04:47:00Z.


What

Implement 10 real previously throwing libcairo exports for the complete guest-visible Cairo affine-matrix family currently in the 3.20 catalogue: cairo_matrix_init, init_identity, init_translate, translate, scale, rotate, invert, multiply, transform_point, and transform_distance.

Use the published Cairo 48-byte cairo_matrix_t layout and C ABI, preserve the original exported symbols with exact typed signatures, handle output aliasing (result == a/b), Cairo status 5 for noninvertible matrices, and distinct point/distance translation behavior. Avoid a new third-party dependency: this math-only subset requires no rendering backend. The algorithms are independently implemented from Cairo's public matrix API documentation. Existing 151 unrelated rendering/font/surface exports remain unimplemented.

A focused CTest target exercises construction, matrix multiplication order/aliasing, translation/scale composition order, quarter-turn rotation, points vs distances, inversion round trips, singular diagonal partial mutation, and nonfinite determinants. A scoped technical-debt note records that native PS5 behavior and Cairo revision are not verified.

Tested

  • PASS: linked standalone Ubuntu Linux GCC C++20 test with -O1 -g -fno-omit-frame-pointer -Wall -Wextra -Werror -fsanitize=address,undefined, ASAN_OPTIONS=detect_leaks=1.
  • PASS: linked and executed Windows MinGW C++20 guest-SysV ABI test with -Wall -Wextra -Werror.
  • PASS: python tools/tests/test_progress.py (57 tests), python core/libs/tests/test_public_headers.py --audit-only (398 libraries / 25971 exports), conventions, git diff --check.
  • Verified progress at base 6fe120d11b: system libraries 8810/34009 -> 8820/34009 (+10 real implemented exports), libcairo 0/161 -> 10/161. Inventory denominator unchanged.
  • The complete project CMake build/CTest (third-party submodules not initialized in this independent worktree) and real PS5-console differential testing have not been performed. CI should verify full Windows build.

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; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none introduced)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: Cairo matrix-using guests (not measured)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5104470486 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14258). Originally posted by [hyvvs](https://github.com/hyvvs) on 2026-11-01T04:47:00Z. --- ### What Implement **10 real previously throwing libcairo exports** for the complete guest-visible Cairo affine-matrix family currently in the 3.20 catalogue: `cairo_matrix_init`, `init_identity`, `init_translate`, `translate`, `scale`, `rotate`, `invert`, `multiply`, `transform_point`, and `transform_distance`. Use the published Cairo 48-byte `cairo_matrix_t` layout and C ABI, preserve the original exported symbols with exact typed signatures, handle output aliasing (`result == a/b`), Cairo status 5 for noninvertible matrices, and distinct point/distance translation behavior. Avoid a new third-party dependency: this math-only subset requires no rendering backend. The algorithms are independently implemented from Cairo's [public matrix API documentation](https://www.cairographics.org/manual/cairo-cairo-matrix-t.html). Existing 151 unrelated rendering/font/surface exports remain unimplemented. A focused CTest target exercises construction, matrix multiplication order/aliasing, translation/scale composition order, quarter-turn rotation, points vs distances, inversion round trips, singular diagonal partial mutation, and nonfinite determinants. A scoped technical-debt note records that native PS5 behavior and Cairo revision are not verified. ### Tested - **PASS**: linked standalone Ubuntu Linux GCC C++20 test with `-O1 -g -fno-omit-frame-pointer -Wall -Wextra -Werror -fsanitize=address,undefined`, `ASAN_OPTIONS=detect_leaks=1`. - **PASS**: linked and executed Windows MinGW C++20 guest-SysV ABI test with `-Wall -Wextra -Werror`. - **PASS**: `python tools/tests/test_progress.py` (57 tests), `python core/libs/tests/test_public_headers.py --audit-only` (398 libraries / 25971 exports), conventions, `git diff --check`. - **Verified progress** at base `6fe120d11b`: system libraries **8810/34009 -> 8820/34009** (+10 real implemented exports), libcairo **0/161 -> 10/161**. Inventory denominator unchanged. - The complete project CMake build/CTest (third-party submodules not initialized in this independent worktree) and real PS5-console differential testing have **not** been performed. CI should verify full Windows build. ### Checklist - [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 - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none introduced) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: Cairo matrix-using guests (not measured) - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-01 05:01:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-01T05:01:48Z.

Review: APPROVED


Reviewed — looks good

The implementation and focused tests cover the ten matrix exports, multiplication aliasing, transform order, and singular-matrix handling without a material issue found in the inspected diff.

What I ran

Reviewed head a855b5a981057334db4aa0c1d4e3f92457814a89, against the PR base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e; I also checked a merge preview against current main 3c3f38be405c063f52dcc3eca2ef29209912f84b, which merged cleanly. Environment: Debian 12 x86_64, GCC 12.2.0, Python 3.11.2. I did not build or run C++ tests locally.

git diff --check 6fe120d11ba3b92c56ade1bb783e211d5dc0949e...a855b5a981057334db4aa0c1d4e3f92457814a89
python3 tools/check_conventions.py --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --title 'feat(libcairo): implement ten Cairo affine matrix exports' --body /tmp/anyps5-pr-precheck-14258-session/pr-body.md
python3 tools/pr_abi_audit.py --repo /tmp/anyps5-review-14258-exact-20261101 --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --json | python3 -c 'import json,sys; d=json.load(sys.stdin); print("status=%s symbols=%d findings=%d" % (d["status"],len(d["symbols"]),len(d["findings"])))'
python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14258-exact-20261101 --json core/libs/tests/GuestCairoMatrix.cpp
git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/upstream/pr/14258
gh api repos/boykopovar/AnyPS5/commits/a855b5a981057334db4aa0c1d4e3f92457814a89/check-runs --jq '.check_runs[] | [.name,.status,.conclusion] | @tsv'

Results

Check Result
Diff check Passed.
Conventions and PR template Passed.
Export audit Passed: 161 symbols, no findings; this does not prove runtime ABI or console compatibility.
Test registration Confirmed in libcairo/CMakeLists.txt. The test-quality heuristic's unregistered-test warning is a false positive.
Merge preview Clean against current main.
Author-reported tests Linux GCC C++20 ASan/UBSan test and Windows MinGW C++20 guest-SysV ABI test passed; I did not independently run them.
Hosted CI Conventions, eligibility, library portability, intake, labels, and report passed. Windows was in progress; Linux and specialized product jobs were skipped at the final check.
Integrated precheck Its detached checkout lacked workspace-only ABI/test-quality helper scripts; I ran both manually against the exact head.
Unedited command output
$ git diff --check 6fe120d11ba3b92c56ade1bb783e211d5dc0949e...a855b5a981057334db4aa0c1d4e3f92457814a89
[no output; exit status 0]
$ python3 tools/check_conventions.py --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --title 'feat(libcairo): implement ten Cairo affine matrix exports' --body /tmp/anyps5-pr-precheck-14258-session/pr-body.md
All conventions checks passed.
$ python3 tools/pr_abi_audit.py --repo /tmp/anyps5-review-14258-exact-20261101 --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --json | python3 -c 'import json,sys; d=json.load(sys.stdin); print("status=%s symbols=%d findings=%d" % (d["status"],len(d["symbols"]),len(d["findings"])))'
status=passed symbols=161 findings=0
$ python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14258-exact-20261101 --json core/libs/tests/GuestCairoMatrix.cpp
{"findings":[{"path":"core/libs/tests/GuestCairoMatrix.cpp","line":1,"kind":"possible-unregistered-cpp-test","message":"Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."}],"negative_control_candidates":[],"limits":["Heuristics can miss weak assertions and can flag valid tests; inspect every finding.","A test that passes against base is not by itself proof that the PR test is inadequate.","Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."]}
$ grep -n 'GuestCairoMatrix' /tmp/anyps5-review-14258-exact-20261101/core/libs/prx/libcairo/CMakeLists.txt
6:    add_test_executable(guest_cairo_matrix_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoMatrix.cpp)
$ git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/upstream/pr/14258
f7d262ef212b2932828bc35eb84643b4fc63dbb9
$ gh api repos/boykopovar/AnyPS5/commits/a855b5a981057334db4aa0c1d4e3f92457814a89/check-runs --jq '.check_runs[] | [.name,.status,.conclusion] | @tsv'
register-context	completed	skipped
relinker	completed	skipped
relinker-asan	completed	skipped
linux	completed	skipped
write-watch	completed	skipped
windows	in_progress	
labels	completed	success
eligibility	completed	success
library-portability	completed	success
intake	completed	success
conventions	completed	success
report	completed	success

Sources

Not verified

No local build, local CTest, or PS5-console differential test. Windows CI had not completed; Linux and specialized hosted jobs were skipped when checked.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5726563798 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14258#pullrequestreview-5726563798). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-01T05:01:48Z. **Review:** APPROVED --- # Reviewed — looks good The implementation and focused tests cover the ten matrix exports, multiplication aliasing, transform order, and singular-matrix handling without a material issue found in the inspected diff. ## What I ran Reviewed head `a855b5a981057334db4aa0c1d4e3f92457814a89`, against the PR base `6fe120d11ba3b92c56ade1bb783e211d5dc0949e`; I also checked a merge preview against current `main` `3c3f38be405c063f52dcc3eca2ef29209912f84b`, which merged cleanly. Environment: Debian 12 x86_64, GCC 12.2.0, Python 3.11.2. I did not build or run C++ tests locally. ```sh git diff --check 6fe120d11ba3b92c56ade1bb783e211d5dc0949e...a855b5a981057334db4aa0c1d4e3f92457814a89 python3 tools/check_conventions.py --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --title 'feat(libcairo): implement ten Cairo affine matrix exports' --body /tmp/anyps5-pr-precheck-14258-session/pr-body.md python3 tools/pr_abi_audit.py --repo /tmp/anyps5-review-14258-exact-20261101 --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --json | python3 -c 'import json,sys; d=json.load(sys.stdin); print("status=%s symbols=%d findings=%d" % (d["status"],len(d["symbols"]),len(d["findings"])))' python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14258-exact-20261101 --json core/libs/tests/GuestCairoMatrix.cpp git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/upstream/pr/14258 gh api repos/boykopovar/AnyPS5/commits/a855b5a981057334db4aa0c1d4e3f92457814a89/check-runs --jq '.check_runs[] | [.name,.status,.conclusion] | @tsv' ``` ## Results | Check | Result | |---|---| | Diff check | Passed. | | Conventions and PR template | Passed. | | Export audit | Passed: 161 symbols, no findings; this does not prove runtime ABI or console compatibility. | | Test registration | Confirmed in `libcairo/CMakeLists.txt`. The test-quality heuristic's unregistered-test warning is a false positive. | | Merge preview | Clean against current `main`. | | Author-reported tests | Linux GCC C++20 ASan/UBSan test and Windows MinGW C++20 guest-SysV ABI test passed; I did not independently run them. | | Hosted CI | Conventions, eligibility, library portability, intake, labels, and report passed. Windows was in progress; Linux and specialized product jobs were skipped at the final check. | | Integrated precheck | Its detached checkout lacked workspace-only ABI/test-quality helper scripts; I ran both manually against the exact head. | <details><summary>Unedited command output</summary> ```text $ git diff --check 6fe120d11ba3b92c56ade1bb783e211d5dc0949e...a855b5a981057334db4aa0c1d4e3f92457814a89 [no output; exit status 0] $ python3 tools/check_conventions.py --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --title 'feat(libcairo): implement ten Cairo affine matrix exports' --body /tmp/anyps5-pr-precheck-14258-session/pr-body.md All conventions checks passed. $ python3 tools/pr_abi_audit.py --repo /tmp/anyps5-review-14258-exact-20261101 --base 6fe120d11ba3b92c56ade1bb783e211d5dc0949e --head a855b5a981057334db4aa0c1d4e3f92457814a89 --json | python3 -c 'import json,sys; d=json.load(sys.stdin); print("status=%s symbols=%d findings=%d" % (d["status"],len(d["symbols"]),len(d["findings"])))' status=passed symbols=161 findings=0 $ python3 tools/pr_test_quality.py --root /tmp/anyps5-review-14258-exact-20261101 --json core/libs/tests/GuestCairoMatrix.cpp {"findings":[{"path":"core/libs/tests/GuestCairoMatrix.cpp","line":1,"kind":"possible-unregistered-cpp-test","message":"Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage."}],"negative_control_candidates":[],"limits":["Heuristics can miss weak assertions and can flag valid tests; inspect every finding.","A test that passes against base is not by itself proof that the PR test is inadequate.","Negative controls are only candidates until the test actually runs against base and fails by assertion rather than import/setup error."]} $ grep -n 'GuestCairoMatrix' /tmp/anyps5-review-14258-exact-20261101/core/libs/prx/libcairo/CMakeLists.txt 6: add_test_executable(guest_cairo_matrix_tests ${LIBS_INCLUDE_DIR}/tests/GuestCairoMatrix.cpp) $ git merge-tree --write-tree refs/remotes/upstream/main refs/remotes/upstream/pr/14258 f7d262ef212b2932828bc35eb84643b4fc63dbb9 $ gh api repos/boykopovar/AnyPS5/commits/a855b5a981057334db4aa0c1d4e3f92457814a89/check-runs --jq '.check_runs[] | [.name,.status,.conclusion] | @tsv' register-context completed skipped relinker completed skipped relinker-asan completed skipped linux completed skipped write-watch completed skipped windows in_progress labels completed success eligibility completed success library-portability completed success intake completed success conventions completed success report completed success ``` </details> ## Sources - [Matrix implementation and ABI declarations at the reviewed head](https://github.com/boykopovar/AnyPS5/tree/a855b5a981057334db4aa0c1d4e3f92457814a89/core/libs/prx/libcairo) - [Focused matrix tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/a855b5a981057334db4aa0c1d4e3f92457814a89/core/libs/tests/GuestCairoMatrix.cpp) ## Not verified No local build, local CTest, or PS5-console differential test. Windows CI had not completed; Linux and specialized hosted jobs were skipped when checked.
CnRJay commented 2026-11-01 19:49:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:49:36Z.

Review: COMMENTED


Withdrawn. The Unblocks line says Cairo matrix-using guests (not measured), not none. The title-ID requirement is not in CONTRIBUTING.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729922779 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14258#pullrequestreview-5729922779). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:49:36Z. **Review:** COMMENTED --- Withdrawn. The `Unblocks` line says `Cairo matrix-using guests (not measured)`, not `none`. The title-ID requirement is not in CONTRIBUTING.
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!14258
No description provided.