11#ifndef GAMP_WT_CAPABILITIES_HPP_
12#define GAMP_WT_CAPABILITIES_HPP_
48 constexpr static std::string_view
na_str =
"----";
58 bool m_backgroundOpaque =
true;
60 int m_xparentValueRed = 0;
61 int m_xparentValueGreen = 0;
62 int m_xparentValueBlue = 0;
63 int m_xparentValueAlpha = 0;
66 bool m_onscreen =
true;
69 bool m_isBitmap =
false;
88 size_t hash = 31U + m_redBits;
89 hash = ((hash << 5) - hash) + (m_onscreen ? 1U : 0U);
90 hash = ((hash << 5) - hash) + (m_isBitmap ? 1U : 0U);
91 hash = ((hash << 5) - hash) + m_greenBits;
92 hash = ((hash << 5) - hash) + m_blueBits;
93 hash = ((hash << 5) - hash) + m_alphaBits;
94 hash = ((hash << 5) - hash) + (m_backgroundOpaque ? 1U : 0U);
95 hash = ((hash << 5) - hash) + m_xparentValueRed;
96 hash = ((hash << 5) - hash) + m_xparentValueGreen;
97 hash = ((hash << 5) - hash) + m_xparentValueBlue;
98 hash = ((hash << 5) - hash) + m_xparentValueAlpha;
112 const int id_o = rhs.visualID();
117 bool res = rhs.redBits() == m_redBits &&
118 rhs.greenBits() == m_greenBits &&
119 rhs.blueBits() == m_blueBits &&
120 rhs.alphaBits() == m_alphaBits &&
121 rhs.isBackgroundOpaque() == m_backgroundOpaque &&
122 rhs.isOnscreen() == m_onscreen &&
123 rhs.isBitmap() == m_isBitmap;
124 if( res && !m_backgroundOpaque ) {
125 res = rhs.transparentRedValue() == m_xparentValueRed &&
126 rhs.transparentGreenValue() == m_xparentValueGreen &&
127 rhs.transparentBlueValue() == m_xparentValueBlue &&
128 rhs.transparentAlphaValue() == m_xparentValueAlpha;
149 const int rgba = m_redBits * m_greenBits * m_blueBits * (m_alphaBits + 1);
150 const int xrgba = rhs.redBits() * rhs.greenBits() * rhs.blueBits() * (rhs.alphaBits() + 1);
153 }
else if( rgba < xrgba ) {
161 return 0 == r ? std::strong_ordering::equal : (0 > r ? std::strong_ordering::less : std::strong_ordering::greater);
164 constexpr int visualID() const noexcept {
return m_vid; }
166 constexpr int redBits() const noexcept {
return m_redBits; }
168 constexpr int greenBits() const noexcept {
return m_greenBits; }
170 constexpr int blueBits() const noexcept {
return m_blueBits; }
172 constexpr int alphaBits() const noexcept {
return m_alphaBits; }
174 constexpr int&
visualID() noexcept {
return m_vid; }
177 constexpr int&
redBits() noexcept {
return m_redBits; }
180 constexpr int&
greenBits() noexcept {
return m_greenBits; }
183 constexpr int&
blueBits() noexcept {
return m_blueBits; }
194 constexpr int&
alphaBits() noexcept {
return m_alphaBits; }
212 m_backgroundOpaque = opaque;
251 constexpr bool isOnscreen() const noexcept {
return m_onscreen; }
281 constexpr bool isBitmap() const noexcept {
return m_isBitmap; }
335 std::string msg(
"Caps[");
337 return msg.append(
"]");
342 constexpr static std::string_view
ESEP =
"/";
344 constexpr static std::string_view
CSEP =
", ";
346 void toString(std::string& sink,
bool withOnOffScreen)
const {
347 sink.append(
"rgba ").append(std::to_string(m_redBits)).append(
ESEP).append(std::to_string(m_greenBits)).append(
ESEP)
348 .append(std::to_string(m_blueBits)).append(
ESEP).append(std::to_string(m_alphaBits));
349 if (m_backgroundOpaque) {
350 sink.append(
", opaque");
355 if (withOnOffScreen) {
358 sink.append(
"on-scr");
360 sink.append(
"offscr[");
363 sink.append(
"bitmap");
364 }
else if (m_onscreen) {
367 sink.append(
"auto-cfg");
385 struct hash<
gamp::wt::Capabilities> {
387 return a.hash_code();
Specifies a set of capabilities that a window's rendering context must support, such as color depth p...
constexpr void setBitmap(bool enable) noexcept
Requesting offscreen bitmap mode.
constexpr int & transparentGreenValue() noexcept
Allows setting the transparent green value for the frame buffer configuration, ranging from 0 to the ...
constexpr int transparentBlueValue() const noexcept
Gets the transparent blue value for the frame buffer configuration.
constexpr int redBits() const noexcept
Returns the number of bits for the color buffer's red component.
constexpr int & transparentRedValue() noexcept
Allows setting the transparent red value for the frame buffer configuration, ranging from 0 to the ma...
static constexpr std::string_view ESEP
Element separator.
constexpr bool isOnscreen() const noexcept
Returns whether an on- or offscreen surface is requested, available or chosen.
constexpr int & blueBits() noexcept
Returns the reference to the number of bits for the color buffer's blue component.
constexpr int & visualID() noexcept
constexpr int & transparentAlphaValue() noexcept
Allows setting the transparent alpha value for the frame buffer configuration, ranging from 0 to the ...
constexpr int greenBits() const noexcept
Returns the number of bits for the color buffer's green component.
constexpr int visualID() const noexcept
constexpr int transparentRedValue() const noexcept
Gets the transparent red value for the frame buffer configuration.
constexpr int transparentAlphaValue() const noexcept
Gets the transparent alpha value for the frame buffer configuration.
std::strong_ordering operator<=>(const Capabilities &rhs) const noexcept
constexpr bool isBitmap() const noexcept
Returns whether bitmap offscreen mode is requested, available or chosen.
virtual int compare(const Capabilities &rhs) const noexcept
Comparing RGBA values only.
constexpr int & greenBits() noexcept
Returns the reference to the number of bits for the color buffer's green component.
void toString(std::string &sink, bool withOnOffScreen) const
static constexpr std::string_view CSEP
Component separator.
constexpr int blueBits() const noexcept
Returns the number of bits for the color buffer's blue component.
virtual std::size_t hash_code() const noexcept
constexpr void setBackgroundOpaque(bool opaque) noexcept
Sets whether the surface shall be opaque or translucent.
constexpr int & redBits() noexcept
Returns the reference to the number of bits for the color buffer's red component.
static constexpr std::string_view na_str
constexpr void setOnscreen(bool v) noexcept
Sets whether the surface shall be on- or offscreen.
constexpr int & alphaBits() noexcept
Returns the reference to the number of bits for the color buffer's blue component.
virtual std::string toString() const
Returns a textual representation of this Capabilities object.
virtual CapabilitiesPtr clone() const noexcept
constexpr int & transparentBlueValue() noexcept
Allows setting the transparent blue value for the frame buffer configuration, ranging from 0 to the m...
constexpr int alphaBits() const noexcept
Returns the number of bits for the color buffer's alpha component.
virtual const jau::type_info & signature() const noexcept
virtual bool operator==(const Capabilities &rhs) const noexcept
constexpr bool isBackgroundOpaque() const noexcept
Returns whether an opaque or translucent surface is requested, supported or chosen.
constexpr Capabilities() noexcept=default
Creates a Capabilities object.
constexpr int transparentGreenValue() const noexcept
Gets the transparent green value for the frame buffer configuration.
const jau::type_info & static_ctti() noexcept
Returns a static global reference of make_ctti<T>(true) w/ identity instance.
std::unique_ptr< Capabilities > CapabilitiesPtr
std::string toHexString(const void *data, const nsize_t length, const lb_endian_t byteOrder=lb_endian_t::big, const LoUpCase capitalization=LoUpCase::lower, const PrefixOpt prefix=PrefixOpt::prefix) noexcept
Produce a hexadecimal string representation of the given lsb-first byte values.
Gamp: Graphics, Audio, Multimedia and Processing Framework (Native C++, WebAssembly,...
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
std::size_t operator()(gamp::wt::Capabilities const &a) const noexcept