From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- dom/canvas/WebGLIpdl.h | 139 ++++++++++++++++++++++++------------------------- 1 file changed, 69 insertions(+), 70 deletions(-) (limited to 'dom/canvas/WebGLIpdl.h') diff --git a/dom/canvas/WebGLIpdl.h b/dom/canvas/WebGLIpdl.h index 748c1a30a6..5a35c05909 100644 --- a/dom/canvas/WebGLIpdl.h +++ b/dom/canvas/WebGLIpdl.h @@ -10,6 +10,7 @@ #include "ipc/EnumSerializer.h" #include "ipc/IPCMessageUtils.h" #include "mozilla/GfxMessageUtils.h" +#include "mozilla/dom/BindingIPCUtils.h" #include "mozilla/ipc/IPDLParamTraits.h" #include "mozilla/ipc/Shmem.h" #include "mozilla/layers/LayersSurfaces.h" @@ -233,6 +234,16 @@ struct ParamTraits : public ContiguousEnumSerializerInclusive< gfxAlphaType, gfxAlphaType::Opaque, gfxAlphaType::NonPremult> {}; +template <> +struct ParamTraits final + : public mozilla::dom::WebIDLEnumSerializer< + mozilla::dom::WebGLPowerPreference> {}; + +template <> +struct ParamTraits final + : public mozilla::dom::WebIDLEnumSerializer< + mozilla::dom::PredefinedColorSpace> {}; + // - // ParamTraits_TiedFields @@ -242,7 +253,7 @@ struct ParamTraits_TiedFields { static void Write(MessageWriter* const writer, const T& in) { const auto& fields = mozilla::TiedFields(in); - MapTuple(fields, [&](const auto& field) { + mozilla::MapTuple(fields, [&](const auto& field) { WriteParam(writer, field); return true; // ignored }); @@ -251,7 +262,7 @@ struct ParamTraits_TiedFields { static bool Read(MessageReader* const reader, T* const out) { const auto& fields = mozilla::TiedFields(*out); bool ok = true; - MapTuple(fields, [&](auto& field) { + mozilla::MapTuple(fields, [&](auto& field) { if (ok) { ok &= ReadParam(reader, &field); } @@ -263,72 +274,17 @@ struct ParamTraits_TiedFields { // - -template -bool ValidateParam(const T& val) { - return ParamTraits::Validate(val); -} - -template -struct ValidatedPlainOldDataSerializer : public PlainOldDataSerializer { - static void Write(MessageWriter* const writer, const T& in) { - MOZ_ASSERT(ValidateParam(in)); - PlainOldDataSerializer::Write(writer, in); - } - - static bool Read(MessageReader* const reader, T* const out) { - if (!PlainOldDataSerializer::Read(reader, out)) return false; - return ValidateParam(*out); - } - - // static bool Validate(const T&) = 0; -}; - -// - - template <> struct ParamTraits final - : public ValidatedPlainOldDataSerializer { - using T = mozilla::webgl::InitContextDesc; - - static bool Validate(const T& val) { - return ValidateParam(val.options) && (val.size.x && val.size.y); - } -}; + : public ParamTraits_TiedFields {}; template <> struct ParamTraits final - : public ValidatedPlainOldDataSerializer { - using T = mozilla::WebGLContextOptions; - - static bool Validate(const T& val) { - bool ok = true; - ok &= ValidateParam(val.powerPreference); - ok &= ValidateParam(val.colorSpace); - return ok; - } -}; - -template <> -struct ParamTraits final - : public ValidatedPlainOldDataSerializer< - mozilla::dom::WebGLPowerPreference> { - using T = mozilla::dom::WebGLPowerPreference; - - static bool Validate(const T& val) { return val <= T::High_performance; } -}; - -template <> -struct ParamTraits final - : public ValidatedPlainOldDataSerializer< - mozilla::dom::PredefinedColorSpace> { - using T = mozilla::dom::PredefinedColorSpace; - - static bool Validate(const T& val) { return val < T::EndGuard_; } -}; + : public ParamTraits_TiedFields {}; template <> struct ParamTraits final - : public PlainOldDataSerializer { + : public ParamTraits_TiedFields { }; // - @@ -340,28 +296,24 @@ struct ParamTraits mozilla::gl::kHighestGLVendor> { }; -template -struct ParamTraits> final - : public PlainOldDataSerializer> {}; +template +struct ParamTraits> final + : public ParamTraits_TiedFields> {}; template <> struct ParamTraits final : public ParamTraits_TiedFields {}; -template <> -struct ParamTraits final - : public PlainOldDataSerializer {}; - template <> struct ParamTraits final - : public PlainOldDataSerializer {}; + : public ParamTraits_TiedFields {}; template <> struct ParamTraits final - : public PlainOldDataSerializer {}; + : public ParamTraits_TiedFields {}; template <> struct ParamTraits final - : public PlainOldDataSerializer {}; + : public ParamTraits_TiedFields {}; // - @@ -569,6 +521,24 @@ struct ParamTraits final { // - +template +struct ParamTraits> final { + using T = std::array; + + static void Write(MessageWriter* const writer, const T& in) { + for (const auto& v : in) { + WriteParam(writer, v); + } + } + + static bool Read(MessageReader* const reader, T* const out) { + for (auto& v : *out) { + if (!ReadParam(reader, &v)) return false; + } + return true; + } +}; + template struct ParamTraits final { using T = U[N]; @@ -639,6 +609,35 @@ struct ParamTraits> final { } }; +// - + +template +struct ParamTraits_IsEnumCase { + using T = TT; + + static void Write(IPC::MessageWriter* const writer, const T& in) { + MOZ_RELEASE_ASSERT(IsEnumCase(in)); + WriteParam(writer, mozilla::UnderlyingValue(in)); + } + + static bool Read(IPC::MessageReader* const reader, T* const out) { + std::underlying_type_t rawVal; + if (!ReadParam(reader, &rawVal)) return false; + *out = static_cast(rawVal); + return IsEnumCase(*out); + } +}; + +// - + +#define USE_IS_ENUM_CASE(T) \ + template <> \ + struct ParamTraits : public ParamTraits_IsEnumCase {}; + +USE_IS_ENUM_CASE(mozilla::webgl::OptionalRenderableFormatBits) + +#undef USE_IS_ENUM_CASE + } // namespace IPC #endif -- cgit v1.2.3