minor speedup for 2D

* robustness: Segment::height() should never return 0
* Segment::XY(), Segment::virtualWidth() and Segment::virtualHeight() declared inline in fx.h. The compiler will always inline these functions now, avoiding overhead of call/return. "Knowing" the function body might also enable other optimizations.
--> up to 10% speedup in 2D effects.
This commit is contained in:
Frank
2023-05-26 23:12:49 +02:00
parent e2eb3e8ab4
commit 9cb6189611
3 changed files with 26 additions and 23 deletions

View File

@@ -199,11 +199,7 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) {
#ifndef WLED_DISABLE_2D
// XY(x,y) - gets pixel index within current segment (often used to reference leds[] array element)
uint16_t IRAM_ATTR_YN Segment::XY(uint16_t x, uint16_t y) { //WLEDMM: IRAM_ATTR conditionaly, use fast types
uint_fast16_t width = virtualWidth(); // segment width in logical pixels
uint_fast16_t height = virtualHeight(); // segment height in logical pixels
return (x%width) + (y%height) * width;
}
// WLEDMM Segment::XY()is declared inline, see FX.h
void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM: IRAM_ATTR conditionaly
{