diff options
Diffstat (limited to 'dom/canvas/WebGLIpdl.h')
-rw-r--r-- | dom/canvas/WebGLIpdl.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/dom/canvas/WebGLIpdl.h b/dom/canvas/WebGLIpdl.h index 45a5c5ad64..4c81393b70 100644 --- a/dom/canvas/WebGLIpdl.h +++ b/dom/canvas/WebGLIpdl.h @@ -18,6 +18,8 @@ #include "TupleUtils.h" #include "WebGLTypes.h" +#include <memory> + namespace mozilla { namespace webgl { @@ -652,6 +654,32 @@ struct ParamTraits<mozilla::avec3<U>> final { } }; +// - + +template <class U> +struct ParamTraits<std::optional<U>> final { + using T = std::optional<U>; + + static void Write(MessageWriter* const writer, const T& in) { + WriteParam(writer, bool{in}); + if (in) { + WriteParam(writer, *in); + } + } + + static bool Read(MessageReader* const reader, T* const out) { + bool isSome; + if (!ReadParam(reader, &isSome)) return false; + + if (!isSome) { + out->reset(); + return true; + } + out->emplace(); + return ReadParam(reader, &**out); + } +}; + } // namespace IPC #endif |