From 0a6e2232300ad9874fe5f0284fc4cf6b327bc6bc Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Fri, 21 Jul 2017 14:00:50 +0200 Subject: [PATCH] [kandinsky] Inline KDColor::red, green and blue Change-Id: Ief45fa20155c5857be36e2acd7351dfdf71639cb --- kandinsky/include/kandinsky/color.h | 17 ++++++++++++++--- kandinsky/src/color.cpp | 15 --------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/kandinsky/include/kandinsky/color.h b/kandinsky/include/kandinsky/color.h index 2c65fd1af..b22d5e3b5 100644 --- a/kandinsky/include/kandinsky/color.h +++ b/kandinsky/include/kandinsky/color.h @@ -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: diff --git a/kandinsky/src/color.cpp b/kandinsky/src/color.cpp index 1a44bbeec..b61c45061 100644 --- a/kandinsky/src/color.cpp +++ b/kandinsky/src/color.cpp @@ -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; -}