[ili9xxx] Improve fill operation performance (#4702)

Co-authored-by: Your Name <you@example.com>
This commit is contained in:
Fabian 2023-05-10 01:19:28 +02:00 committed by GitHub
parent b5dac00dcb
commit 8c32941428
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,10 +84,19 @@ void ILI9XXXDisplay::fill(Color color) {
break;
case BITS_16:
new_color = display::ColorUtil::color_to_565(color);
for (uint32_t i = 0; i < this->get_buffer_length_() * 2; i = i + 2) {
{
const uint32_t buffer_length_16_bits = this->get_buffer_length_() * 2;
if (((uint8_t) (new_color >> 8)) == ((uint8_t) new_color)) {
// Upper and lower is equal can use quicker memset operation. Takes ~20ms.
memset(this->buffer_, (uint8_t) new_color, buffer_length_16_bits);
} else {
// Slower set of both buffers. Takes ~30ms.
for (uint32_t i = 0; i < buffer_length_16_bits; i = i + 2) {
this->buffer_[i] = (uint8_t) (new_color >> 8);
this->buffer_[i + 1] = (uint8_t) new_color;
}
}
}
return;
break;
default: