diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /dom/canvas/WebGLTypes.h | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/canvas/WebGLTypes.h')
-rw-r--r-- | dom/canvas/WebGLTypes.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/dom/canvas/WebGLTypes.h b/dom/canvas/WebGLTypes.h index c268047930..f5f78e98cb 100644 --- a/dom/canvas/WebGLTypes.h +++ b/dom/canvas/WebGLTypes.h @@ -1224,6 +1224,15 @@ inline bool StartsWith(const std::string_view str, // - +template <class T> +Maybe<T> AsValidEnum(const std::underlying_type_t<T> raw_val) { + const auto raw_enum = T{raw_val}; // This is the risk we prevent! + if (!IsEnumCase(raw_enum)) return {}; + return Some(raw_enum); +} + +// - + namespace webgl { // In theory, this number can be unbounded based on the driver. However, no @@ -1302,6 +1311,50 @@ struct ReinterpretToSpan { } }; +// - + +inline std::string Join(Span<const std::string> ss, + const std::string_view& delim) { + if (!ss.size()) return ""; + auto ret = std::string(); + { + auto chars = delim.size() * (ss.size() - 1); + for (const auto& s : ss) { + chars += s.size(); + } + ret.reserve(chars); + } + + ret = ss[0]; + ss = ss.subspan(1); + for (const auto& s : ss) { + ret += delim; + ret += s; + } + return ret; +} + +inline std::string ToStringWithCommas(uint64_t v) { + if (!v) return "0"; + std::vector<std::string> chunks; + while (v) { + const auto chunk = v % 1000; + v /= 1000; + chunks.insert(chunks.begin(), std::to_string(chunk)); + } + return Join(chunks, ","); +} + +// - + +namespace webgl { + +std::unordered_map<GLenum, bool> MakeIsEnabledMap(bool webgl2); + +static constexpr uint32_t kMaxClientWaitSyncTimeoutNS = + 1000 * 1000 * 1000; // 1000ms in ns. + +} // namespace webgl } // namespace mozilla #endif |