feat(libSceNKWebKit): implement WebCore filter operations #16510

Closed
gslashm wants to merge 1 commit from upstream-pr/16510 into main
gslashm commented 2026-11-06 23:28:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gslashm on 2026-11-06T23:28:45Z.


What

Implements 40 libSceNKWebKit exports from Source/WebCore/platform/graphics/filters/FilterOperation.cpp:46-550, the inline parts of FilterOperation.h:66-377, the Length move and equality rules at Source/WebCore/platform/Length.h:232-315 and the FilterOperations printer in FilterOperations.cpp:220-232 at 80f77e94c6:

  • BlurFilterOperation: create, both constructors, D0, D1, D2, clone, operator==, stdDeviation
  • DropShadowFilterOperation: create, both constructors, D0, D1, D2, clone, operator==, x, y, location, stdDeviation, color
  • InvertLightnessFilterOperation: create, both constructors, clone, operator==
  • DefaultFilterOperation: representedType, clone, operator==
  • BasicColorMatrixFilterOperation: clone, operator==, amount, passthroughAmount
  • BasicComponentTransferFilterOperation: clone, operator==, amount, passthroughAmount, affectsOpacity
  • operator<<(WTF::TextStream&, const FilterOperations&)

The 41st export, operator<<(WTF::TextStream&, const FilterOperation&), is implemented for 14 of the 15 types, but its drop-shadow case needs operator<<(WTF::TextStream&, const IntPoint&) (held by open #15517) and operator<<(WTF::TextStream&, const Color&) (still a stub), so it calls NotImplemented_nid_no_patch there and remains a pending export.

src/FilterOperation.cpp carries three notices, each with its own Derived from line: FilterOperation.cpp and FilterOperation.h (BSD) and Length.h (LGPL-2+), because CopyLength and LengthsEqual are ports of Length::initialize(Length&&) and Length::operator==. src/FilterOperations.cpp carries the FilterOperations.cpp notice.

The objects are polymorphic, and the inventory exports no _ZTV symbol, so a guest cannot build one inline: every object comes from this library, which installs host vtables laid out from the pinned header in the ValueVtableStorage form of src/WtfJson.cpp (offset-to-top 0, null typeinfo, 12 slots). create and clone return Ref<FilterOperation> through the hidden sret pointer and blend returns RefPtr<FilterOperation> the same way; Length is passed to create and to the constructors by invisible reference; location() returns IntPoint (8 bytes) in rax; outsets() returns IntOutsets (four ints) in rax:rdx.

Behaviour that differs from upstream, all in the debt file:

  • A calculated Length throws, because ~Length would call the unimplemented Length::deref.
  • An out-of-line Color throws, through the existing Color copy constructor.
  • The unexported blend overrides of the four amount classes, their transformColor, InvertLightnessFilterOperation's transformColor and inverseTransformColor, BlurFilterOperation::isIdentity, and the blur and drop-shadow outsets throw through NotImplemented_nid_no_patch: they need Length blending, the color matrices, ColorBlending and FEGaussianBlur/FEDropShadow.
  • Printing a drop-shadow operation calls NotImplemented_nid_no_patch before writing anything, for the missing printers above.
  • Printing goes through main's TextStream exports, so it inherits #14172's 40-byte WTF::StringBuilder rather than the 24-byte one at the pin. This PR does not settle that.
  • A null self, other, stream or argument pointer throws std::invalid_argument.

D0, D1 and D2 of DefaultFilterOperation, InvertLightnessFilterOperation, BasicColorMatrixFilterOperation and BasicComponentTransferFilterOperation already existed (#13947's jmp fastFree for D0, #13930's empty D1/D2), so their vtable slots reproduce the same behaviour. D0 of BlurFilterOperation and DropShadowFilterOperation is new; their D1/D2 do nothing, because a non-calculated Length and an inline Color need no destruction.

Not compared with a console module.

tools/pr_overlap.py lists #13486 under the same exports. It is a relinker draft whose merge base 87755c8519 (head 0bde10d243, 2026-10-30) predates the 8703 stubs, so its diff re-adds them, including these 41, all still throwing NotImplemented_nid_no_patch; it implements none of them. The scan ran at 2026-11-06 23:15 UTC against 1840 open PRs: no open PR adds the same files. #16509, opened five minutes before this PR, implements 7 of the 41 getters; it is listed under Depends on, and the 80 PRs the tool could not merge with main were compared separately and hold none of the 41 names. One of them, #15011, merged while this PR was open; it holds none of these names, and rebasing onto it conflicted only on the debt count line. Line conflicts are the Filter operations entry this replaces (docs/dev/debt/libSceNKWebKit.md:50), the debt count line (:66), the include in libSceNKWebKit.hpp:22, and the deleted stub ranges in Export.cpp and include/InventoryExports.hpp. Whichever merges later keeps both sides.

Update (2026-11-08): rebased onto main 80057dddd2. #16509 implements the 7 filter-operation getters above as measured field reads. This branch keeps its implementations until #16509 merges, then drops those 7 and rebases.

Tested

Windows 11 Pro, WinLibs GCC 15.2.0. No title and no console module. nkwebkit_filteroperation checks the member offsets and vtable slots, construction and the Length move, calculated-Length and out-of-line-Color rejection, clone reference counts, every equality rule including NaN and Length quirks, both passthroughAmount tables and affectsOpacity, the isIdentity slots, the constant slots against ConstantExports.cpp, the blend and throwing slots, D0 of all six classes, printing of every type and of a FilterOperations list (including a list holding a drop-shadow, which throws after writing the earlier entries), and a null-pointer throw for every pointer argument of the exports that take one, first and later alike. ctest -R nkwebkit: 31 of 31 pass. ctest -R public_headers: 65 of 65 pass. tools/progress.py --module libSceNKWebKit: 1964 of 10982, 40 more than main's 1924. Whole suite not run.

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: #16509
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5196207634 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16510). Originally posted by [gslashm](https://github.com/gslashm) on 2026-11-06T23:28:45Z. --- ### What Implements 40 `libSceNKWebKit` exports from `Source/WebCore/platform/graphics/filters/FilterOperation.cpp:46-550`, the inline parts of `FilterOperation.h:66-377`, the `Length` move and equality rules at `Source/WebCore/platform/Length.h:232-315` and the `FilterOperations` printer in `FilterOperations.cpp:220-232` at `80f77e94c6`: - `BlurFilterOperation`: `create`, both constructors, `D0`, `D1`, `D2`, `clone`, `operator==`, `stdDeviation` - `DropShadowFilterOperation`: `create`, both constructors, `D0`, `D1`, `D2`, `clone`, `operator==`, `x`, `y`, `location`, `stdDeviation`, `color` - `InvertLightnessFilterOperation`: `create`, both constructors, `clone`, `operator==` - `DefaultFilterOperation`: `representedType`, `clone`, `operator==` - `BasicColorMatrixFilterOperation`: `clone`, `operator==`, `amount`, `passthroughAmount` - `BasicComponentTransferFilterOperation`: `clone`, `operator==`, `amount`, `passthroughAmount`, `affectsOpacity` - `operator<<(WTF::TextStream&, const FilterOperations&)` The 41st export, `operator<<(WTF::TextStream&, const FilterOperation&)`, is implemented for 14 of the 15 types, but its drop-shadow case needs `operator<<(WTF::TextStream&, const IntPoint&)` (held by open #15517) and `operator<<(WTF::TextStream&, const Color&)` (still a stub), so it calls `NotImplemented_nid_no_patch` there and remains a pending export. `src/FilterOperation.cpp` carries three notices, each with its own `Derived from` line: `FilterOperation.cpp` and `FilterOperation.h` (BSD) and `Length.h` (LGPL-2+), because `CopyLength` and `LengthsEqual` are ports of `Length::initialize(Length&&)` and `Length::operator==`. `src/FilterOperations.cpp` carries the `FilterOperations.cpp` notice. The objects are polymorphic, and the inventory exports no `_ZTV` symbol, so a guest cannot build one inline: every object comes from this library, which installs host vtables laid out from the pinned header in the `ValueVtableStorage` form of `src/WtfJson.cpp` (offset-to-top 0, null typeinfo, 12 slots). `create` and `clone` return `Ref<FilterOperation>` through the hidden sret pointer and `blend` returns `RefPtr<FilterOperation>` the same way; `Length` is passed to `create` and to the constructors by invisible reference; `location()` returns `IntPoint` (8 bytes) in `rax`; `outsets()` returns `IntOutsets` (four `int`s) in `rax:rdx`. Behaviour that differs from upstream, all in the debt file: - A calculated `Length` throws, because `~Length` would call the unimplemented `Length::deref`. - An out-of-line `Color` throws, through the existing `Color` copy constructor. - The unexported `blend` overrides of the four amount classes, their `transformColor`, `InvertLightnessFilterOperation`'s `transformColor` and `inverseTransformColor`, `BlurFilterOperation::isIdentity`, and the blur and drop-shadow `outsets` throw through `NotImplemented_nid_no_patch`: they need `Length` blending, the color matrices, `ColorBlending` and `FEGaussianBlur`/`FEDropShadow`. - Printing a drop-shadow operation calls `NotImplemented_nid_no_patch` before writing anything, for the missing printers above. - Printing goes through `main`'s `TextStream` exports, so it inherits #14172's 40-byte `WTF::StringBuilder` rather than the 24-byte one at the pin. This PR does not settle that. - A null `self`, `other`, `stream` or argument pointer throws `std::invalid_argument`. `D0`, `D1` and `D2` of `DefaultFilterOperation`, `InvertLightnessFilterOperation`, `BasicColorMatrixFilterOperation` and `BasicComponentTransferFilterOperation` already existed (#13947's `jmp fastFree` for `D0`, #13930's empty `D1`/`D2`), so their vtable slots reproduce the same behaviour. `D0` of `BlurFilterOperation` and `DropShadowFilterOperation` is new; their `D1`/`D2` do nothing, because a non-calculated `Length` and an inline `Color` need no destruction. Not compared with a console module. `tools/pr_overlap.py` lists #13486 under the same exports. It is a relinker draft whose merge base `87755c8519` (head `0bde10d243`, 2026-10-30) predates the 8703 stubs, so its diff re-adds them, including these 41, all still throwing `NotImplemented_nid_no_patch`; it implements none of them. The scan ran at 2026-11-06 23:15 UTC against 1840 open PRs: no open PR adds the same files. #16509, opened five minutes before this PR, implements 7 of the 41 getters; it is listed under `Depends on`, and the 80 PRs the tool could not merge with `main` were compared separately and hold none of the 41 names. One of them, #15011, merged while this PR was open; it holds none of these names, and rebasing onto it conflicted only on the debt count line. Line conflicts are the `Filter operations` entry this replaces (`docs/dev/debt/libSceNKWebKit.md:50`), the debt count line (`:66`), the include in `libSceNKWebKit.hpp:22`, and the deleted stub ranges in `Export.cpp` and `include/InventoryExports.hpp`. Whichever merges later keeps both sides. **Update (2026-11-08):** rebased onto `main` `80057dddd2`. #16509 implements the 7 filter-operation getters above as measured field reads. This branch keeps its implementations until #16509 merges, then drops those 7 and rebases. ### Tested <!-- 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. --> Windows 11 Pro, WinLibs GCC 15.2.0. No title and no console module. `nkwebkit_filteroperation` checks the member offsets and vtable slots, construction and the `Length` move, calculated-`Length` and out-of-line-`Color` rejection, `clone` reference counts, every equality rule including NaN and `Length` quirks, both `passthroughAmount` tables and `affectsOpacity`, the `isIdentity` slots, the constant slots against `ConstantExports.cpp`, the `blend` and throwing slots, `D0` of all six classes, printing of every type and of a `FilterOperations` list (including a list holding a drop-shadow, which throws after writing the earlier entries), and a null-pointer throw for every pointer argument of the exports that take one, first and later alike. `ctest -R nkwebkit`: 31 of 31 pass. `ctest -R public_headers`: 65 of 65 pass. `tools/progress.py --module libSceNKWebKit`: 1964 of 10982, 40 more than `main`'s 1924. Whole suite not run. ### 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: #16509 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-11-20 10:57:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T10:57:17Z.

Review: CHANGES_REQUESTED


Reviewed — comments

Changes are required before merge: correct the new vtable’s behavior for default filter operations before relying on objects created by this library.

What I ran

Reviewed head a82f458a8eefd0ae68ccc66a64e8d0508aae25a6. No commands or tests were run; I inspected the prepared diff and used the pinned repository reader for targeted source ranges.

Results

Check Result Note
Prepared diff review passed Changed code inspected
Tests not run No test command run
Console comparison not run Description reports none

Findings

Blocking

  • core/libs/prx/libSceNKWebKit/src/FilterOperation.cpp:198: the DefaultFilterOperation vtable’s isIdentity slot always returns false. A default operation represents a filter type with no explicit operation; the pinned WebKit behavior treats it as an identity operation. Consumers dispatching this slot will therefore treat an identity filter as active. Implement the type-specific identity result (or use the pinned implementation) instead of returning a constant.

Non-blocking

  • core/libs/prx/libSceNKWebKit/src/FilterOperation.cpp:754: the invert-lightness blend override ignores its blending context and returns a newly created operation whenever the source type matches. The PR description acknowledges that this path differs from upstream and does not list it among the throwing debt paths; consider matching the pinned blend semantics or explicitly making this path throw until implemented.

Not verified

No tests or build checks were run, and no console module comparison was made. The review bundle excluded the full text of Export.cpp and include/InventoryExports.hpp because they were too large; I inspected their relevant changes in diff.patch. The test file and other changed files were not read in full. The reviewed manifest lists 10 changed files; targeted reads covered the filter implementation, ABI header, and relevant diff hunks.

To get this to a good state

Fix the DefaultFilterOperation identity slot, then run the targeted nkwebkit_filteroperation checks and confirm the result against the pinned behavior.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5991550166 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16510#pullrequestreview-5991550166). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-20T10:57:17Z. **Review:** CHANGES_REQUESTED --- # Reviewed — comments Changes are required before merge: correct the new vtable’s behavior for default filter operations before relying on objects created by this library. ## What I ran Reviewed head `a82f458a8eefd0ae68ccc66a64e8d0508aae25a6`. No commands or tests were run; I inspected the prepared diff and used the pinned repository reader for targeted source ranges. ## Results | Check | Result | Note | |---|---|---| | Prepared diff review | passed | Changed code inspected | | Tests | not run | No test command run | | Console comparison | not run | Description reports none | ## Findings ### Blocking - `core/libs/prx/libSceNKWebKit/src/FilterOperation.cpp:198`: the `DefaultFilterOperation` vtable’s `isIdentity` slot always returns `false`. A default operation represents a filter type with no explicit operation; the pinned WebKit behavior treats it as an identity operation. Consumers dispatching this slot will therefore treat an identity filter as active. Implement the type-specific identity result (or use the pinned implementation) instead of returning a constant. ### Non-blocking - `core/libs/prx/libSceNKWebKit/src/FilterOperation.cpp:754`: the invert-lightness blend override ignores its blending context and returns a newly created operation whenever the source type matches. The PR description acknowledges that this path differs from upstream and does not list it among the throwing debt paths; consider matching the pinned blend semantics or explicitly making this path throw until implemented. ## Not verified No tests or build checks were run, and no console module comparison was made. The review bundle excluded the full text of `Export.cpp` and `include/InventoryExports.hpp` because they were too large; I inspected their relevant changes in `diff.patch`. The test file and other changed files were not read in full. The reviewed manifest lists 10 changed files; targeted reads covered the filter implementation, ABI header, and relevant diff hunks. ## To get this to a good state Fix the `DefaultFilterOperation` identity slot, then run the targeted `nkwebkit_filteroperation` checks and confirm the result against the pinned behavior.

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