feat(libcairo): implement surface user-data ownership #16315

Merged
ahmadmuj merged 2 commits from upstream-pr/16315 into main 2026-11-09 01:36:01 +00:00
ahmadmuj commented 2026-11-06 07:18:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-11-06T07:18:24Z.


What

Implement cairo_surface_set_user_data so callers can attach cleanup to borrowed image buffers. Callbacks run after the final surface reference, including references held by subsurfaces.

The behavior follows Cairo 1.18.0 src/cairo-surface.c:956-999,1161-1174 and src/cairo-array.c:384-400,453-499. Callback types follow src/cairo.h:232-257; parent release order follows src/cairo-surface-subsurface.c:48-57. Official source, SHA-256 243a0736b978a33dee29f9cca7521733b78a65b5418206fef7bd1c3d4cf10b64.

Tested

Linux x86-64, Ubuntu 24.04 on WSL2, GCC 13.3. The new regression reaches main's real throwing stub, then passes with this change. Native Cairo 1.18.0 matches the shared callback, status, and allocation-failure scenarios. ASan/UBSan with leak detection pass. The full project build and all four Cairo CTest tests pass. Conventions passes on the actual commit.

The overlap tool exits 2 for shared files and stale branches. Manual comparison of exact heads for #14329, #15208, #15315, #15317, #15324, #15430, #15675, #15679, #15681, and #15685 finds distinct functions, exports, and tests. Shared debt counts and adjacent stubs can need later reconciliation.

Cases include key identity, replacement/removal, same-pointer replacement, null keys/callbacks, vacant slots, reverse destruction, borrowed pixels, extra references, subsurfaces, empty images, stored errors, teardown reentry, and first/growth allocation failures.

No Windows callback run, console measurement, or game-dump test. The console library revision remains unverified.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5184376563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16315). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-11-06T07:18:24Z. --- ### What Implement `cairo_surface_set_user_data` so callers can attach cleanup to borrowed image buffers. Callbacks run after the final surface reference, including references held by subsurfaces. The behavior follows Cairo 1.18.0 `src/cairo-surface.c:956-999,1161-1174` and `src/cairo-array.c:384-400,453-499`. Callback types follow `src/cairo.h:232-257`; parent release order follows `src/cairo-surface-subsurface.c:48-57`. [Official source](https://cairographics.org/releases/cairo-1.18.0.tar.xz), SHA-256 `243a0736b978a33dee29f9cca7521733b78a65b5418206fef7bd1c3d4cf10b64`. ### Tested Linux x86-64, Ubuntu 24.04 on WSL2, GCC 13.3. The new regression reaches main's real throwing stub, then passes with this change. Native Cairo 1.18.0 matches the shared callback, status, and allocation-failure scenarios. ASan/UBSan with leak detection pass. The full project build and all four Cairo CTest tests pass. Conventions passes on the actual commit. The overlap tool exits 2 for shared files and stale branches. Manual comparison of exact heads for #14329, #15208, #15315, #15317, #15324, #15430, #15675, #15679, #15681, and #15685 finds distinct functions, exports, and tests. Shared debt counts and adjacent stubs can need later reconciliation. Cases include key identity, replacement/removal, same-pointer replacement, null keys/callbacks, vacant slots, reverse destruction, borrowed pixels, extra references, subsurfaces, empty images, stored errors, teardown reentry, and first/growth allocation failures. No Windows callback run, console measurement, or game-dump test. The console library revision remains unverified. <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> ### 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes
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!16315
No description provided.