diff options
author | kriegsman@gmail.com <kriegsman@gmail.com@4ad4ec5c-605d-bd5c-5796-512c9b60011b> | 2013-08-20 23:59:31 +0400 |
---|---|---|
committer | kriegsman@gmail.com <kriegsman@gmail.com@4ad4ec5c-605d-bd5c-5796-512c9b60011b> | 2013-08-20 23:59:31 +0400 |
commit | 921d06cf34713231afdaf1c219369f39b70a8547 (patch) | |
tree | 88f7257d039bae793b26dd5e8a0f5e4f5aa9e637 /pixeltypes.h | |
parent | e6f5599396f36c5bf2f98b85b21b00ab0f811620 (diff) |
Renamed operator+=(uint8_t) and operator-=(uint8_t) to addToRGB and subtractFromRGB, even though I don't like those names; this is needed to prevent gcc from DEmoting values like CRGB::Red to 16-bit ints instead of PROmoting them to 32-bit ints.
Diffstat (limited to 'pixeltypes.h')
-rw-r--r-- | pixeltypes.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pixeltypes.h b/pixeltypes.h index 7b66ee63..6d3f67f2 100644 --- a/pixeltypes.h +++ b/pixeltypes.h @@ -195,7 +195,10 @@ struct CRGB { } // add a contstant to each channel, saturating at 0xFF - inline CRGB& operator+= (uint8_t d ) + // this is NOT an operator+= overload because the compiler + // can't usefully decide when it's being passed a 32-bit + // constant (e.g. CRGB::Red) and an 8-bit one (CRGB::Blue) + inline CRGB& addToRGB (uint8_t d ) { r = qadd8( r, d); g = qadd8( g, d); @@ -213,7 +216,10 @@ struct CRGB { } // subtract a constant from each channel, saturating at 0x00 - inline CRGB& operator-= (uint8_t d ) + // this is NOT an operator+= overload because the compiler + // can't usefully decide when it's being passed a 32-bit + // constant (e.g. CRGB::Red) and an 8-bit one (CRGB::Blue) + inline CRGB& subtractFromRGB(uint8_t d ) { r = qsub8( r, d); g = qsub8( g, d); @@ -224,7 +230,7 @@ struct CRGB { // subtract a constant of '1' from each channel, saturating at 0x00 inline CRGB& operator-- () __attribute__((always_inline)) { - *(this) -= 1; + subtractFromRGB(1); return *this; } @@ -239,7 +245,7 @@ struct CRGB { // add a constant of '1' from each channel, saturating at 0xFF inline CRGB& operator++ () __attribute__((always_inline)) { - *(this) += 1; + addToRGB(1); return *this; } |