diff --git a/wled00/colorTools.hpp b/wled00/colorTools.hpp index 9d600b3e..27249e31 100644 --- a/wled00/colorTools.hpp +++ b/wled00/colorTools.hpp @@ -25,8 +25,9 @@ /* * color blend function (from colors.cpp) */ -inline __attribute__((hot,const)) uint32_t color_blend(uint32_t color1, uint32_t color2, uint_fast16_t blend, bool b16=false) { - if ((color1 == color2) || (blend == 0)) return color1; // WLEDMM +inline WLED_O3_ATTR __attribute__((hot,const)) uint32_t color_blend(uint32_t color1, uint32_t color2, uint_fast16_t blend, bool b16=false) { + // min / max blend checking is omitted: calls with 0 or 255 are rare, checking lowers overall performance + // if ((color1 == color2) || (blend == 0)) return color1; // WLEDMM const uint_fast16_t blendmax = b16 ? 0xFFFF : 0xFF; if(blend >= blendmax) return color2; const uint_fast8_t shift = b16 ? 16 : 8; @@ -64,7 +65,7 @@ inline __attribute__((hot,const)) uint32_t color_blend(uint32_t color1, uint32_t * idea: https://github.com/Aircoookie/WLED/pull/2465 by https://github.com/Proto-molecule */ -inline __attribute__((hot,const)) uint32_t color_add(uint32_t c1, uint32_t c2, bool fast=false) +inline WLED_O3_ATTR __attribute__((hot,const)) uint32_t color_add(uint32_t c1, uint32_t c2, bool fast=false) { if (c2 == 0) return c1; // WLEDMM shortcut if (c1 == 0) return c2; // WLEDMM shortcut @@ -98,7 +99,7 @@ inline __attribute__((hot,const)) uint32_t color_add(uint32_t c1, uint32_t c2, b * if using "video" method the resulting color will never become black unless it is already black */ -inline __attribute__((hot,const)) uint32_t color_fade(uint32_t c1, uint8_t amount, bool video=false) +inline WLED_O2_ATTR __attribute__((hot,const)) uint32_t color_fade(uint32_t c1, uint8_t amount, bool video=false) { if (c1 == 0 || amount == 0) return 0; // black or no change if (amount == 255) return c1; diff --git a/wled00/colors.cpp b/wled00/colors.cpp index 379afecf..9b5a03d3 100644 --- a/wled00/colors.cpp +++ b/wled00/colors.cpp @@ -8,8 +8,9 @@ /* * color blend function */ -uint32_t WLED_O2_ATTR IRAM_ATTR __attribute__((hot)) color_blend(uint32_t color1, uint32_t color2, uint_fast16_t blend, bool b16) { - if ((color1 == color2) || (blend == 0)) return color1; // WLEDMM +uint32_t WLED_O3_ATTR IRAM_ATTR_YN __attribute__((hot)) color_blend(uint32_t color1, uint32_t color2, uint_fast16_t blend, bool b16) { + // min / max blend checking is omitted: calls with 0 or 255 are rare, checking lowers overall performance + //if ((color1 == color2) || (blend == 0)) return color1; // WLEDMM const uint_fast16_t blendmax = b16 ? 0xFFFF : 0xFF; if(blend >= blendmax) return color2; const uint_fast8_t shift = b16 ? 16 : 8; @@ -80,7 +81,7 @@ uint32_t WLED_O2_ATTR color_add(uint32_t c1, uint32_t c2, bool fast) // WLEDMM * if using "video" method the resulting color will never become black unless it is already black */ -uint32_t IRAM_ATTR_YN __attribute__((hot)) color_fade(uint32_t c1, uint8_t amount, bool video) +uint32_t WLED_O2_ATTR IRAM_ATTR_YN __attribute__((hot)) color_fade(uint32_t c1, uint8_t amount, bool video) { if (c1 == 0 || amount == 0) return 0; // black or no change if (amount == 255) return c1;