summaryrefslogtreecommitdiff
path: root/include/vcl/salgtype.hxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-03-25 10:38:47 +0100
committerStephan Bergmann <sbergman@redhat.com>2017-03-25 12:51:34 +0000
commitf175ded3aef01cf598a1838cf93b8b3f37b6933c (patch)
tree6b3f8ea8f884e955928b1e50a5faa5628d99d928 /include/vcl/salgtype.hxx
parent4b788a12380518e31a9064d5839f4880d3f36874 (diff)
Replace some macros with constexpr functions
...in preparation of teaching loplugin:redundantcast about C-style casts in macro bodies. TRGB_COLORDATA contained a curious cast to sal_Int32 (instead of sal_uInt32 aka ColorData), but for one that affected (by accident?) only the fist term of the ... | ... | ... | ... expression (so the ultimate expression was of type sal_uInt32), and for another before a83698b980424be214829b3ee7cdbf8d2a778755 "tools: split out color macros into own header" there were two different definitions of TRGB_COLORDATA, and only one casted to sal_Int32 (the other to ColorData). Change-Id: I5bfffe5614d0424202268ef7adaf6a0da61ec30a Reviewed-on: https://gerrit.libreoffice.org/35679 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/vcl/salgtype.hxx')
-rw-r--r--include/vcl/salgtype.hxx6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/vcl/salgtype.hxx b/include/vcl/salgtype.hxx
index b9eb6ae74dcb..df708b4fe196 100644
--- a/include/vcl/salgtype.hxx
+++ b/include/vcl/salgtype.hxx
@@ -33,7 +33,11 @@ enum class DeviceFormat {
};
typedef sal_uInt32 SalColor;
-#define MAKE_SALCOLOR( r, g, b ) ((SalColor)(((sal_uInt32)((sal_uInt8)(b))))|(((sal_uInt32)((sal_uInt8)(g)))<<8)|(((sal_uInt32)((sal_uInt8)(r)))<<16))
+
+constexpr SalColor MAKE_SALCOLOR(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) {
+ return sal_uInt32(b) | (sal_uInt32(g) << 8) | (sal_uInt32(r) << 16);
+}
+
#define SALCOLOR_RED( n ) ((sal_uInt8)((n)>>16))
#define SALCOLOR_GREEN( n ) ((sal_uInt8)(((sal_uInt16)(n)) >> 8))
#define SALCOLOR_BLUE( n ) ((sal_uInt8)(n))