// ui/gl/mojom/gl_implementation.mojom-shared.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef UI_GL_MOJOM_GL_IMPLEMENTATION_MOJOM_SHARED_H_
#define UI_GL_MOJOM_GL_IMPLEMENTATION_MOJOM_SHARED_H_

#include <stdint.h>

#include <functional>
#include <iosfwd>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/array_data_view.h"
#include "mojo/public/cpp/bindings/map_data_view.h"
#include "mojo/public/cpp/bindings/string_data_view.h"
#include "mojo/public/cpp/system/message_pipe.h"

#include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h"

#include "ui/gl/mojom/gl_implementation.mojom-shared-internal.h"




#include "ui/gl/mojom/gl_implementation.mojom-data-view.h"  // IWYU pragma: export
#include "base/component_export.h"




namespace std {

template <>
struct hash<::gl::mojom::GLImplementation>
    : public mojo::internal::EnumHashImpl<::gl::mojom::GLImplementation> {};

template <>
struct hash<::gl::mojom::ANGLEImplementation>
    : public mojo::internal::EnumHashImpl<::gl::mojom::ANGLEImplementation> {};

}  // namespace std

namespace mojo {


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::gl::mojom::GLImplementation, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::gl::mojom::GLImplementation, UserType>;

  static void Serialize(UserType input, int32_t* output) {
    *output = static_cast<int32_t>(Traits::ToMojom(input));
  }

  static bool Deserialize(int32_t input, UserType* output) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::gl::mojom::GLImplementation>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::gl::mojom::GLImplementation, UserType> ||
                        HasInfallibleConversion(::gl::mojom::GLImplementation()),
                    "::gl::mojom::GLImplementation does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::gl::mojom::ANGLEImplementation, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = EnumTraits<::gl::mojom::ANGLEImplementation, UserType>;

  static void Serialize(UserType input, int32_t* output) {
    *output = static_cast<int32_t>(Traits::ToMojom(input));
  }

  static bool Deserialize(int32_t input, UserType* output) {
    auto known_value = ::mojo::internal::ToKnownEnumValueHelper(
        static_cast<::gl::mojom::ANGLEImplementation>(input));
    if constexpr (requires {
                    {
                      Traits::FromMojom(known_value)
                    } -> std::same_as<UserType>;
                  }) {
      static_assert(std::same_as<::gl::mojom::ANGLEImplementation, UserType> ||
                        HasInfallibleConversion(::gl::mojom::ANGLEImplementation()),
                    "::gl::mojom::ANGLEImplementation does not have an infallible conversion, "
                    "use an optional return type.");
      *output = Traits::FromMojom(known_value);
      return true;
    } else {
      static_assert(
          requires {
            {
              Traits::FromMojom(known_value)
            } -> std::same_as<std::optional<UserType>>;
          }, "FromMojom must return by value or optional.");
      std::optional<UserType> from_mojom = Traits::FromMojom(known_value);
      if (from_mojom) {
        *output = *from_mojom;
      }
      return from_mojom.has_value();
    }
  }
};

}  // namespace internal


namespace internal {

template <typename MaybeConstUserType>
struct Serializer<::gl::mojom::GLImplementationPartsDataView, MaybeConstUserType> {
  using UserType = typename std::remove_const<MaybeConstUserType>::type;
  using Traits = StructTraits<::gl::mojom::GLImplementationPartsDataView, UserType>;

  static void Serialize(
      MaybeConstUserType& input,
      mojo::internal::MessageFragment<::gl::mojom::internal::GLImplementationParts_Data>& fragment) {
    if (CallIsNullIfExists<Traits>(input))
      return;
    fragment.Allocate();

    
    mojo::internal::Serialize<::gl::mojom::GLImplementation>(
      Traits::gl(input),
      &fragment->gl);

    
    mojo::internal::Serialize<::gl::mojom::ANGLEImplementation>(
      Traits::angle(input),
      &fragment->angle);
  }

  static bool Deserialize(::gl::mojom::internal::GLImplementationParts_Data* input,
                          UserType* output,
                          Message* message) {
    if (!input)
      return CallSetToNullIfExists<Traits>(output);

    ::gl::mojom::GLImplementationPartsDataView data_view(input, message);
    return CallTraitsRead<Traits>(data_view, output);
  }
};

}  // namespace internal

}  // namespace mojo


namespace gl::mojom {




}  // gl::mojom

// Declare TraceFormatTraits for enums, which should be defined in ::perfetto
// namespace.

namespace perfetto {

template <>
struct COMPONENT_EXPORT(GL_MOJOM_SHARED) TraceFormatTraits<::gl::mojom::GLImplementation> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::gl::mojom::GLImplementation value);
};

} // namespace perfetto

namespace perfetto {

template <>
struct COMPONENT_EXPORT(GL_MOJOM_SHARED) TraceFormatTraits<::gl::mojom::ANGLEImplementation> {
 static void WriteIntoTrace(perfetto::TracedValue context, ::gl::mojom::ANGLEImplementation value);
};

} // namespace perfetto

#endif  // UI_GL_MOJOM_GL_IMPLEMENTATION_MOJOM_SHARED_H_