HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sfloat_rgba32.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../numeric_array.hpp"
8#include <immintrin.h>
9#include <emmintrin.h>
10#include <algorithm>
11
12namespace tt {
13
15 // Red, Green, Blue, Alpha in binary32 (native endian).
17
18public:
19 sfloat_rgba32() = default;
20 sfloat_rgba32(sfloat_rgba32 const &rhs) noexcept = default;
21 sfloat_rgba32(sfloat_rgba32 &&rhs) noexcept = default;
22 sfloat_rgba32 &operator=(sfloat_rgba32 const &rhs) noexcept = default;
23 sfloat_rgba32 &operator=(sfloat_rgba32 &&rhs) noexcept = default;
24
25 sfloat_rgba32(f32x4 const &rhs) noexcept : v(static_cast<std::array<float,4>>(rhs)) {
26 }
27
28 sfloat_rgba32 &operator=(f32x4 const &rhs) noexcept {
29 v = static_cast<std::array<float,4>>(rhs);
30 return *this;
31 }
32
33 operator f32x4 () const noexcept {
34 return f32x4{v};
35 }
36
37 sfloat_rgba32(aarect const &rhs) noexcept : sfloat_rgba32(rhs.v) {}
38
39 sfloat_rgba32 &operator=(aarect const &rhs) noexcept {
40 *this = rhs.v;
41 return *this;
42 }
43
44 operator aarect () const noexcept {
45 return aarect::p0p3(f32x4(v));
46 }
47
48 [[nodiscard]] friend bool operator==(sfloat_rgba32 const &lhs, sfloat_rgba32 const &rhs) noexcept {
49 return lhs.v == rhs.v;
50 }
51 [[nodiscard]] friend bool operator!=(sfloat_rgba32 const &lhs, sfloat_rgba32 const &rhs) noexcept {
52 return !(lhs == rhs);
53 }
54};
55
56}
static axis_aligned_rectangle p0p3(numeric_array< float, 4 > const &v) noexcept
Create axis_aligned_rectangle from packed p0p3 coordinates.
Definition aarect.hpp:86
Definition sfloat_rgba32.hpp:14