summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2013-05-15 11:07:40 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-05-20 12:06:48 +0200
commitf66af39933087ec5d65bf9a0d770a10f676b9cd0 (patch)
tree949aed5c55be184068866028efe70ec6d133e4fb /src/gui/painting
parente63b831bbdee89decbe8c2f06110e8ac56ef9e2b (diff)
Make QRgb-related functions constexpr
Change-Id: I44b2b60e89a3312889101d7e5c305f4f7c18f7ae Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qrgb.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h
index d7a01840e8..3c2bc5b97a 100644
--- a/src/gui/painting/qrgb.h
+++ b/src/gui/painting/qrgb.h
@@ -52,31 +52,31 @@ typedef unsigned int QRgb; // RGB triplet
// non-namespaced Qt global variable
const Q_DECL_UNUSED QRgb RGB_MASK = 0x00ffffff; // masks RGB values
-inline int qRed(QRgb rgb) // get red part of RGB
+inline Q_DECL_CONSTEXPR int qRed(QRgb rgb) // get red part of RGB
{ return ((rgb >> 16) & 0xff); }
-inline int qGreen(QRgb rgb) // get green part of RGB
+inline Q_DECL_CONSTEXPR int qGreen(QRgb rgb) // get green part of RGB
{ return ((rgb >> 8) & 0xff); }
-inline int qBlue(QRgb rgb) // get blue part of RGB
+inline Q_DECL_CONSTEXPR int qBlue(QRgb rgb) // get blue part of RGB
{ return (rgb & 0xff); }
-inline int qAlpha(QRgb rgb) // get alpha part of RGBA
+inline Q_DECL_CONSTEXPR int qAlpha(QRgb rgb) // get alpha part of RGBA
{ return rgb >> 24; }
-inline QRgb qRgb(int r, int g, int b)// set RGB value
+inline Q_DECL_CONSTEXPR QRgb qRgb(int r, int g, int b)// set RGB value
{ return (0xffu << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
-inline QRgb qRgba(int r, int g, int b, int a)// set RGBA value
+inline Q_DECL_CONSTEXPR QRgb qRgba(int r, int g, int b, int a)// set RGBA value
{ return ((a & 0xff) << 24) | ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff); }
-inline int qGray(int r, int g, int b)// convert R,G,B to gray 0..255
+inline Q_DECL_CONSTEXPR int qGray(int r, int g, int b)// convert R,G,B to gray 0..255
{ return (r*11+g*16+b*5)/32; }
-inline int qGray(QRgb rgb) // convert RGB to gray 0..255
+inline Q_DECL_CONSTEXPR int qGray(QRgb rgb) // convert RGB to gray 0..255
{ return qGray(qRed(rgb), qGreen(rgb), qBlue(rgb)); }
-inline bool qIsGray(QRgb rgb)
+inline Q_DECL_CONSTEXPR bool qIsGray(QRgb rgb)
{ return qRed(rgb) == qGreen(rgb) && qRed(rgb) == qBlue(rgb); }
QT_END_NAMESPACE