Repository navigation
refactor(colorimetric): extract shared response layer (#3255 PR 1) - #3256
Conversation
Move the topology-independent math primitives out of `fl::colorimetric_detail::` and into a new `fl::colorimetric_response::` namespace so the upcoming RGB-only colorimetric path (PR 3 of #3255) can reuse them without dragging in RGBW-specific solver internals. Moved into `src/fl/gfx/colorimetric_response.h`: cct_to_xy, xyY_to_XYZ, invert3x3, matvec3, barycentric_xy, build_source_matrix, quantize_u8, quantize_lut_cell, nnls3, hermite_basis, the kLut* constants, the LutInterp enum, and a new EmitterProfile struct (declared now, used by the RGB solver in PR 3). `rgbw_colorimetric.h` keeps every RGBW-specific declaration (ProfileCache, LutTable, RgbcctProfile, solve_*) and re-exports the moved names into `colorimetric_detail::` via using-declarations so every existing call site (`rgbw.cpp.hpp`, `rgbww.cpp.hpp`, the `using namespace fl::colorimetric_detail` test) keeps compiling byte-identically. PR 2 of #3255 will drop the `colorimetric_detail::` re-exports as part of the variant + shared_ptr refactor. Verification: - bash test fl_gfx_colorimetric_response (new module, 20 cases) - bash test fl_gfx_rgbw_colorimetric (existing, byte-identical) - bash test fl_gfx_rgbww (existing, byte-identical) - bash test --cpp (331/331 pass) - bash lint --cpp (clean) Refs #3255. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughShared chromaticity math and LUT utilities are extracted from ChangesColorimetric math extraction and wiring
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/fl/gfx/colorimetric_response.cpp.hpp`:
- Around line 14-24: Replace the FASTLED_RGBW_COLORIMETRIC preprocessor
directive check at the top of the file with a new FL_* format identifier
following the FL_<COMPONENT>_<NAME> naming convention. Update the `#if`
preprocessor check and its corresponding `#endif` comment to use the new FL_*
macro name instead of the FASTLED_RGBW_COLORIMETRIC macro, ensuring consistency
with the macro policy that forbids new FASTLED_* identifiers in newly introduced
code.
In `@src/fl/gfx/colorimetric_response.h`:
- Around line 41-56: The function signatures cct_to_xy and xyY_to_XYZ use
decayed array parameters (float out[2] and float out[3]) which lose extent
information and don't provide bounds checking. Replace all occurrences of
fixed-size array parameters in the form T out[N] or T in[N] with fl::span<T, N>
to provide extent-safe types. This applies to cct_to_xy, xyY_to_XYZ, and the
other functions mentioned at lines 67-68, 88-89, 94-96, 131-133, and 224-225.
Update each parameter declaration to use the appropriate fl::span specialization
with the correct size.
- Around line 41-238: Move all function definitions (cct_to_xy, xyY_to_XYZ,
invert3x3, matvec3, barycentric_xy, quantize_u8, build_source_matrix, nnls3,
hermite_basis, quantize_lut_cell, and the constexpr constants) out of the
src/fl/gfx/colorimetric_response.h file and into a new
colorimetric_response.cpp.hpp or colorimetric_response.impl.hpp file. The .h
file should contain only forward declarations, type definitions, and enum
declarations, while the function bodies and implementation details move to the
new .cpp.hpp/.impl.hpp file which will be included in the appropriate
implementation files.
- Around line 31-41: The comments in colorimetric_response.h contain non-ASCII
Unicode characters that violate the 7-bit ASCII requirement. Replace all Unicode
glyphs with their ASCII equivalents throughout the file, specifically in the
comments around the cct_to_xy function definition and in the sections at lines
158-165, 202-207, 216-223, and 245-248. Replace the following: ≤ with <=, ≥ with
>=, × with x, · with ., ∂ with d, → with ->, and any other non-ASCII characters
with their ASCII equivalents to ensure the entire file uses only 7-bit ASCII
characters.
In `@tests/fl/gfx/colorimetric_response.cpp`:
- Around line 166-212: Replace all non-ASCII Unicode characters in the comments
throughout this test file with their ASCII equivalents. Specifically, replace
the arrow symbol (→) with a hyphen-greater-than sequence (->), the
approximately-equal symbol (≈) with a tilde-equals sequence (~=), and the middle
dot symbol (·) with an asterisk (*). Apply these replacements to all test cases
including "build_source_matrix: Rec.709 + D65 reproduces published sRGB → XYZ",
"build_source_matrix: singular primaries return false", and "nnls3: identity
system trivial recovery", as well as any other comments in the file marked in
the review.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 610ed167-8bba-4511-8737-2275543eaac2
📒 Files selected for processing (5)
src/fl/gfx/_build.cpp.hppsrc/fl/gfx/colorimetric_response.cpp.hppsrc/fl/gfx/colorimetric_response.hsrc/fl/gfx/rgbw_colorimetric.htests/fl/gfx/colorimetric_response.cpp
| inline void cct_to_xy(int cct, float out[2]) FL_NOEXCEPT { | ||
| const float T = static_cast<float>( | ||
| (cct < 1500) ? 1500 : ((cct > 15000) ? 15000 : cct)); | ||
| const float T2 = T * T; | ||
| const float u_num = 0.860117757f + 1.54118254e-4f * T + 1.28641212e-7f * T2; | ||
| const float u_den = 1.0f + 8.42420235e-4f * T + 7.08145163e-7f * T2; | ||
| const float v_num = 0.317398726f + 4.22806245e-5f * T + 4.20481691e-8f * T2; | ||
| const float v_den = 1.0f - 2.89741816e-5f * T + 1.61456053e-7f * T2; | ||
| const float u = u_num / u_den; | ||
| const float v = v_num / v_den; | ||
| const float den = 2.0f * u - 8.0f * v + 4.0f; | ||
| out[0] = 3.0f * u / den; | ||
| out[1] = 2.0f * v / den; | ||
| } | ||
|
|
||
| inline void xyY_to_XYZ(float x, float y, float Y, float out[3]) FL_NOEXCEPT { | ||
| if (y < 1e-12f) { | ||
| out[0] = out[1] = out[2] = 0.0f; | ||
| return; | ||
| } | ||
| const float inv_y = 1.0f / y; | ||
| out[0] = x * Y * inv_y; | ||
| out[1] = Y; | ||
| out[2] = (1.0f - x - y) * Y * inv_y; | ||
| } | ||
|
|
||
| inline bool invert3x3(const float in[3][3], float out[3][3]) FL_NOEXCEPT { | ||
| const float a = in[0][0], b = in[0][1], c = in[0][2]; | ||
| const float d = in[1][0], e = in[1][1], f = in[1][2]; | ||
| const float g = in[2][0], h = in[2][1], i = in[2][2]; | ||
| const float det = a * (e * i - f * h) - b * (d * i - f * g) + c * (d * h - e * g); | ||
| if (fl::fabs(det) < 1e-20f) { | ||
| return false; | ||
| } | ||
| const float inv_det = 1.0f / det; | ||
| out[0][0] = (e * i - f * h) * inv_det; | ||
| out[0][1] = (c * h - b * i) * inv_det; | ||
| out[0][2] = (b * f - c * e) * inv_det; | ||
| out[1][0] = (f * g - d * i) * inv_det; | ||
| out[1][1] = (a * i - c * g) * inv_det; | ||
| out[1][2] = (c * d - a * f) * inv_det; | ||
| out[2][0] = (d * h - e * g) * inv_det; | ||
| out[2][1] = (b * g - a * h) * inv_det; | ||
| out[2][2] = (a * e - b * d) * inv_det; | ||
| return true; | ||
| } | ||
|
|
||
| inline void matvec3(const float M[3][3], const float v[3], float out[3]) FL_NOEXCEPT { | ||
| out[0] = M[0][0] * v[0] + M[0][1] * v[1] + M[0][2] * v[2]; | ||
| out[1] = M[1][0] * v[0] + M[1][1] * v[1] + M[1][2] * v[2]; | ||
| out[2] = M[2][0] * v[0] + M[2][1] * v[1] + M[2][2] * v[2]; | ||
| } | ||
|
|
||
| inline bool barycentric_xy(const float t[2], const float A[2], const float B[2], | ||
| const float C[2], float bary[3]) FL_NOEXCEPT { | ||
| const float v0x = B[0] - A[0], v0y = B[1] - A[1]; | ||
| const float v1x = C[0] - A[0], v1y = C[1] - A[1]; | ||
| const float v2x = t[0] - A[0], v2y = t[1] - A[1]; | ||
| const float d00 = v0x * v0x + v0y * v0y; | ||
| const float d01 = v0x * v1x + v0y * v1y; | ||
| const float d11 = v1x * v1x + v1y * v1y; | ||
| const float d20 = v2x * v0x + v2y * v0y; | ||
| const float d21 = v2x * v1x + v2y * v1y; | ||
| const float den = d00 * d11 - d01 * d01; | ||
| if (fl::fabs(den) < 1e-20f) { | ||
| return false; | ||
| } | ||
| const float inv_den = 1.0f / den; | ||
| const float u = (d11 * d20 - d01 * d21) * inv_den; | ||
| const float v = (d00 * d21 - d01 * d20) * inv_den; | ||
| bary[0] = 1.0f - u - v; | ||
| bary[1] = u; | ||
| bary[2] = v; | ||
| return true; | ||
| } | ||
|
|
||
| inline u8 quantize_u8(float v) FL_NOEXCEPT { | ||
| const float scaled = v * 255.0f + 0.5f; | ||
| if (scaled <= 0.0f) return 0; | ||
| if (scaled >= 255.0f) return 255; | ||
| return static_cast<u8>(scaled); | ||
| } | ||
|
|
||
| // Standard CIE primary-matrix construction (#2705). Given source primary | ||
| // chromaticities xy_r/g/b and a source white chromaticity xy_w, build the | ||
| // 3x3 matrix M such that M·[1,1,1]^T = xyY_to_XYZ(xy_w, 1.0). Columns are | ||
| // per-channel scaled XYZ vectors of the primaries at Y=1, with scaling | ||
| // chosen so the (1,1,1) input lands at source white in XYZ. This is the | ||
| // classic linear-sRGB -> XYZ derivation generalized to arbitrary primaries. | ||
| // Returns false if the primary matrix is singular (collinear chromaticities). | ||
| inline bool build_source_matrix(const float xy_r[2], const float xy_g[2], | ||
| const float xy_b[2], const float xy_w[2], | ||
| float M_out[3][3]) FL_NOEXCEPT { | ||
| float xyz_R[3], xyz_G[3], xyz_B[3], xyz_W[3]; | ||
| xyY_to_XYZ(xy_r[0], xy_r[1], 1.0f, xyz_R); | ||
| xyY_to_XYZ(xy_g[0], xy_g[1], 1.0f, xyz_G); | ||
| xyY_to_XYZ(xy_b[0], xy_b[1], 1.0f, xyz_B); | ||
| xyY_to_XYZ(xy_w[0], xy_w[1], 1.0f, xyz_W); | ||
|
|
||
| float P[3][3]; | ||
| P[0][0] = xyz_R[0]; P[0][1] = xyz_G[0]; P[0][2] = xyz_B[0]; | ||
| P[1][0] = xyz_R[1]; P[1][1] = xyz_G[1]; P[1][2] = xyz_B[1]; | ||
| P[2][0] = xyz_R[2]; P[2][1] = xyz_G[2]; P[2][2] = xyz_B[2]; | ||
|
|
||
| float P_inv[3][3]; | ||
| if (!invert3x3(P, P_inv)) { | ||
| return false; | ||
| } | ||
| float k[3]; | ||
| matvec3(P_inv, xyz_W, k); | ||
|
|
||
| M_out[0][0] = k[0] * xyz_R[0]; M_out[0][1] = k[1] * xyz_G[0]; M_out[0][2] = k[2] * xyz_B[0]; | ||
| M_out[1][0] = k[0] * xyz_R[1]; M_out[1][1] = k[1] * xyz_G[1]; M_out[1][2] = k[2] * xyz_B[1]; | ||
| M_out[2][0] = k[0] * xyz_R[2]; M_out[2][1] = k[1] * xyz_G[2]; M_out[2][2] = k[2] * xyz_B[2]; | ||
| return true; | ||
| } | ||
|
|
||
| // Non-negative least squares for the 3×3 sub-system M·t = b with t ≥ 0 | ||
| // (#2708, gist §3). Projected-gradient form matching the reference | ||
| // `_nnls_solve` fallback used when scipy is unavailable: 500 iterations at | ||
| // step 0.01. Cheap (~50 µs scalar on a typical MCU at -O2; only invoked for | ||
| // out-of-hull source targets, never on the in-hull fast path) and free of | ||
| // dynamic allocation, which makes it safe to inline behind the colorimetric | ||
| // solvers' rare-branch. | ||
| inline void nnls3(const float M[3][3], const float b[3], // ok array parameter | ||
| float t_out[3], float* residual_out) FL_NOEXCEPT { | ||
| float t[3] = {0.0f, 0.0f, 0.0f}; | ||
| constexpr float kStep = 0.01f; | ||
| constexpr int kIters = 500; | ||
| for (int it = 0; it < kIters; ++it) { | ||
| float r[3]; | ||
| r[0] = M[0][0]*t[0] + M[0][1]*t[1] + M[0][2]*t[2] - b[0]; | ||
| r[1] = M[1][0]*t[0] + M[1][1]*t[1] + M[1][2]*t[2] - b[1]; | ||
| r[2] = M[2][0]*t[0] + M[2][1]*t[1] + M[2][2]*t[2] - b[2]; | ||
| // grad = Mᵀ · r | ||
| float g[3]; | ||
| g[0] = M[0][0]*r[0] + M[1][0]*r[1] + M[2][0]*r[2]; | ||
| g[1] = M[0][1]*r[0] + M[1][1]*r[1] + M[2][1]*r[2]; | ||
| g[2] = M[0][2]*r[0] + M[1][2]*r[1] + M[2][2]*r[2]; | ||
| for (int j = 0; j < 3; ++j) { | ||
| float v = t[j] - kStep * g[j]; | ||
| t[j] = v > 0.0f ? v : 0.0f; | ||
| } | ||
| } | ||
| if (residual_out != nullptr) { | ||
| float r[3]; | ||
| r[0] = M[0][0]*t[0] + M[0][1]*t[1] + M[0][2]*t[2] - b[0]; | ||
| r[1] = M[1][0]*t[0] + M[1][1]*t[1] + M[1][2]*t[2] - b[1]; | ||
| r[2] = M[2][0]*t[0] + M[2][1]*t[1] + M[2][2]*t[2] - b[2]; | ||
| *residual_out = fl::sqrt(r[0]*r[0] + r[1]*r[1] + r[2]*r[2]); | ||
| } | ||
| t_out[0] = t[0]; t_out[1] = t[1]; t_out[2] = t[2]; | ||
| } | ||
|
|
||
| // ===== LUT quantization and interpolation constants ========================= | ||
| // Used by both the RGBW LUT (today) and any future RGB / RGBCCT LUT paths | ||
| // extracted out of the topology-specific solver modules. | ||
|
|
||
| // LUT cell quantization scale (value in [-8, +8) maps to i16 via *kLutQ). | ||
| constexpr i16 kLutQ = 4096; | ||
|
|
||
| // Storage stride per grid point. Bilinear LUTs store 4 (rgbw) values; Hermite | ||
| // LUTs additionally store ∂/∂t_x and ∂/∂t_y per channel (in cell-parameter | ||
| // units), enabling bicubic Hermite interpolation that reaches comparable | ||
| // accuracy at ~half the grid edge length — ~25 % of the memory at ~ the | ||
| // same error vs. bilinear. The grid step is uniform so derivatives are | ||
| // naturally expressed in cell-parameter units (t ∈ [0, 1] per cell). | ||
| constexpr int kLutStrideBilinear = 4; | ||
| constexpr int kLutStrideHermite = 12; | ||
|
|
||
| enum class LutInterp : u8 { | ||
| Bilinear = 0, | ||
| Hermite = 1, | ||
| }; | ||
|
|
||
| // Cubic Hermite basis on [0, 1]. Output layout: { h00, h01, h10, h11 } where | ||
| // h00(t) = 2t³ - 3t² + 1 value at t=0 | ||
| // h01(t) = -2t³ + 3t² value at t=1 | ||
| // h10(t) = t³ - 2t² + t derivative at t=0 | ||
| // h11(t) = t³ - t² derivative at t=1 | ||
| // Lifted into a header inline so `lookup_lut` and the test suite consume | ||
| // exactly the same evaluator (CodeRabbit #2707: tests that redefine basis | ||
| // locally cannot catch regressions in the production code). | ||
| inline void hermite_basis(float t, float out[4]) FL_NOEXCEPT { | ||
| const float t2 = t * t; | ||
| const float t3 = t2 * t; | ||
| out[0] = 2.0f * t3 - 3.0f * t2 + 1.0f; | ||
| out[1] = -2.0f * t3 + 3.0f * t2; | ||
| out[2] = t3 - 2.0f * t2 + t; | ||
| out[3] = t3 - t2; | ||
| } | ||
|
|
||
| inline i16 quantize_lut_cell(float v) FL_NOEXCEPT { | ||
| const float scaled = v * static_cast<float>(kLutQ) + 0.5f; | ||
| if (scaled <= -32768.0f) return -32768; | ||
| if (scaled >= 32767.0f) return 32767; | ||
| return static_cast<i16>(scaled); | ||
| } |
There was a problem hiding this comment.
Move function definitions out of src/**/*.h into .cpp.hpp/.impl.hpp.
This header defines many functions inline under src/fl/.../*.h. Per the repo header policy, function definitions should not live in these .h files.
As per coding guidelines, "src/**/*.h: Header file. Verify it does NOT contain function definitions... If function definitions are needed, they belong in .cpp.hpp or .impl.hpp files."
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/fl/gfx/colorimetric_response.h` around lines 41 - 238, Move all function
definitions (cct_to_xy, xyY_to_XYZ, invert3x3, matvec3, barycentric_xy,
quantize_u8, build_source_matrix, nnls3, hermite_basis, quantize_lut_cell, and
the constexpr constants) out of the src/fl/gfx/colorimetric_response.h file and
into a new colorimetric_response.cpp.hpp or colorimetric_response.impl.hpp file.
The .h file should contain only forward declarations, type definitions, and enum
declarations, while the function bodies and implementation details move to the
new .cpp.hpp/.impl.hpp file which will be included in the appropriate
implementation files.
Source: Coding guidelines
There was a problem hiding this comment.
Deferred to PR 2 of #3255. The inline definitions in src/fl/gfx/colorimetric_response.h are a byte-identical move of code that already lived inline in src/fl/gfx/rgbw_colorimetric.h on master (same pattern, same call sites in rgbw.cpp.hpp / rgbww.cpp.hpp consumed the inline-in-header layout). The header comment at the top of colorimetric_response.h explicitly documents the rationale -- these helpers are in hot inner loops and the optimizer needs to fold them. Splitting the bodies out into colorimetric_response.cpp.hpp now would change inlining behavior versus the master baseline (violating this PR's byte-identical guarantee for the RGBW solver) and would leave the matching inline helpers in rgbw_colorimetric.h half-migrated. PR 2 of #3255 will move both files' bodies into .cpp.hpp together with an explicit benchmark gate to confirm the optimizer still folds them at the call sites.
There was a problem hiding this comment.
@zackees, understood — the inline-in-header layout is the established baseline for these helpers and splitting the bodies now would change inlining behavior relative to master. The plan for PR 2 of #3255 (benchmarked, coordinated move of both files together) makes sense.
Would you like me to open a GitHub tracking issue for the migration of colorimetric_response.h and rgbw_colorimetric.h function bodies to .cpp.hpp in PR 2 of #3255, so it doesn't get lost?
✏️ Learnings added
Learnt from: zackees
Repo: FastLED/FastLED PR: 3256
File: src/fl/gfx/colorimetric_response.h:41-238
Timestamp: 2026-06-19T02:26:47.210Z
Learning: In `src/fl/gfx/colorimetric_response.h` (and the peer `src/fl/gfx/rgbw_colorimetric.h`), the colorimetric math helpers (`cct_to_xy`, `xyY_to_XYZ`, `invert3x3`, `matvec3`, `barycentric_xy`, `quantize_u8`, `build_source_matrix`, `nnls3`, `hermite_basis`, `quantize_lut_cell`) are intentionally kept `inline` in the `.h` file rather than moved to `.cpp.hpp`/`.impl.hpp`. These helpers sit in hot inner loops and must be visible to the optimizer for folding at call sites in `rgbw.cpp.hpp` and `rgbww.cpp.hpp`. Moving them to `.cpp.hpp` is planned for PR 2 of issue `#3255`, which will migrate both files together with an explicit benchmark gate to confirm the optimizer still folds them. Do not flag the inline-in-header pattern for these specific files as a violation until that migration PR lands.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Address CodeRabbit comment 3439669997 on PR #3256: replace non-ASCII glyphs in comments and test-case names (-> , <=, ~=, etc.) so the new test file complies with the repo source-encoding rule. The matching non-ASCII characters in the moved code in src/fl/gfx/colorimetric_response.h and the inline definitions / decayed array parameter style are intentionally left untouched in this PR -- that content is a byte-identical move out of rgbw_colorimetric.h and will be normalized in PR 2 of #3255 alongside the matching cleanup of the original RGBW header. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
PR 1 of #3255. Pure refactor — moves the topology-independent colorimetric math helpers out of
fl::colorimetric_detail::(RGBW-specific) into a newfl::colorimetric_response::namespace so the upcoming RGB-only colorimetric path (PR 3) can reuse them.Zero behavior change — every RGBW path still calls the same code via using-declarations that re-export the moved names back into
colorimetric_detail::. PR 2 will drop those re-exports as part of the variant + shared_ptr config refactor.What moved
Into
src/fl/gfx/colorimetric_response.hundernamespace fl::colorimetric_response:cct_to_xy,xyY_to_XYZ,invert3x3,matvec3,barycentric_xy,build_source_matrixquantize_u8,quantize_lut_cell,nnls3,hermite_basiskLutQ,kLutStrideBilinear,kLutStrideHermite, theLutInterpenumEmitterProfilestruct (RGB-only profile shape; declared here so PR 3 can land the solver without a structural reshuffle).What stayed
src/fl/gfx/rgbw_colorimetric.hkeeps every RGBW-specific declaration:ProfileCache,LutTable,RgbcctProfile,is_native_input_gamut,count_active_channels, thebuild_profile_cache/solve_strict_subgamut*/solve_wx_lp_legacy/solve_wx_overdrive/build_lut/lookup_lut/solve_rgbcctdeclarations, thekDefaultOverdriveRatioconstant.The header now
#includescolorimetric_response.hand starts with a using-declaration block (each marked// ok bare using— controlled re-export inside a namespace block) that re-imports the moved names intocolorimetric_detail::. That keeps every external caller working unchanged:src/fl/gfx/rgbw.cpp.hpp(6 references),src/fl/gfx/rgbww.cpp.hpp(11 references),src/fl/gfx/rgbww.h, andtests/fl/gfx/rgbw_colorimetric.cpp(usesusing namespace fl::colorimetric_detail;).New test coverage
tests/fl/gfx/colorimetric_response.cppexercises the moved primitives in isolation of any RGBW topology — 20 test cases covering xyY/XYZ round-trip, 3x3 invert identity + singular detection, matvec3 hand-computed product, barycentric inside/outside, CCT-to-xy at 2700/4000/6500K, quantize edges, NNLS identity + non-negativity, Hermite basis at nodes + partition-of-unity, LUT stride constants, andEmitterProfilezero-init.The existing
tests/fl/gfx/rgbw_colorimetric.cppwas deliberately not touched and continues to pass byte-identically — it pulls in the moved helpers via the using-declarations.Build manifest
src/fl/gfx/_build.cpp.hpppicks upcolorimetric_response.cpp.hppin the same unity-build slot as the other gfx modules. The new.cpp.hppis empty (gated byFASTLED_RGBW_COLORIMETRICso it matches the existing gate exactly) and reserved for PR 3'ssolve_rgb_colorimetricdefinition.Test plan
bash test fl_gfx_colorimetric_response— new module, 20/20 passbash test fl_gfx_rgbw_colorimetric— existing, byte-identical, passbash test fl_gfx_rgbww— existing, byte-identical, passbash test --cpp— 331/331 passbash lint --cpp— cleanOut of scope
PR 2 of #3255:
fl::variant<RGBW_MODE, ColorimetricMode>+DiodeProfilePtr(fl::shared_ptr<const DiodeProfile>), removal ofFASTLED_RGBW_COLORIMETRICmacro +kRGBWColorimetric/kRGBWColorimetricBoostedenum entries + global setters + the using-declaration re-exports added here.PR 3 of #3255: actual RGB solver implementation, per-strip
loadAndScaleRGBhook,CLEDController::setRgbColorimetricProfile,FL_PLATFORM_HAS_TINY_MEMORYgating on per-instance state.Refs #3255.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
EmitterProfilestructure.Refactor
Tests
EmitterProfileinitialization.Chores