diff options
author | Neil <nyamatongwe@gmail.com> | 2023-04-13 09:21:59 +1000 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2023-04-13 09:21:59 +1000 |
commit | c1ead4a59ead03738610f3285d076bcb3abdd214 (patch) | |
tree | 17fbcfaa6d7a513ea3199eb610ac1a3568450cff | |
parent | c94691510eefa2f74e5f760fa09b51046cea8eab (diff) | |
download | scintilla-mirror-c1ead4a59ead03738610f3285d076bcb3abdd214.tar.gz |
Use & instead of cast to avoid warning in header.
Use named constant for mask that chooses RGB part.
-rw-r--r-- | src/Geometry.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Geometry.h b/src/Geometry.h index 4e4fe95d9..f417caae0 100644 --- a/src/Geometry.h +++ b/src/Geometry.h @@ -172,6 +172,7 @@ PRectangle PixelAlignOutside(const PRectangle &rc, int pixelDivisions) noexcept; */ constexpr const float componentMaximum = 255.0f; class ColourRGBA { + static constexpr int rgbMask = 0xffffff; int co; public: constexpr explicit ColourRGBA(int co_ = 0) noexcept : co(co_) { @@ -190,11 +191,11 @@ public: } static constexpr ColourRGBA FromIpRGB(intptr_t co_) noexcept { - return ColourRGBA(static_cast<int>(co_) | (0xffu << 24)); + return ColourRGBA((co_ & rgbMask) | (0xffu << 24)); } constexpr ColourRGBA WithoutAlpha() const noexcept { - return ColourRGBA(co & 0xffffff); + return ColourRGBA(co & rgbMask); } constexpr ColourRGBA Opaque() const noexcept { @@ -206,7 +207,7 @@ public: } constexpr int OpaqueRGB() const noexcept { - return co & 0xffffff; + return co & rgbMask; } // Red, green and blue values as bytes 0..255 |