feat(libcairo): implement eight cairo_pattern gradient state exports #15208

Closed
simnJS wants to merge 8 commits from upstream-pr/15208 into main
simnJS commented 2026-11-02 20:42:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by simnJS on 2026-11-02T20:42:26Z.


What

Implements eight cairo_pattern_* state exports in Patterns.cpp: cairo_pattern_create_linear, cairo_pattern_create_radial, cairo_pattern_add_color_stop_rgba, cairo_pattern_reference, cairo_pattern_destroy, cairo_pattern_set_extend, cairo_pattern_set_filter and cairo_pattern_set_matrix. Patterns are refcounted objects holding their color stops, extend, filter and matrix, following the public Cairo pattern documentation.

Rendering is out of scope. cairo_pattern_create_for_surface, cairo_pattern_create_mesh and the mesh functions stay NotImplemented_nid_no_patch; the debt file records it.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: guest_cairo_patterns passes (reference counts, status codes, values read back). Only this test was run, not the full suite. Not run on Linux or on a title.

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:5127112289 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15208). Originally posted by [simnJS](https://github.com/simnJS) on 2026-11-02T20:42:26Z. --- ### What Implements eight `cairo_pattern_*` state exports in `Patterns.cpp`: `cairo_pattern_create_linear`, `cairo_pattern_create_radial`, `cairo_pattern_add_color_stop_rgba`, `cairo_pattern_reference`, `cairo_pattern_destroy`, `cairo_pattern_set_extend`, `cairo_pattern_set_filter` and `cairo_pattern_set_matrix`. Patterns are refcounted objects holding their color stops, extend, filter and matrix, following the public Cairo pattern documentation. Rendering is out of scope. `cairo_pattern_create_for_surface`, `cairo_pattern_create_mesh` and the mesh functions stay `NotImplemented_nid_no_patch`; the debt file records it. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release: `guest_cairo_patterns` passes (reference counts, status codes, values read back). Only this test was run, not the full suite. Not run on Linux or on a title. ### 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: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-22 13:04:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T13:04:01Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: cairo_pattern_set_matrix leaves the pattern matrix changed when the supplied matrix is non-invertible.

What I ran

  • Inspected the prepared diff and changed source files at head 2be61e76e8abafdecb3f38a31331006aa5515987 using repo_read.py reader tools.
  • No build or tests were run. The description reports a Windows 11 / GCC 15.2 run of guest_cairo_patterns; this was not independently verified.

Results

Check Result Note
Diff and source review passed Reviewed the included changed files.
Build and tests not run Only the author's test report was available.

Findings

Blocking

  • core/libs/prx/libcairo/Patterns.cpp:138 stores the requested matrix before checking whether it can be inverted. When inversion fails, Cairo sets the pattern status to an error and retains the prior matrix; here the pattern becomes errored but keeps the invalid matrix. The test at core/libs/tests/GuestCairoPatterns.cpp:533 currently codifies this divergent behavior. Validate/invert first and only assign the new matrix if inversion succeeds.

Non-blocking

None.

Not verified

  • The included changed files were read: core/libs/prx/libcairo/CMakeLists.txt, core/libs/prx/libcairo/Export.cpp, core/libs/prx/libcairo/Patterns.cpp, core/libs/prx/libcairo/include/InventoryExports.hpp, core/libs/prx/libcairo/include/Pattern.hpp, core/libs/tests/GuestCairoPatterns.cpp, and docs/dev/debt/libcairo.md.
  • files.json was not available through the reader, so the complete reviewed set and excluded files could not be confirmed. The only visible manifest marks those seven files as included.
  • No build, tests, Linux run, or console behavior was independently checked. No negative control was run.

To get this to a good state

  • Preserve the previous matrix when inversion fails, and update the test to check that behavior. Re-run guest_cairo_patterns on the new head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012402701 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15208#pullrequestreview-6012402701). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T13:04:01Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: `cairo_pattern_set_matrix` leaves the pattern matrix changed when the supplied matrix is non-invertible. ## What I ran - Inspected the prepared diff and changed source files at head `2be61e76e8abafdecb3f38a31331006aa5515987` using `repo_read.py` reader tools. - No build or tests were run. The description reports a Windows 11 / GCC 15.2 run of `guest_cairo_patterns`; this was not independently verified. ## Results | Check | Result | Note | | --- | --- | --- | | Diff and source review | passed | Reviewed the included changed files. | | Build and tests | not run | Only the author's test report was available. | ## Findings ### Blocking - `core/libs/prx/libcairo/Patterns.cpp:138` stores the requested matrix before checking whether it can be inverted. When inversion fails, Cairo sets the pattern status to an error and retains the prior matrix; here the pattern becomes errored but keeps the invalid matrix. The test at `core/libs/tests/GuestCairoPatterns.cpp:533` currently codifies this divergent behavior. Validate/invert first and only assign the new matrix if inversion succeeds. ### Non-blocking None. ## Not verified - The included changed files were read: `core/libs/prx/libcairo/CMakeLists.txt`, `core/libs/prx/libcairo/Export.cpp`, `core/libs/prx/libcairo/Patterns.cpp`, `core/libs/prx/libcairo/include/InventoryExports.hpp`, `core/libs/prx/libcairo/include/Pattern.hpp`, `core/libs/tests/GuestCairoPatterns.cpp`, and `docs/dev/debt/libcairo.md`. - `files.json` was not available through the reader, so the complete `reviewed` set and excluded files could not be confirmed. The only visible manifest marks those seven files as included. - No build, tests, Linux run, or console behavior was independently checked. No negative control was run. ## To get this to a good state - Preserve the previous matrix when inversion fails, and update the test to check that behavior. Re-run `guest_cairo_patterns` on the new head.

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!15208
No description provided.