HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sfloat_rg32.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 "../geometry/numeric_array.hpp"
8#include "../geometry/extent.hpp"
9#include "../geometry/scale.hpp"
10#include "../geometry/vector.hpp"
11#include "../geometry/point.hpp"
12#include <algorithm>
13
14namespace tt {
15
17 alignas(sizeof(float) * 2)
18 // Red, Green in binary32 (native endian).
20
21public:
22 sfloat_rg32() = default;
23 sfloat_rg32(sfloat_rg32 const &rhs) noexcept = default;
24 sfloat_rg32(sfloat_rg32 &&rhs) noexcept = default;
25 sfloat_rg32 &operator=(sfloat_rg32 const &rhs) noexcept = default;
26 sfloat_rg32 &operator=(sfloat_rg32 &&rhs) noexcept = default;
27
28 explicit sfloat_rg32(f32x4 const &rhs) noexcept :
29 v{rhs.r(), rhs.g()} {}
30
31 sfloat_rg32 &operator=(f32x4 const &rhs) noexcept
32 {
33 v = {rhs.r(), rhs.g()};
34 return *this;
35 }
36
37 explicit operator f32x4() const noexcept
38 {
39 return f32x4{std::get<0>(v), std::get<1>(v), 0.0f, 0.0f};
40 }
41
42 sfloat_rg32(extent2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
43 sfloat_rg32(scale2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
44 sfloat_rg32(vector2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
45 sfloat_rg32(point2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
46
47 [[nodiscard]] friend bool operator==(sfloat_rg32 const &lhs, sfloat_rg32 const &rhs) noexcept {
48 return lhs.v == rhs.v;
49 }
50 [[nodiscard]] friend bool operator!=(sfloat_rg32 const &lhs, sfloat_rg32 const &rhs) noexcept {
51 return !(lhs == rhs);
52 }
53};
54
55}
Definition sfloat_rg32.hpp:16
Definition scale.hpp:15