feat(libcairo): implement fifteen graphics-state and dash exports #15317
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15317"
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-02T23:44:35Z.
What
Implement 15 Cairo graphics-state and dash exports, owned arrays and save/restore; validate sticky INVALID_DASH, native NaN and contextual nil target. Merge after #15315 and before #15324.
Tested
Windows MinGW C++20 -DNDEBUG DLL-linked context/graphics tests PASS (4,096 dash lifetimes); Ubuntu WSL -DNDEBUG ASan+UBSan/leak check PASS; 1,024 randomized native Cairo1.18 state sequences PASS; headers/progress/conventions PASS. Full integrated CMake/CTest and PS5 console not tested.
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)Detailed implementation and verification notes
Summary
Implement 15 additional, formerly throwing Cairo graphics-state exports for antialias, fill rule, line cap/join, line width, miter limit and dash arrays:
Context state owns and deep-copies dash arrays across nested save/restore, preserves normal getters, clamps negative line width to 0, and rejects invalid dash arrays with sticky error. Matches native Cairo's very short dash-cycle normalization.
Validation
Dependencies and limitations
Stacked: #14327 (surfaces) -> #15315 (context & CTM) -> this PR (graphics state). This PR currently includes the predecessor histories, so land upstream parents first and refresh this PR's base/merge order. #14258 matrix functions already merged. No export claimed by other Cairo contributor's #15208 gradient-pattern PR.
This is a real observable/owned graphics-state implementation, not a claim of rendering: no path, clipping, strokes/fills, rasterizer or PS5 firmware differential. Those remain unimplemented. Does not increase main's scanner count until merged.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T23:58:26Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The reviewed head has three Cairo behavior mismatches and does not retain the repository’s required pull request template.
What I ran
Reviewed all 12 changed files at head
373ab8699984c4d9a76594f7f0ac74de40a1e7a3against base5cb015caaaaf83f8ee431414ee6a457b5b307d49; the exact head merges cleanly into that base. Environment: Debian Linux x86_64, Python 3.11.2, GCC 12.2.0. No build or C++ test binary was run.Results
Check output
The precheck’s isolated snapshot did not contain
pr_abi_audit.pyorpr_test_quality.py; I ran the ABI audit directly in the workspace. Its JSON result wasstatus: passed, with no findings. The stack report said the exact head merged cleanly against the current base. The six hosted checks (labels, intake, conventions, eligibility, report and library-portability) were queued on this head.Negative control
Not run. The new C++ tests require a build, and this review remained in the no-build pass.
Findings
Blocking
cairo_surface_create_similarchanges the requested dimensions. AtSurface.cpplines 270–280, it multiplies width and height by the target scale, then assigns that scale to the result. For example, scale 2 and requested dimensions 10×5 produce a 20×10 backing image, although Cairo specifies these arguments in device-space units and passes them unchanged to its similar-surface backend. Pass the requested dimensions unchanged; handle any scale metadata separately.Rectangle surfaces report the image type.
cairo_surface_create_for_rectanglemarks the surface as non-image, butcairo_surface_get_typealways returns the image enum. Cairo definesCAIRO_SURFACE_TYPE_SUBSURFACEfor surfaces created by this API. Store and return the subsurface type for these surfaces.cairo_get_targetreturns a normal or wrong-status surface after context failure. Aftercairo_restoresetskInvalidRestore,cairo_get_targetstill returns the original target. Also, the static null-pointer context is initialized with akNoMemorytarget. Cairo requires an error (“nil”) surface carrying the context’s status whenever the context is in an error state. Return an error surface matching the context status and make the null-pointer context’s target statuskNullPointer.The PR description omits required template fields. The repository checker reports missing
### What,### Testedand### Checklist; the description also omits the required checklist entries, includingDepends on,Unblocks,GPUs testedandAI-assisted. Restore the full template and fill every item.Non-blocking
Sources
cairo_get_targetbehavior.Not verified
I did not build or run the C++ tests, run the negative control, or verify behavior on Windows, PS5 firmware or a console. The author-reported MinGW, sanitizer and Cairo differential runs were not independently reproduced. Hosted checks were still queued at the final refresh.
To get this to a good state
Correct the three surface/context behaviors, restore and complete the PR template, and add an observable invalid-dash assertion. On the new head I will rerun the diff check, precheck, ABI audit, stack check and applicable hosted checks, then review the updated diff and tests.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-03T01:37:08Z.
Review: CHANGES_REQUESTED
Re-checked — new head, changes requested
The new head fixes the earlier surface findings, but it still returns the wrong error status for error targets, mishandles zero-containing dash patterns, and adds a code comment forbidden by the repository rules.
What I ran
c91c64ec211aee03dfa5cd34df846d08398edf8eagainst PR base5cb015caaaaf83f8ee431414ee6a457b5b307d49; the exact head had a clean individual merge preview against currentmain7feb37ee3e30e10139b483fb4df689d5b5b69ab8.3909090108bb2db55330e3eb148aebe664735363.Results
main; transitive stack ancestry is incomplete.Precheck report table (unedited)
The precheck deliberately does not configure, build, or compile AnyPS5.git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...c91c64ec211aee03dfa5cd34df846d08398edf8e/usr/bin/python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49 --head c91c64ec211aee03dfa5cd34df846d08398edf8e --title feat(libcairo): implement fifteen graphics-state and dash exports --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15317-c91c64ec211a/pr-body.md/usr/bin/python3 tools/pr_abi_audit.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49 --head c91c64ec211aee03dfa5cd34df846d08398edf8e --jsonNo changed Python implementation files.No changed tools/ module has an existing sibling tools/tests/test_<module>.py suite.No changed test_*.py files./usr/bin/python3 /marc/AnyPS5/tools/pr_stack_check.py 15317 --repo boykopovar/AnyPS5 --output-dir /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15317-c91c64ec211a/stackNot run: C++ tests need exact-head binaries, which require a build; the precheck does not build./usr/bin/python3 /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15317-c91c64ec211a/head-c91c64ec211a-13d645a7/tools/pr_test_quality.py --root /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-15317-c91c64ec211a/head-c91c64ec211a-13d645a7 --json core/libs/prx/libcairo/CMakeLists.txt core/libs/prx/libcairo/Context.cpp core/libs/prx/libcairo/Export.cpp core/libs/prx/libcairo/Surface.cpp core/libs/prx/libcairo/include/Context.hpp core/libs/prx/libcairo/include/InventoryExports.hpp core/libs/prx/libcairo/include/Surface.hpp core/libs/prx/libcairo/libcairo.hpp core/libs/tests/GuestCairoContext.cpp core/libs/tests/GuestCairoGraphicsState.cpp core/libs/tests/GuestCairoSurface.cpp docs/dev/debt/libcairo.mdNo changed Python test module in tools/ can be run as a no-build base-source control.Raw outputs (unedited)
Precheck command:
Conventions stdout:
Missing helper stderr:
Direct ABI summary:
Direct test-quality output:
Negative control
1for null and invalid-dash errors.{5, 0, 2}test expects three dashes.Findings
Blocking
cairo_create(nullptr)stores aNO_MEMORYtarget for a context whose status isNULL_POINTER. After a valid context enters an error state,cairo_get_targetalso returnsNO_MEMORYfor every error. Cairo constructs the target error surface from the context’s actual status; the current tests instead assert1for both null-pointer and invalid-dash errors. Preserve the originating status in both paths and assert7for the null-pointer case and19for invalid dash.1/256. In Cairo 1.18.0,[5, 0, 2]normalizes to a solid line (dash count0), while this PR’s test explicitly expects dash count3;[10, 0]is also degenerate solid. Normalize zero gaps and determine degeneracy from the off portions, then update tests to match the pinned implementation behavior.Surface.hppadds a code comment, contrary toAGENTS.md’s “No comments in code” rule. Remove the comment.Non-blocking
main; confirm the intended landing ancestry when updating the dependency stack.Sources
Not verified
To get this to a good state
Preserve each context error status in its target surface, normalize zero-containing/degenerate dash arrays to Cairo 1.18 behavior and correct the associated test expectations, and remove the code comment. Verify the dependency ancestry when the predecessor stack changes. I’ll rerun the same no-build checks and review the full diff on the new head.