Skip to content

Fork RGBMatrix into HUEMatrix and restore RGBMatrix to upstream - #5

Merged
abossard merged 3 commits into
mcp-serverfrom
abossard-fork-huematrix-from-rgbmatrix
Aug 10, 2026
Merged

Fork RGBMatrix into HUEMatrix and restore RGBMatrix to upstream#5
abossard merged 3 commits into
mcp-serverfrom
abossard-fork-huematrix-from-rgbmatrix

Conversation

@abossard

Copy link
Copy Markdown
Owner

Description

Summary of Changes:

This fork had diverged RGBMatrix heavily (+1185 lines in rgbmatrix.cpp, +478 in rgbscriptv4.cpp, 39 stock scripts rewritten, RGBAudio deleted), which made every upstream merge painful and meant fork-only behavior could not be turned off. This PR splits that divergence in two: RGBMatrix goes back to pristine upstream, and all fork behavior moves to a new HUEMatrix function type that inherits from it. Users pick between them side by side.

The split is cheap because of one non-obvious property: the fork's HSV contract lives entirely inside RGBScript. RGBMap was always packed RGB (hsvToRgb() packs before the map leaves the script class), so rgbmatrix.cpp never referenced hue at all. That let the divergence be cut at the algorithm boundary rather than threaded through the matrix.

Approach:

  • engine/src/rgbmatrix.cpp, rgbalgorithm.cpp, rgbscriptv4.cpp, rgbaudio.{h,cpp} and the 39 stock scripts are restored byte-identical to upstream/master. git diff upstream/master on those paths returns 0 lines. This also integrates upstream e671868c6 (script parameters as attributes), which the fork had never picked up.
  • Headers differ only by access-widening tokens: virtual, removal of final, two additive ControlMode enumerators, and friend class HUEMatrix; / friend class HUEScript;. friend was chosen over widening members to protected: because it is strictly narrower.
  • HUEMatrix : public RGBMatrix and HUEScript : public RGBScript carry rotation, mirror + blend, beat transforms, brightness, RGBW control modes, the pixel plan, and async precompute.
  • The 41 HSV audio scripts plus hsvutil.js moved to resources/huescripts/ via pure renames (all R100, zero content edits) behind a separate cache. RGBMatrix sees only upstream stock scripts; HUEMatrix sees both, since HUEScript supports the HSV Float32Array contract and the upstream packed-uint contract.

Related Issues:

N/A

Checklist

  • I have read and followed the QLC+ Coding Guidelines.
  • My code adheres to the project's coding style, including:
    • Placing opening braces { on a new line for functions and class definitions.
    • Consistent use of spaces and indentation.
  • I have tested my changes on the following platforms:
    • Linux
    • Windows
    • macOS
  • I have added or updated documentation as necessary.

Note: verified on macOS only. Not built or run on Linux or Windows.

Testing

Test Cases:

  • huematrix_test (42 cases, new): HSV Float32Array contract across all 41 audio scripts, the upstream packed-uint contract on the same class, algorithm-list separation in both directions, fork properties in memory and through XML round-trip, enumerated icon sites, built-in reachability, bounded destructor drain, async precompute generation checks, per-tick recompute for audio algorithms, and the unavailable-algorithm and AudioProfileID load warnings.
  • rgbmatrix_test (9) and rgbscript_test (14): upstream's own suites, unmodified. These are the real proof of the restore.
  • mcp_rgb_transform_test (15): re-pointed at HUEMatrix, keeping spatial coverage of rotation/mirror/beat rather than degrading to property get/set.

Test Results:

Full sweep of every project test binary, each run from its own directory since resource paths are cwd-relative:

SUITES: pass=92 fail=1 no-totals=0
FAIL  plugins/velleman/test/velleman_test :: Totals: 4 passed, 2 failed

The single failure is pre-existing and unrelated: git diff upstream/master -- plugins/velleman/ is empty and nothing in this branch touches that plugin.

Key results:

huematrix_test          Totals: 42 passed, 0 failed     (10 consecutive runs, 0 variance)
rgbmatrix_test          Totals:  9 passed, 0 failed
rgbscript_test          Totals: 14 passed, 0 failed
function_test           Totals: 36 passed, 0 failed
mcp_rgb_transform_test  Totals: 15 passed, 0 failed

git diff upstream/master -- <6 restored paths> | wc -l   =>  0
full build with -Werror -Wextra -Wall                    =>  0 errors, 0 warnings

Additional Notes

Please review these areas carefully:

Breaking change for existing workspaces. Because the audio scripts moved directories, pre-existing RGBMatrix functions that referenced them no longer resolve: 56 functions across three real workspaces. A warning naming both the script and the function now fires on load. Separately, the fork-only <AudioProfileID> tag is dropped by restored-upstream loadXML (5 functions), with upstream's Unknown RGB matrix tag warning. This is intentional; there is no automatic migration. Affected effects should be recreated as HUEMatrix functions. Both cases are documented in README Known Issues and MANUAL_REVIEW section 23.4.

Deliberate duplication. HUEMatrix::write() fully overrides without calling the base, duplicating roughly 200 lines. The alternative was extracting virtual seams into upstream's write(), which was rejected: it would permanently diverge the method upstream touches most. Keeping rgbmatrix.cpp byte-identical was judged worth the duplication.

Known coverage gaps, not papered over:

  • HUEMatrixEditor::algorithms() has no test. qmlui builds an executable rather than a library and FunctionEditor depends on Tardis, so editors cannot be constructed in a unit test. The delegation is proven only at the cache boundary; MANUAL_REVIEW 23.1 covers it by hand.
  • Two async-precompute predicate arms are provably uncovered: the m_precomputedAlgorithm == m_runAlgorithm check in consumePrecomputedMap, and the pre-compute generation re-check in kickAsyncRgbMap. Deleting either fails no test.
  • Destructor drain is bounded per object at 2s. Many stuck matrices would accumulate at shutdown; not observed in practice.
  • A HUEMatrix can be assigned to a VC Animation widget (it IS-A RGBMatrix), but that widget's icon is unconditionally the RGB Matrix icon. Cosmetic.

resources/rgbscripts/audiospectrum.js was renamed to "Audio Spectrum Bars" because it shadowed the built-in RGBAudio algorithm and made it unreachable by name. Workspaces storing the old name will not resolve it; verified this adds no new breakage beyond the relocation loss already described.

abossard and others added 3 commits August 10, 2026 16:49
- Updated multiple RGB scripts to replace HSV color handling with direct RGB values.
- Modified functions to create and manipulate pixel maps using RGB arrays.
- Removed unnecessary HSV color conversions and streamlined color handling.
- Adjusted color initialization and merging logic to accommodate RGB format.
- Cleaned up code for better readability and maintainability.
- Removed RGBW color mode references from the RGBMatrixEditor UI and logic.

Signed-off-by: Andre Bossard <anbossar@microsoft.com>
- Introduced a new QML component `HUEMatrixEditor.qml` for editing hue matrix functions, featuring various UI elements for configuration.
- Created a new CMakeLists.txt file for managing hue script resources, ensuring scripts are copied to the appropriate directory when building for Android.
- Added a new SVG icon `huematrix.svg` to visually represent the hue matrix in the application.

Signed-off-by: Andre Bossard <anbossar@microsoft.com>
Resolves engine/src/rgbmatrix.cpp to upstream/master content.

Both sides carried upstream commit e671868 ("expose RGBMatrix Script
parameters as attributes"): the base picked it up as 896bf2a, this branch
integrated it via the byte-restore. The conflict was the fork divergence that
this branch removes by design, so the resolution keeps rgbmatrix.cpp
byte-identical to upstream and the fork behaviour stays in HUEMatrix.

896bf2a was the only new base commit touching rgbmatrix.cpp; no unique base
work is lost.

Verified: git diff upstream/master -- engine/src/rgbmatrix.cpp is empty;
build clean with -Werror -Wextra -Wall; huematrix 42, rgbmatrix 9, rgbscript 14,
function 37, mcp_rgb_transform 15, all 0 failed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: fc4ab017-05b4-4630-9c37-972e85838621
@abossard
abossard merged commit ada7adc into mcp-server Aug 10, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant