feat(libSceNKWebKit): implement WebCore::AffineTransform::mapRegion #18538

Merged
adriaespii merged 3 commits from upstream-pr/18538 into main 2026-11-13 07:22:52 +00:00
adriaespii commented 2026-11-11 20:44:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriaespii on 2026-11-11T20:44:25Z.


What

  • Implements WebCore::AffineTransform::mapRegion in Region.cpp and declares it in RegionExports.hpp, following the pinned PS5-WebKit-11.x AffineTransform.cpp (L473-L485) and IntSize.h (roundedIntSize).
  • Translates a copied Region with rounded float-narrowed offset on identity or pure translation transforms, and unites mapRect results across Region::rects() on general affine transforms; throws std::invalid_argument on a null AffineTransform pointer.
  • Adds test coverage in core/libs/prx/libSceNKWebKit/tests/RegionGeometry.cpp and updates docs/dev/debt/libSceNKWebKit.md (5997 -> 5996).

Tested

  • python tools/check_conventions.py --base origin/main -> All conventions checks passed.
  • cmake --build build --target libSceNKWebKit nkwebkit_regiongeometry_tests nkwebkit_base_tests -j 8
  • ctest --test-dir build -R "(nkwebkit|public_headers|unbuilt_exports)" --output-on-failure -> 128/128 passed (100% tests passed, 0 tests failed out of 128, including nkwebkit_regiongeometry, unbuilt_exports, public_headers, and all public_headers_compile_* targets).

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:5266519763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18538). Originally posted by [adriaespii](https://github.com/adriaespii) on 2026-11-11T20:44:25Z. --- ### What - Implements `WebCore::AffineTransform::mapRegion` in [Region.cpp](https://github.com/adriaespii/AnyPS5/blob/feat/nkwebkit-affine-map-region/core/libs/prx/libSceNKWebKit/src/Region.cpp) and declares it in [RegionExports.hpp](https://github.com/adriaespii/AnyPS5/blob/feat/nkwebkit-affine-map-region/core/libs/prx/libSceNKWebKit/include/RegionExports.hpp), following the pinned `PS5-WebKit-11.x` `AffineTransform.cpp` (`L473-L485`) and `IntSize.h` (`roundedIntSize`). - Translates a copied `Region` with rounded float-narrowed offset on identity or pure translation transforms, and unites `mapRect` results across `Region::rects()` on general affine transforms; throws `std::invalid_argument` on a null `AffineTransform` pointer. - Adds test coverage in `core/libs/prx/libSceNKWebKit/tests/RegionGeometry.cpp` and updates `docs/dev/debt/libSceNKWebKit.md` (`5997 -> 5996`). ### Tested - `python tools/check_conventions.py --base origin/main` -> `All conventions checks passed.` - `cmake --build build --target libSceNKWebKit nkwebkit_regiongeometry_tests nkwebkit_base_tests -j 8` - `ctest --test-dir build -R "(nkwebkit|public_headers|unbuilt_exports)" --output-on-failure` -> `128/128` passed (`100% tests passed, 0 tests failed out of 128`, including `nkwebkit_regiongeometry`, `unbuilt_exports`, `public_headers`, and all `public_headers_compile_*` targets). ### 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](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
PrivacyOnion commented 2026-11-12 06:09:41 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T06:09:41Z.

Review: APPROVED


Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against b7fb8e29f6:

  • Conventions: tools/check_conventions.py passed; git diff --check clean.
  • Build: nkwebkit_regiongeometry_tests built cleanly.
  • CTest (nkwebkit_regiongeometry):
    1/1 Test #3708: nkwebkit_regiongeometry ..........   Passed    0.03 sec
    100% tests passed, 0 tests failed out of 1
    
  • Negative control: with core/libs/prx/libSceNKWebKit/Export.cpp, core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp, core/libs/prx/libSceNKWebKit/include/RegionExports.hpp, core/libs/prx/libSceNKWebKit/src/Region.cpp reverted to main, the new tests do not build/link without the change; restoring it makes them build and pass.
  • Code reading:
    • Verified in core/libs/prx/libSceNKWebKit/src/Region.cpp that WebCore::AffineTransform::mapRegion validates self for nullptr and throws std::invalid_argument before accessing transform state, matching the documented libSceNKWebKit contract in docs/dev/debt/libSceNKWebKit.md.
    • Verified the identity and pure translation fast-path in Region.cpp accurately tests m_transform[0] == 1.0, m_transform[1] == 0.0, m_transform[2] == 0.0, and m_transform[3] == 1.0 matching WebKit's AffineTransform::isIdentityOrTranslation().
    • Verified the clampToInt lambda and std::roundf logic in Region.cpp correctly guard against int32 overflow and undefined behavior when casting float translation offsets against std::numeric_limits::max() and min().
    • Verified general affine transforms in Region.cpp accurately decompose regions via _ZNK7WebCore6Region5rectsEv, transform individual rects with _ZNK7WebCore15AffineTransform7mapRectERKNS_7IntRectE, and assemble the resulting shape via ZN7WebCore6Region5uniteERKS0.
    • Verified strict AGENTS.md compliance: zero comments in code, no hardcoded game-specific cases, properly moved declaration to RegionExports.hpp, removed stubs from Export.cpp and InventoryExports.hpp, and accurately updated docs/dev/debt/libSceNKWebKit.md with inventory count decrement from 5995 to 5994.
    • Verified test coverage in core/libs/prx/libSceNKWebKit/tests/RegionGeometry.cpp thoroughly validates identity/empty mappings, multi-rect translations, non-uniform scaling, zero-scale collapse, null-pointer exception throwing, and ensures proper fixture destruction.
  • Note: the AI-assisted checkbox can stay.

Looks Good To Me

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5869897375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/18538#pullrequestreview-5869897375). Originally posted by [PrivacyOnion](https://github.com/PrivacyOnion) on 2026-11-12T06:09:41Z. **Review:** APPROVED --- Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against `b7fb8e29f6`: - **Conventions**: `tools/check_conventions.py` passed; `git diff --check` clean. - **Build**: `nkwebkit_regiongeometry_tests` built cleanly. - **CTest** (`nkwebkit_regiongeometry`): ``` 1/1 Test #3708: nkwebkit_regiongeometry .......... Passed 0.03 sec 100% tests passed, 0 tests failed out of 1 ``` - **Negative control**: with `core/libs/prx/libSceNKWebKit/Export.cpp`, `core/libs/prx/libSceNKWebKit/include/InventoryExports.hpp`, `core/libs/prx/libSceNKWebKit/include/RegionExports.hpp`, `core/libs/prx/libSceNKWebKit/src/Region.cpp` reverted to `main`, the new tests do not build/link without the change; restoring it makes them build and pass. - **Code reading**: - Verified in core/libs/prx/libSceNKWebKit/src/Region.cpp that WebCore::AffineTransform::mapRegion validates self for nullptr and throws std::invalid_argument before accessing transform state, matching the documented libSceNKWebKit contract in docs/dev/debt/libSceNKWebKit.md. - Verified the identity and pure translation fast-path in Region.cpp accurately tests m_transform[0] == 1.0, m_transform[1] == 0.0, m_transform[2] == 0.0, and m_transform[3] == 1.0 matching WebKit's AffineTransform::isIdentityOrTranslation(). - Verified the clampToInt lambda and std::roundf logic in Region.cpp correctly guard against int32 overflow and undefined behavior when casting float translation offsets against std::numeric_limits<int>::max() and min(). - Verified general affine transforms in Region.cpp accurately decompose regions via _ZNK7WebCore6Region5rectsEv, transform individual rects with _ZNK7WebCore15AffineTransform7mapRectERKNS_7IntRectE, and assemble the resulting shape via _ZN7WebCore6Region5uniteERKS0_. - Verified strict AGENTS.md compliance: zero comments in code, no hardcoded game-specific cases, properly moved declaration to RegionExports.hpp, removed stubs from Export.cpp and InventoryExports.hpp, and accurately updated docs/dev/debt/libSceNKWebKit.md with inventory count decrement from 5995 to 5994. - Verified test coverage in core/libs/prx/libSceNKWebKit/tests/RegionGeometry.cpp thoroughly validates identity/empty mappings, multi-rect translations, non-uniform scaling, zero-scale collapse, null-pointer exception throwing, and ensures proper fixture destruction. - Note: the AI-assisted checkbox can stay. Looks Good To Me
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!18538
No description provided.