From: Vsevolod Stakhov Date: Fri, 21 May 2021 15:28:26 +0000 (+0100) Subject: [Minor] Css: Allow to convert css color to uint32_t X-Git-Tag: 3.0~379 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=adeb3780e89cc42dd452280428bf46b1a0efc63b;p=thirdparty%2Frspamd.git [Minor] Css: Allow to convert css color to uint32_t --- diff --git a/src/libserver/css/css_value.hxx b/src/libserver/css/css_value.hxx index 4c013124c5..9e192acb6f 100644 --- a/src/libserver/css/css_value.hxx +++ b/src/libserver/css/css_value.hxx @@ -40,6 +40,12 @@ struct alignas(int) css_color { css_color(std::uint8_t _r, std::uint8_t _g, std::uint8_t _b, std::uint8_t _alpha = 255) : r(_r), g(_g), b(_b), alpha(_alpha) {} css_color() = default; + constexpr auto to_number() const -> std::uint32_t { + return (std::uint32_t)alpha << 24 | + (std::uint32_t)r << 16 | + (std::uint32_t)g << 8 | + (std::uint32_t)b << 0; + } friend bool operator==(const css_color& l, const css_color& r) { return (memcmp(&l, &r, sizeof(css_color)) == 0); }