Repository navigation
Rebase generic palette refactor onto current master - #2363
Conversation
|
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 (3)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughIntroduces a generic template infrastructure for palettes, centralizes PROGMEM loading and fill logic, and replaces per-palette upscaling loops with two helpers ( Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 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 |
📊 Header Compilation PerformanceTotal Time: 1135.21ms Top 5 Slowest Headers
Warnings
Full Report |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/fl/gfx/colorutils.h`:
- Around line 531-546: The member-template disambiguator "template" is
incorrectly used without an explicit template argument list in the TCRGBPalette
constructors and assignment operators (symbols: TCRGBPalette, operator=) causing
clang/WASM failures; remove the stray "template" keyword and call the dependent
member directly as Base::copyConverted(...) in each of the four sites (the two
constructors and two operator= overloads) so the calls become
Base::copyConverted(rhs.entries) and Base::copyConverted(rhs) respectively.
🪄 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: b5982033-2845-4fb9-9a60-9d42ff5bb398
📒 Files selected for processing (3)
src/fl/gfx/colorutils.cpp.hppsrc/fl/gfx/colorutils.htests/fl/gfx/colorutils_palette.cpp
5fbc178 to
9146920
Compare
|
Addressed the review comment and force-pushed the branch as a single amended commit. Current head: Change made:
Focused verification after the fix:
|
📊 Header Compilation PerformanceTotal Time: 1163.38ms Top 5 Slowest Headers
Warnings
Full Report |
There was a problem hiding this comment.
Pull request overview
This PR rebases and modernizes the palette refactor by consolidating duplicated palette behavior behind shared internal helpers while keeping the public CHSVPalette* / CRGBPalette* types and UpscalePalette(...) entry points intact, and adds targeted unit coverage for the refactor’s compatibility-sensitive behaviors.
Changes:
- Refactors palette class implementations in
colorutils.hto use shared internaldetail::TColorPalette/detail::TCRGBPalettehelpers (including common PROGMEM loading and fill/gradient behavior). - Refactors
UpscalePalette(...)implementations to use shared internal upscaling helpers (repeat/interpolated) for consistent behavior. - Adds focused tests covering 16/32/256 upscaling, PROGMEM constructors, same-size CHSV→CRGB conversion, and single-color copy-initializable construction.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/fl/gfx/colorutils_palette.cpp | Adds unit tests validating palette upscaling, PROGMEM loading, CHSV→CRGB conversions, and constructor/assignment compatibility. |
| src/fl/gfx/colorutils.h | Centralizes palette implementation details into shared internal templates/helpers while preserving public palette types and behavior. |
| src/fl/gfx/colorutils.cpp.hpp | Replaces duplicated upscaling loops with shared internal helper templates for repeat/interpolated upscaling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| TColorPalette(const TColor (&rhs)[Size]) FL_NOEXCEPT { copyBytes(rhs); } | ||
|
|
||
| /// Create palette with a gradient from one color to another | ||
| /// @param c1 the starting color for the gradient | ||
| /// @param c2 the end color for the gradient | ||
| CHSVPalette16(const CHSV &c1, const CHSV &c2) FL_NOEXCEPT { | ||
| fill_gradient(&(entries[0]), 16, c1, c2); | ||
| TColorPalette &operator=(const TColorPalette &rhs) FL_NOEXCEPT { | ||
| copyBytes(rhs.entries); | ||
| return *this; | ||
| } | ||
|
|
||
| /// Create palette with three-color gradient | ||
| /// @param c1 the starting color for the gradient | ||
| /// @param c2 the middle color for the gradient | ||
| /// @param c3 the end color for the gradient | ||
| CHSVPalette16(const CHSV &c1, const CHSV &c2, const CHSV &c3) FL_NOEXCEPT { | ||
| fill_gradient(&(entries[0]), 16, c1, c2, c3); | ||
| TColorPalette &operator=(const TColor (&rhs)[Size]) FL_NOEXCEPT { | ||
| copyBytes(rhs); | ||
| return *this; |
There was a problem hiding this comment.
The refactor replaces the previous palette constructors/assignments that accepted const CRGB rhs[16/32/256] (which is effectively const CRGB*) with const TColor (&rhs)[Size]. This is a breaking public-API change: user code that passes a pointer (e.g. CRGB* buf) to construct/assign a palette will no longer compile. To preserve the existing API as stated in the PR description, reintroduce overloads that take const TColor* (and const CHSV* for the CHSV->CRGB conversion paths) and copy/convert Size elements.
| for (fl::u16 i = 0; i < (sizeof(entries)); ++i) { | ||
| if (*p != *q) | ||
| } | ||
| for (unsigned int i = 0; i < sizeof(entries); ++i) { |
There was a problem hiding this comment.
operator== iterates with unsigned int i but compares against sizeof(entries) (a size_t). On some toolchains this can trigger signed/unsigned or width mismatch warnings (and potential -Werror failures). Prefer size_t i (or decltype(sizeof(entries))) for the loop counter to match sizeof's type.
| for (unsigned int i = 0; i < sizeof(entries); ++i) { | |
| for (decltype(sizeof(entries)) i = 0; i < sizeof(entries); ++i) { |
Summary
masterUpscalePalette(...)entry points intactWhat This Keeps Intact
CHSVPalette16/32/256andCRGBPalette16/32/256types remain in placeUpscalePalette(...)overloads remain the public pathCRGBPalette32/256remain intactVerification
g++ -std=gnu++17 -I. -Isrc -Itests -Isrc/platforms/stub -DSTUB_PLATFORM -x c++ -fsyntax-only tests/fl/gfx/colorutils_palette.cpp-Werror=division-by-zero, missing PCH, forced AVX512 macros)fl.gfx+.cpptranslation unit after removing those same unrelated toolchain flagsNotes
This supersedes #1036 with a fresh implementation on top of current
masterinstead of trying to revive the old branch directly.Summary by CodeRabbit
New Features
Refactor
Tests