diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-03-25 10:38:47 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-03-25 12:51:34 +0000 |
commit | f175ded3aef01cf598a1838cf93b8b3f37b6933c (patch) | |
tree | 6b3f8ea8f884e955928b1e50a5faa5628d99d928 /include/tools | |
parent | There should be no need to distinguish between I32S and I64S (diff) | |
download | core-f175ded3aef01cf598a1838cf93b8b3f37b6933c.tar.gz core-f175ded3aef01cf598a1838cf93b8b3f37b6933c.zip |
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/tools')
-rw-r--r-- | include/tools/colordata.hxx | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/include/tools/colordata.hxx b/include/tools/colordata.hxx index 1d0fb42b4e39..c303957411df 100644 --- a/include/tools/colordata.hxx +++ b/include/tools/colordata.hxx @@ -24,10 +24,16 @@ // Color types typedef sal_uInt32 ColorData; -#define TRGB_COLORDATA(TRANSPARENCE,RED,GREEN,BLUE) \ - ((sal_Int32)(((sal_uInt32)((sal_uInt8)(BLUE))))|(((sal_uInt32)((sal_uInt8)(GREEN)))<<8)|(((sal_uInt32)((sal_uInt8)(RED)))<<16)|(((sal_uInt32)((sal_uInt8)(TRANSPARENCE)))<<24)) +constexpr ColorData TRGB_COLORDATA( + sal_uInt8 TRANSPARENCE, sal_uInt8 RED, sal_uInt8 GREEN, sal_uInt8 BLUE) +{ + return sal_uInt32(BLUE) | (sal_uInt32(GREEN) << 8) | (sal_uInt32(RED) << 16) + | (sal_uInt32(TRANSPARENCE) << 24); +} -#define RGB_COLORDATA( r,g,b ) ((ColorData)(((sal_uInt32)((sal_uInt8)(b))))|(((sal_uInt32)((sal_uInt8)(g)))<<8)|(((sal_uInt32)((sal_uInt8)(r)))<<16)) +constexpr ColorData RGB_COLORDATA(sal_uInt8 r, sal_uInt8 g, sal_uInt8 b) { + return sal_uInt32(b) | (sal_uInt32(g) << 8) | (sal_uInt32(r) << 16); +} #define COLORDATA_RED( n ) ((sal_uInt8)((n)>>16)) #define COLORDATA_GREEN( n ) ((sal_uInt8)(((sal_uInt16)(n)) >> 8)) |