HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
subpixel_orientation.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2022.
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
8#pragma once
9
10#include "../geometry/module.hpp"
11#include "../utility/module.hpp"
12#include <format>
13
14namespace hi::inline v1 {
15
19 unknown,
20 horizontal_rgb,
21 horizontal_bgr,
22 vertical_rgb,
23 vertical_bgr,
24};
25
26// clang-format off
27constexpr auto subpixel_orientation_metadata = enum_metadata{
28 subpixel_orientation::unknown, "unknown",
29 subpixel_orientation::horizontal_rgb, "horizontal RGB",
30 subpixel_orientation::horizontal_bgr, "horizontal BGR",
31 subpixel_orientation::vertical_rgb, "vertical RGB",
32 subpixel_orientation::vertical_bgr, "vertical BGR",
33};
34// clang-format on
35
38[[nodiscard]] constexpr extent2 sub_pixel_size(subpixel_orientation orientation) noexcept
39{
40 switch (orientation) {
41 case subpixel_orientation::vertical_rgb:
42 case subpixel_orientation::vertical_bgr: return extent2{1.0f, 1.0f / 3.0f};
43 case subpixel_orientation::horizontal_bgr:
44 case subpixel_orientation::horizontal_rgb: return extent2{1.0f / 3.0f, 1.0f};
45 default: return extent2{1.0f, 1.0f};
46 }
47}
48
49} // namespace hi::inline v1
50
51template<typename CharT>
52struct std::formatter<hi::subpixel_orientation, CharT> : std::formatter<std::string_view, CharT> {
53 auto format(hi::subpixel_orientation const &t, auto &fc)
54 {
55 return std::formatter<std::string_view, CharT>::format(hi::subpixel_orientation_metadata[t], fc);
56 }
57};
geo::extent< float, 2 > extent2
A 2D extent.
Definition extent.hpp:502
DOXYGEN BUG.
Definition algorithm.hpp:13
constexpr extent2 sub_pixel_size(subpixel_orientation orientation) noexcept
Get the size of a sub-pixel based on the sub-pixel orientation.
Definition subpixel_orientation.hpp:38
subpixel_orientation
The orientation of the RGB sub-pixels of and LCD/LED panel.
Definition subpixel_orientation.hpp:18
geometry/margins.hpp
Definition cache.hpp:11