diff --git a/esphome/components/image/image.cpp b/esphome/components/image/image.cpp index 4fbd1520bb2..c0592b33fe6 100644 --- a/esphome/components/image/image.cpp +++ b/esphome/components/image/image.cpp @@ -44,11 +44,15 @@ void Image::draw(int x, int y, display::Display *display, Color color_on, Color // image read and the frame buffer write sequential. When the display swaps // the axes before writing, walking columns keeps the write sequential // instead; a strided write costs more than a strided read. +#ifdef USE_PSRAM if (display->pixel_axes_swapped()) { this->draw_(x, y, display, color_on, color_off, x_start, x_end, y_start, y_end); - } else { - this->draw_(x, y, display, color_on, color_off, x_start, x_end, y_start, y_end); + return; } +#endif + // Without PSRAM the frame buffer is in uncached RAM, where the strided write + // is free, so one copy of the loops is enough. + this->draw_(x, y, display, color_on, color_off, x_start, x_end, y_start, y_end); } template diff --git a/tests/benchmarks/components/image/bench_image_draw.cpp b/tests/benchmarks/components/image/bench_image_draw.cpp index 0b203426d01..83530e0653c 100644 --- a/tests/benchmarks/components/image/bench_image_draw.cpp +++ b/tests/benchmarks/components/image/bench_image_draw.cpp @@ -76,6 +76,21 @@ static void ImageDraw_RGB_Rotated(benchmark::State &state) { } BENCHMARK(ImageDraw_RGB_Rotated); +static void ImageDraw_Binary_Transparent(benchmark::State &state) { + draw_image(state, IMAGE_TYPE_BINARY, TRANSPARENCY_CHROMA_KEY); +} +BENCHMARK(ImageDraw_Binary_Transparent); + +static void ImageDraw_Grayscale_ChromaKey(benchmark::State &state) { + draw_image(state, IMAGE_TYPE_GRAYSCALE, TRANSPARENCY_CHROMA_KEY); +} +BENCHMARK(ImageDraw_Grayscale_ChromaKey); + +static void ImageDraw_Grayscale_Alpha(benchmark::State &state) { + draw_image(state, IMAGE_TYPE_GRAYSCALE, TRANSPARENCY_ALPHA_CHANNEL); +} +BENCHMARK(ImageDraw_Grayscale_Alpha); + static void ImageDraw_RGB_Alpha(benchmark::State &state) { draw_image(state, IMAGE_TYPE_RGB, TRANSPARENCY_ALPHA_CHANNEL); }