some drawing speedups
* speedups for addPixelColorXY, fadePixelColorXY, fadeToBlackBy
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
|
||||
#define indexToVStrip(index, stripNr) ((index) | (int((stripNr)+1)<<16))
|
||||
|
||||
// WLEDMM replace abs8 by abs, as abs8 does not work for numbers >127
|
||||
#define abs8(x) abs(x)
|
||||
|
||||
// effect utility functions
|
||||
static uint8_t sin_gap(uint16_t in) {
|
||||
if (in & 0x100) return 0;
|
||||
|
||||
@@ -463,8 +463,9 @@ uint32_t IRAM_ATTR_YN Segment::getPixelColorXY(int x, int y) const {
|
||||
if (reverse ) x = virtualWidth() - x - 1;
|
||||
if (reverse_y) y = virtualHeight() - y - 1;
|
||||
if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
|
||||
x *= groupLength(); // expand to physical pixels
|
||||
y *= groupLength(); // expand to physical pixels
|
||||
const uint_fast16_t groupLength_ = groupLength(); // WLEDMM small optimization
|
||||
x *= groupLength_; // expand to physical pixels
|
||||
y *= groupLength_; // expand to physical pixels
|
||||
if (x >= width() || y >= height()) return 0;
|
||||
return strip.getPixelColorXY(start + x, startY + y);
|
||||
}
|
||||
@@ -479,15 +480,16 @@ void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
|
||||
void IRAM_ATTR_YN Segment::addPixelColorXY(int x, int y, uint32_t color, bool fast) {
|
||||
// if (!isActive()) return; // not active //WLEDMM sanity check is repeated in getPixelColorXY / setPixelColorXY
|
||||
// if (x >= virtualWidth() || y >= virtualHeight() || x<0 || y<0) return; // if pixel would fall out of virtual segment just exit //WLEDMM
|
||||
uint32_t col = getPixelColorXY(x,y);
|
||||
col = color_add(col, color, fast);
|
||||
setPixelColorXY(x, y, col);
|
||||
uint32_t oldCol = getPixelColorXY(x,y);
|
||||
uint32_t col = color_add(oldCol, color, fast);
|
||||
if (col != oldCol) setPixelColorXY(x, y, col);
|
||||
}
|
||||
|
||||
void Segment::fadePixelColorXY(uint16_t x, uint16_t y, uint8_t fade) {
|
||||
// if (!isActive()) return; // not active //WLEDMM sanity check is repeated in getPixelColorXY / setPixelColorXY
|
||||
CRGB pix = CRGB(getPixelColorXY(x,y)).nscale8_video(fade);
|
||||
setPixelColorXY(x, y, pix);
|
||||
CRGB oldPix = CRGB(getPixelColorXY(x,y));
|
||||
CRGB pix = oldPix.nscale8_video(fade);
|
||||
if (pix != oldPix) setPixelColorXY(int(x), int(y), pix);
|
||||
}
|
||||
|
||||
// blurRow: perform a blur on a row of a rectangular matrix
|
||||
|
||||
@@ -1510,7 +1510,9 @@ void __attribute__((hot)) Segment::fadeToBlackBy(uint8_t fadeBy) {
|
||||
for (unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) {
|
||||
uint32_t cc = getPixelColorXY(int(x),int(y)); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion
|
||||
uint32_t cc2 = color_fade(cc, scaledown); // fade
|
||||
//if (cc2 != cc) // WLEDMM only re-paint if faded color is different - disabled - causes problem with text overlay
|
||||
#ifdef WLEDMM_FASTPATH
|
||||
if (cc2 != cc) // WLEDMM only re-paint if faded color is different - normally disabled - causes problem with text overlay
|
||||
#endif
|
||||
setPixelColorXY(int(x), int(y), cc2);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2409260
|
||||
#define VERSION 2409280
|
||||
|
||||
// WLEDMM - you can check for this define in usermods, to only enabled WLEDMM specific code in the "right" fork. Its not defined in AC WLED.
|
||||
#define _MoonModules_WLED_
|
||||
|
||||
Reference in New Issue
Block a user