Drop transparency support

Supporting transparency is very, very expensive in terms of speed, while the
benefits are marginal at best. Drop support for it for now.

Signed-off-by: Gergely Nagy <kaleidoscope@gergo.csillger.hu>
pull/389/head
Gergely Nagy 7 years ago
parent 72630bd326
commit 4a494c686b

@ -10,7 +10,7 @@
[st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52 [st:experimental]: https://img.shields.io/badge/experimental----black.svg?style=flat&colorA=dfb317&colorB=494e52
A common base for plugins that want to provide themes, or theme-related A common base for plugins that want to provide themes, or theme-related
capabilities, using a 15+1 color palette. In other words, this is for plugin capabilities, using a 16 color palette. In other words, this is for plugin
authors primarily. The primary aim of the plugin is to provide not only a common authors primarily. The primary aim of the plugin is to provide not only a common
palette, but tools that make it easier to use it too. palette, but tools that make it easier to use it too.
@ -112,17 +112,6 @@ The plugin provides the `LEDPaletteTheme` object, which has the following method
> The palette can be set via the `palette` focus command, implemented by the > The palette can be set via the `palette` focus command, implemented by the
> `FOCUS_HOOK_LEDPALETTETHEME` hook explained below. > `FOCUS_HOOK_LEDPALETTETHEME` hook explained below.
### `.transparent_index`
> The plugin supports transparent colors too: by default, the last color (index
> 15) is treated as transparent. If a pixel is found to be transparent,
> `.updateHandler` will not change its color, but leave it as is. This way one
> can create layers of themes, if so desired.
>
> This property can be set to a number between 0 and 15 to make that index
> transparent, or to a number higher than 15 to disable transparency support,
> and gain another color on the palette.
## Focus commands ## Focus commands
The plugin provides a single `Focus` hook, `FOCUS_HOOK_LEDPALETTETHEME`, The plugin provides a single `Focus` hook, `FOCUS_HOOK_LEDPALETTETHEME`,

@ -24,10 +24,6 @@
namespace kaleidoscope { namespace kaleidoscope {
uint16_t LEDPaletteTheme::palette_base_; uint16_t LEDPaletteTheme::palette_base_;
uint8_t LEDPaletteTheme::transparent_index = 15;
LEDPaletteTheme::LEDPaletteTheme(void) {
}
void LEDPaletteTheme::begin(void) { void LEDPaletteTheme::begin(void) {
Kaleidoscope.use(&::EEPROMSettings); Kaleidoscope.use(&::EEPROMSettings);
@ -44,11 +40,7 @@ void LEDPaletteTheme::updateHandler(uint16_t theme_base, uint8_t theme) {
uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); uint16_t map_base = theme_base + (theme * ROWS * COLS / 2);
for (uint16_t pos = 0; pos < ROWS * COLS; pos++) { for (uint16_t pos = 0; pos < ROWS * COLS; pos++) {
cRGB color; cRGB color = lookupColorAtPosition(map_base, pos);
if (!lookupColorAtPosition(map_base, pos, &color))
continue;
::LEDControl.setCrgbAt(pos, color); ::LEDControl.setCrgbAt(pos, color);
} }
} }
@ -57,11 +49,7 @@ void LEDPaletteTheme::refreshAt(uint16_t theme_base, uint8_t theme, byte row, by
uint16_t map_base = theme_base + (theme * ROWS * COLS / 2); uint16_t map_base = theme_base + (theme * ROWS * COLS / 2);
uint16_t pos = KeyboardHardware.getLedIndex(row, col); uint16_t pos = KeyboardHardware.getLedIndex(row, col);
cRGB color; cRGB color = lookupColorAtPosition(map_base, pos);
if (!lookupColorAtPosition(map_base, pos, &color))
return;
::LEDControl.setCrgbAt(pos, color); ::LEDControl.setCrgbAt(pos, color);
} }
@ -78,15 +66,10 @@ const uint8_t LEDPaletteTheme::lookupColorIndexAtPosition(uint16_t map_base, uin
return color_index; return color_index;
} }
const bool LEDPaletteTheme::lookupColorAtPosition(uint16_t map_base, uint16_t position, cRGB *color) { const cRGB LEDPaletteTheme::lookupColorAtPosition(uint16_t map_base, uint16_t position) {
uint8_t color_index = lookupColorIndexAtPosition(map_base, position); uint8_t color_index = lookupColorIndexAtPosition(map_base, position);
if (color_index == transparent_index) return lookupPaletteColor(color_index);
return false;
*color = lookupPaletteColor(color_index);
return true;
} }
const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) { const cRGB LEDPaletteTheme::lookupPaletteColor(uint8_t color_index) {

@ -25,7 +25,7 @@ namespace kaleidoscope {
class LEDPaletteTheme : public KaleidoscopePlugin { class LEDPaletteTheme : public KaleidoscopePlugin {
public: public:
LEDPaletteTheme(void); LEDPaletteTheme(void) {};
void begin(void) final; void begin(void) final;
@ -34,7 +34,7 @@ class LEDPaletteTheme : public KaleidoscopePlugin {
static void refreshAt(uint16_t theme_base, uint8_t theme, byte row, byte col); static void refreshAt(uint16_t theme_base, uint8_t theme, byte row, byte col);
static const uint8_t lookupColorIndexAtPosition(uint16_t theme_base, uint16_t position); static const uint8_t lookupColorIndexAtPosition(uint16_t theme_base, uint16_t position);
static const bool lookupColorAtPosition(uint16_t theme_base, uint16_t position, cRGB *color); static const cRGB lookupColorAtPosition(uint16_t theme_base, uint16_t position);
static void updateColorIndexAtPosition(uint16_t theme_base, uint16_t position, uint8_t color_index); static void updateColorIndexAtPosition(uint16_t theme_base, uint16_t position, uint8_t color_index);
static const cRGB lookupPaletteColor(uint8_t palette_index); static const cRGB lookupPaletteColor(uint8_t palette_index);
@ -43,8 +43,6 @@ class LEDPaletteTheme : public KaleidoscopePlugin {
static bool themeFocusHandler(const char *command, const char *expected_command, static bool themeFocusHandler(const char *command, const char *expected_command,
uint16_t theme_base, uint8_t max_themes); uint16_t theme_base, uint8_t max_themes);
static uint8_t transparent_index;
private: private:
static uint16_t palette_base_; static uint16_t palette_base_;
}; };

Loading…
Cancel
Save