Roger-random / ESP_8_BIT_composite

Color composite video code from ESP_8_BIT as an Arduino library
MIT License
125 stars 15 forks source link

Override Adafruit_GFX::drawFastHLine() and related methods for better performance. #6

Closed Roger-random closed 3 years ago

Roger-random commented 3 years ago

An implementation of Adafruit_GFX is absolutely required to implement drawPixel() by overriding that pure virtual method. Everything beyond that point is optional, as they all offer fallback implementations that eventually end up at drawPixel().

For v1.0.0, the only other override was fillScreen() so there are a few promising venues for performance enhancements. Top of the list is drawFastHLine(). ESP_8_BIT (from which this project was derived) set up the frame buffer as an array of pointers to horizontal lines, so drawFastHLine() can be optimized into a single memset() call.

In contrast, drawFastVLine() is less likely to offer significant improvements, because we have to step through the line array anyway, but it might be worth a shot.

Once drawFastHLine() has been implemented, it should be tested to verify it is indeed faster and not counterintuitively slower for some surprising reason. (Requires #4 ) Once confirmed, it might be worth overriding a few other methods because their default implementation calls into drawFastVLine() instead of drawFastHLine(). (Example: fillRect()) Switching them to drawFastHLine() should be faster.

Roger-random commented 3 years ago

Implemented in 0a1abcc1bc13aa6d3955c0a3850d5bc7f57e7f4a

In addition to previously implemented fillScreen()

Example to demonstrate performance limits of these APIs in 291ac9831d87801b30f078e557d9a112af8714fc