diff options
author | Tilo Nitzsche <tricorus@yahoo.com> | 2015-11-23 19:28:25 +0100 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-11-24 05:28:21 +0000 |
commit | 837b5d458970f3981859cb9dfa0cec5fcd6d0c4f (patch) | |
tree | 363085cb47c6034c3579f39938ad253d818a13f5 /src/gui | |
parent | 5b62a5e7aabcc818408f2fe28b9760082f474def (diff) |
Fix undefined behavior in qRgba().
Shifting a signed integer that overflows is undefined behavior. All
masks were changed to unsigned in qRgb and qRgba. While the alpha value
is enough to fix the undefined behavior, Visual C++ generates slow
code if not all of those constants are unsigned.
Change-Id: Ia0ec3e9464088495173b4ad9c2e37a49e6f8e987
Task-number: QTBUG-49595
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/painting/qrgb.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/painting/qrgb.h b/src/gui/painting/qrgb.h index f7f2185bef..ca9fc03d14 100644 --- a/src/gui/painting/qrgb.h +++ b/src/gui/painting/qrgb.h @@ -58,10 +58,10 @@ inline Q_DECL_CONSTEXPR int qAlpha(QRgb rgb) // get alpha part of { return rgb >> 24; } 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); } +{ return (0xffu << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); } 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); } +{ return ((a & 0xffu) << 24) | ((r & 0xffu) << 16) | ((g & 0xffu) << 8) | (b & 0xffu); } 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; } |