[kandinsky] Inline KDColor::red, green and blue

Change-Id: Ief45fa20155c5857be36e2acd7351dfdf71639cb
This commit is contained in:
Romain Goyet
2017-07-21 14:00:50 +02:00
parent 42123dd03d
commit 0a6e223230
2 changed files with 14 additions and 18 deletions

View File

@@ -16,10 +16,21 @@ public:
static constexpr KDColor RGB888(uint8_t r, uint8_t g, uint8_t b) {
return KDColor((r>>3)<<11 | (g>>2) << 5 | (b>>3));
}
uint8_t red() const {
uint8_t r5 = (m_value>>11)&0x1F;
return r5 << 3;
}
uint8_t green() const {
uint8_t g6 = (m_value>>5)&0x3F;
return g6 << 2;
}
uint8_t blue() const {
uint8_t b5 = m_value&0x1F;
return b5 << 3;
}
uint8_t red();
uint8_t green();
uint8_t blue();
static KDColor blend(KDColor first, KDColor second, uint8_t alpha);
operator uint16_t() const { return m_value; }
private:

View File

@@ -26,18 +26,3 @@ KDColor KDColor::blend(KDColor first, KDColor second, uint8_t alpha) {
// white.red() = 0x1F << 3 = 0xF8
// white.red() * 0xFF = 0xF708, we wanted 0xF800
}
uint8_t KDColor::red() {
uint8_t r5 = (m_value>>11)&0x1F;
return r5 << 3;
}
uint8_t KDColor::green() {
uint8_t g6 = (m_value>>5)&0x3F;
return g6 << 2;
}
uint8_t KDColor::blue() {
uint8_t b5 = m_value&0x1F;
return b5 << 3;
}