@@ -216,18 +216,34 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM:
216216 if (Segment::maxHeight==1 ) return ; // not a matrix set-up
217217 if (x<0 || y<0 || x >= virtualWidth () || y >= virtualHeight ()) return ; // if pixel would fall out of virtual segment just exit
218218
219- if (ledsrgb) ledsrgb[XY (x,y)] = col;
220-
219+ unsigned i = UINT_MAX;
220+ bool sameColor = false ;
221+ if (ledsrgb) { // WLEDMM small optimization
222+ i = XY (x,y);
223+ if ((i < UINT_MAX) && (ledsrgb[i] == col)) sameColor = true ;
224+ else ledsrgb[i] = col;
225+ }
221226 uint8_t _bri_t = currentBri (on ? opacity : 0 );
222227 if (!_bri_t && !transitional) return ;
223228 if (_bri_t < 255 ) {
224229 col = color_fade (col, _bri_t );
225230 }
226231
232+ #if 0 // this is a dangerous optimization
233+ if ((i < UINT_MAX) && sameColor && (ledsrgb[i] == col) && (_globalLeds == nullptr)) return; // WLEDMM looks like nothing to do (but we don't trust globalleds)
234+ #endif
235+
227236 if (reverse ) x = virtualWidth () - x - 1 ;
228237 if (reverse_y) y = virtualHeight () - y - 1 ;
229238 if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
230239
240+ // WLEDMM shortcut when no grouping/spacing used
241+ bool simpleSegment = !mirror && !mirror_y && (grouping == 1 ) && (spacing == 0 );
242+ if (simpleSegment) {
243+ strip.setPixelColorXY (start + x, startY + y, col);
244+ return ;
245+ }
246+
231247 x *= groupLength (); // expand to physical pixels
232248 y *= groupLength (); // expand to physical pixels
233249 if (x >= width () || y >= height ()) return ; // if pixel would fall out of segment just exit
@@ -308,8 +324,10 @@ void Segment::setPixelColorXY(float x, float y, uint32_t col, bool aa, bool fast
308324// returns RGBW values of pixel
309325uint32_t IRAM_ATTR_YN Segment::getPixelColorXY (int x, int y) {
310326 if (x<0 || y<0 || !isActive ()) return 0 ; // not active or out-of range
311- int i = XY (x,y);
312- if (ledsrgb) return RGBW32 (ledsrgb[i].r , ledsrgb[i].g , ledsrgb[i].b , 0 );
327+ if (ledsrgb) {
328+ int i = XY (x,y);
329+ return RGBW32 (ledsrgb[i].r , ledsrgb[i].g , ledsrgb[i].b , 0 );
330+ }
313331 if (reverse ) x = virtualWidth () - x - 1 ;
314332 if (reverse_y) y = virtualHeight () - y - 1 ;
315333 if (transpose) { uint16_t t = x; x = y; y = t; } // swap X & Y if segment transposed
@@ -325,7 +343,7 @@ void Segment::blendPixelColorXY(uint16_t x, uint16_t y, uint32_t color, uint8_t
325343}
326344
327345// Adds the specified color with the existing pixel color perserving color balance.
328- void Segment::addPixelColorXY (int x, int y, uint32_t color, bool fast) {
346+ void IRAM_ATTR_YN Segment::addPixelColorXY (int x, int y, uint32_t color, bool fast) {
329347 if (!isActive ()) return ; // not active
330348 if (x >= virtualWidth () || y >= virtualHeight () || x<0 || y<0 ) return ; // if pixel would fall out of virtual segment just exit
331349 uint32_t col = getPixelColorXY (x,y);
0 commit comments