Faster TFTColor processing (#10814)

This commit is contained in:
Jonathan Bennett
2026-06-29 21:50:09 -05:00
committed by GitHub
parent fd8ba4fa4e
commit 21dbe21745
3 changed files with 65 additions and 7 deletions
+23
View File
@@ -67,6 +67,29 @@ uint16_t resolveTFTColorPixel(int16_t x, int16_t y, bool isset, uint16_t default
// Resolve effective region-mapped OFF color at a coordinate in native-endian RGB565.
uint16_t resolveTFTOffColorAt(int16_t x, int16_t y, uint16_t defaultOffColor);
// -- Per-row fast path for the hot pixel loops in TFTDisplay::display() --------
// resolveTFTColorPixel() is O(regions) per pixel; for a full 800x480 repaint that
// dominates redraw time. Regions are vertically localized, so cull to the regions
// overlapping the current row once per row, then resolve each pixel against only
// those (inlined here, so no per-pixel cross-TU call).
extern uint8_t tftColorRowRegions[MAX_TFT_COLOR_REGIONS]; // indices into colorRegions[], ascending
extern uint8_t tftColorRowCount;
// Build tftColorRowRegions for row y. Call once per row before resolveTFTColorPixelRow().
void beginTFTColorRow(int16_t y);
// Resolve one pixel against the current row's active regions (set by beginTFTColorRow()).
// Highest-index region wins, matching resolveTFTColorPixel()'s precedence.
inline uint16_t resolveTFTColorPixelRow(int16_t x, bool isset, uint16_t defaultOnColor, uint16_t defaultOffColor)
{
for (int j = static_cast<int>(tftColorRowCount) - 1; j >= 0; j--) {
const TFTColorRegion &r = colorRegions[tftColorRowRegions[j]];
if (x >= r.x && x < r.x + r.width)
return isset ? r.onColorBe : r.offColorBe;
}
return isset ? defaultOnColor : defaultOffColor;
}
// -- Theme engine ------------------------------------------------------
// Each theme has four fields that work together:
//