You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
updated add and scale color functions to not use references
- using references is slightly faster but using function calls by value is safer
- this is in perparation to optimize ram usage on ESP32 for larger matrix setups
- optimized by dropping the scale check, it is faster overall
- FPS is now more consistent and on average about the same as it was
staticboolcheckBoundsAndWrap(int32_t &position, constint32_t max, constint32_t particleradius, constbool wrap); // returns false if out of bounds by more than particleradius
20
-
staticvoidfast_color_add(CRGBW &c1, const CRGBW &c2, uint8_t scale = 255); // fast and accurate color adding with scaling (scales c2 before adding)
21
-
staticvoidfast_color_scale(CRGBW &c, constuint8_t scale); // fast scaling function using 32bit variable and pointer. note: keep 'scale' within 0-255
20
+
staticuint32_tfast_color_add(CRGBW c1, const CRGBW c2, uint8_t scale = 255); // fast and accurate color adding with scaling (scales c2 before adding)
21
+
staticuint32_tfast_color_scale(CRGBW c, constuint8_t scale); // fast scaling function using 32bit variable and pointer. note: keep 'scale' within 0-255
fast_color_scale(framebuffer[index], motionBlur); // note: could skip if only globalsmear is active but usually they are both active and scaling is fast enough
575
+
framebuffer[index] = fast_color_scale(framebuffer[index], motionBlur); // note: could skip if only globalsmear is active but usually they are both active and scaling is fast enough
fast_color_add(framebuffer[pixco[i].x + (maxYpixel - pixco[i].y) * (maxXpixel + 1)], color, pxlbrightness[i]); // order is: bottom left, bottom right, top right, top left
786
+
if (pixelvalid[i]) {
787
+
uint32_t idx = pixco[i].x + (maxYpixel - pixco[i].y) * (maxXpixel + 1); // flip y coordinate (0,0 is bottom left in PS but top left in framebuffer)
788
+
framebuffer[idx] = fast_color_add(framebuffer[idx], color, pxlbrightness[i]); // order is: bottom left, bottom right, top right, top left
sources = reinterpret_cast<PSsource *>(particleFlags + numParticles); // pointer to source(s) at data+sizeof(ParticleSystem2D)
986
-
framebuffer = reinterpret_cast<CRGBW *>(SEGMENT.getPixels()); // pointer to framebuffer
990
+
framebuffer = SEGMENT.getPixels(); // pointer to framebuffer
987
991
PSdataEnd = reinterpret_cast<uint8_t *>(sources + numSources); // pointer to first available byte after the PS for FX additional data (already aligned to 4 byte boundary)
PSdataEnd = reinterpret_cast<uint8_t *>(sources + numSources); // pointer to first available byte after the PS for FX additional data (already aligned to 4 byte boundary)
1738
1740
#ifndef WLED_DISABLE_2D
1739
1741
if(SEGMENT.is2D() && SEGMENT.map1D2D) {
1740
-
framebuffer = reinterpret_cast<CRGBW *>(sources + numSources); // use local framebuffer for 1D->2D mapping
1742
+
framebuffer = reinterpret_cast<uint32_t *>(sources + numSources); // use local framebuffer for 1D->2D mapping
1741
1743
PSdataEnd = reinterpret_cast<uint8_t *>(framebuffer + SEGMENT.maxMappingLength()); // pointer to first available byte after the PS for FX additional data (still aligned to 4 byte boundary)
1742
1744
}
1743
1745
else
1744
1746
#endif
1745
-
framebuffer = reinterpret_cast<CRGBW *>(SEGMENT.getPixels()); // use segment buffer for standard 1D rendering
1747
+
framebuffer = SEGMENT.getPixels(); // use segment buffer for standard 1D rendering
requiredmemory += sizeof(CRGBW) * SEGMENT.maxMappingLength(); // need local buffer for mapped rendering. CRGBW is 32bit, so this is a multiple of 4 bytes
1797
+
requiredmemory += sizeof(uint32_t) * SEGMENT.maxMappingLength(); // need local buffer for mapped rendering
// fastled color adding is very inaccurate in color preservation (but it is fast)
1891
-
// a better color add function is implemented in colors.cpp but it uses 32bit RGBW. to use it colors need to be shifted just to then be shifted back by that function, which is slow
1892
-
// this is a fast version for RGB (no white channel, PS does not handle white) and with native CRGBW including scaling of second color
1893
-
// note: result is stored in c1, not using a return value is faster as the CRGBW struct does not need to be copied upon return
1894
-
// note2: function is mainly used to add scaled colors, so checking if one color is black is slower
1895
-
// note3: scale is 255 when using blur, checking for that makes blur faster
0 commit comments