[display] Keep to_color() inlined in both draw_pixels_at loops

With two call sites GCC at -Os stopped inlining to_color(), which cost
a call and spills per pixel; flatten keeps it inlined, and the row loop
now measures faster than before the change.
This commit is contained in:
J. Nick Koston
2026-09-17 08:44:14 -05:00
parent e3a62194e5
commit cdfcb71f58
+5 -2
View File
@@ -73,8 +73,11 @@ static inline ESPHOME_ALWAYS_INLINE uint32_t read_packed_pixel(const uint8_t *pt
}
}
void Display::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order,
ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) {
// flatten keeps to_color() inlined in both loops; GCC at -Os stops inlining
// it once there are two call sites, which costs a call and spills per pixel.
__attribute__((flatten)) void Display::draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr,
ColorOrder order, ColorBitness bitness, bool big_endian,
int x_offset, int y_offset, int x_pad) {
const size_t line_stride = x_offset + w + x_pad; // length of each source line in pixels
#ifdef USE_PSRAM
// The source is row-major; when the display swaps the axes before writing,