From e759c4bd16f435465802e0cc388094926e3a50a5 Mon Sep 17 00:00:00 2001 From: Brandon502 <105077712+Brandon502@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:34:17 -0400 Subject: [PATCH] blendPixelColor Shortcut Don't call color_blend if not needed. --- wled00/FX_2Dfcn.cpp | 3 ++- wled00/FX_fcn.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 83ec0f54..eb1c5aee 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -403,7 +403,8 @@ uint32_t IRAM_ATTR_YN Segment::getPixelColorXY(int x, int y) { // Blends the specified color with the existing pixel color. void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t blend) { - setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend)); + if (blend == UINT8_MAX) setPixelColorXY(x, y, color); + else setPixelColorXY(x, y, color_blend(getPixelColorXY(x,y), color, blend)); } // Adds the specified color with the existing pixel color perserving color balance. diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 65849ff1..8cf35b7d 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1362,7 +1362,8 @@ void Segment::fill(uint32_t c) { // Blends the specified color with the existing pixel color. void Segment::blendPixelColor(int n, uint32_t color, uint8_t blend) { - setPixelColor(n, color_blend(getPixelColor(n), color, blend)); + if (blend == UINT8_MAX) setPixelColor(n, color); + else setPixelColor(n, color_blend(getPixelColor(n), color, blend)); } // Adds the specified color with the existing pixel color perserving color balance.