HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
sfloat_rg32.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2020-2021.
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
9#pragma once
10
11#include "../SIMD/module.hpp"
12#include "../geometry/module.hpp"
13#include "../macros.hpp"
14#include <algorithm>
15
16namespace hi::inline v1 {
17
23 alignas(sizeof(float) * 2)
24 // Red, Green in binary32 (native endian).
26
27public:
28 sfloat_rg32() = default;
29 sfloat_rg32(sfloat_rg32 const &rhs) noexcept = default;
30 sfloat_rg32(sfloat_rg32 &&rhs) noexcept = default;
31 sfloat_rg32 &operator=(sfloat_rg32 const &rhs) noexcept = default;
32 sfloat_rg32 &operator=(sfloat_rg32 &&rhs) noexcept = default;
33
34 constexpr sfloat_rg32(float x, float y) noexcept : v{x, y} {}
35
36 explicit sfloat_rg32(f32x4 const &rhs) noexcept : v{rhs.r(), rhs.g()} {}
37
38 sfloat_rg32 &operator=(f32x4 const &rhs) noexcept
39 {
40 v = {rhs.r(), rhs.g()};
41 return *this;
42 }
43
44 explicit operator f32x4() const noexcept
45 {
46 return f32x4{std::get<0>(v), std::get<1>(v), 0.0f, 0.0f};
47 }
48
49 sfloat_rg32(extent2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
50 sfloat_rg32(scale2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
51 sfloat_rg32(vector2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
52 sfloat_rg32(point2 const &rhs) noexcept : sfloat_rg32{static_cast<f32x4>(rhs)} {}
53
54 [[nodiscard]] friend bool operator==(sfloat_rg32 const &lhs, sfloat_rg32 const &rhs) noexcept = default;
55};
56
57} // namespace hi::inline v1
DOXYGEN BUG.
Definition algorithm.hpp:16
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
A high-level geometric point Part of the high-level vec, point, mat and color types.
Definition point2.hpp:26
2 x float32 pixel format.
Definition sfloat_rg32.hpp:22