mirror of
https://github.com/esphome/esphome.git
synced 2026-02-28 01:44:20 -07:00
[display] Make COLOR_OFF and COLOR_ON inline constexpr
Convert COLOR_OFF and COLOR_ON from extern const to inline constexpr. The Color class already has constexpr constructors so these can be compile-time constants, allowing the compiler to optimize default parameter values and eliminate the runtime storage.
This commit is contained in:
@@ -9,8 +9,7 @@ namespace esphome {
|
||||
namespace display {
|
||||
static const char *const TAG = "display";
|
||||
|
||||
const Color COLOR_OFF(0, 0, 0, 0);
|
||||
const Color COLOR_ON(255, 255, 255, 255);
|
||||
// COLOR_OFF and COLOR_ON are now inline constexpr in display.h
|
||||
|
||||
void Display::fill(Color color) { this->filled_rectangle(0, 0, this->get_width(), this->get_height(), color); }
|
||||
void Display::clear() { this->fill(COLOR_OFF); }
|
||||
|
||||
@@ -298,9 +298,9 @@ using display_writer_t = DisplayWriter<Display>;
|
||||
}
|
||||
|
||||
/// Turn the pixel OFF.
|
||||
extern const Color COLOR_OFF;
|
||||
inline constexpr Color COLOR_OFF(0, 0, 0, 0);
|
||||
/// Turn the pixel ON.
|
||||
extern const Color COLOR_ON;
|
||||
inline constexpr Color COLOR_ON(255, 255, 255, 255);
|
||||
|
||||
class BaseImage {
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user