aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2023-04-13 09:21:59 +1000
committerNeil <nyamatongwe@gmail.com>2023-04-13 09:21:59 +1000
commitc1ead4a59ead03738610f3285d076bcb3abdd214 (patch)
tree17fbcfaa6d7a513ea3199eb610ac1a3568450cff
parentc94691510eefa2f74e5f760fa09b51046cea8eab (diff)
downloadscintilla-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.h7
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