// ui/gfx/mojom/hdr_metadata.mojom-blink.h is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2013 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_GFX_MOJOM_HDR_METADATA_MOJOM_BLINK_H_
#define UI_GFX_MOJOM_HDR_METADATA_MOJOM_BLINK_H_

#include <stdint.h>

#include <limits>
#include <optional>
#include <type_traits>
#include <utility>
#include "mojo/public/cpp/bindings/clone_traits.h"
#include "mojo/public/cpp/bindings/equals_traits.h"
#include "mojo/public/cpp/bindings/struct_ptr.h"
#include "mojo/public/cpp/bindings/struct_traits.h"
#include "mojo/public/cpp/bindings/union_traits.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"

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

#include "ui/gfx/mojom/hdr_metadata.mojom-features.h"  // IWYU pragma: export
#include "ui/gfx/mojom/hdr_metadata.mojom-shared.h"  // IWYU pragma: export
#include "ui/gfx/mojom/hdr_metadata.mojom-blink-forward.h"  // IWYU pragma: export
#include "skia/public/mojom/hdr_metadata.mojom-blink.h"
#include "skia/public/mojom/skcolorspace_primaries.mojom-blink-forward.h"

#include "mojo/public/cpp/bindings/lib/wtf_clone_equals_util.h"
#include "mojo/public/cpp/bindings/lib/wtf_hash_util.h"
#include "third_party/blink/renderer/platform/wtf/hash_functions.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"




#if !BLINK_MOJO_IMPL && !INSIDE_BLINK
#error "File must only be imported inside blink"
#endif




namespace gfx::mojom::blink {





class  HdrMetadataExtendedRange {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<HdrMetadataExtendedRange, T>::value>;
  using DataView = HdrMetadataExtendedRangeDataView;
  using Data_ = internal::HdrMetadataExtendedRange_Data;

  template <typename... Args>
  static HdrMetadataExtendedRangePtr New(Args&&... args) {
    return HdrMetadataExtendedRangePtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static HdrMetadataExtendedRangePtr From(const U& u) {
    return mojo::TypeConverter<HdrMetadataExtendedRangePtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, HdrMetadataExtendedRange>::Convert(*this);
  }


  HdrMetadataExtendedRange();

  HdrMetadataExtendedRange(
      float current_headroom,
      float desired_headroom);


  ~HdrMetadataExtendedRange();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = HdrMetadataExtendedRangePtr>
  HdrMetadataExtendedRangePtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }
  size_t Hash(size_t seed) const;

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        HdrMetadataExtendedRange::DataView, ::blink::Vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        HdrMetadataExtendedRange::DataView, ::blink::Vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        HdrMetadataExtendedRange::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::HdrMetadataExtendedRange_UnserializedMessageContext<
            UserType, HdrMetadataExtendedRange::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<HdrMetadataExtendedRange::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return HdrMetadataExtendedRange::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::HdrMetadataExtendedRange_UnserializedMessageContext<
            UserType, HdrMetadataExtendedRange::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<HdrMetadataExtendedRange::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  float current_headroom;
  
  float desired_headroom;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}









class  HDRMetadata {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<HDRMetadata, T>::value>;
  using DataView = HDRMetadataDataView;
  using Data_ = internal::HDRMetadata_Data;

  template <typename... Args>
  static HDRMetadataPtr New(Args&&... args) {
    return HDRMetadataPtr(
        std::in_place, std::forward<Args>(args)...);
  }

  template <typename U>
  static HDRMetadataPtr From(const U& u) {
    return mojo::TypeConverter<HDRMetadataPtr, U>::Convert(u);
  }

  template <typename U>
  U To() const {
    return mojo::TypeConverter<U, HDRMetadata>::Convert(*this);
  }


  HDRMetadata();

  HDRMetadata(
      const std::optional<::skhdr::MasteringDisplayColorVolume>& mdcv,
      const std::optional<::skhdr::ContentLightLevelInformation>& clli,
      std::optional<float> ndwl,
      HdrMetadataExtendedRangePtr extended_range,
      const std::optional<::skhdr::AdaptiveGlobalToneMap>& agtm);

HDRMetadata(const HDRMetadata&) = delete;
HDRMetadata& operator=(const HDRMetadata&) = delete;

  ~HDRMetadata();

  // Clone() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Clone() or copy
  // constructor/assignment are available for members.
  template <typename StructPtrType = HDRMetadataPtr>
  HDRMetadataPtr Clone() const;

  // Equals() is a template so it is only instantiated if it is used. Thus, the
  // bindings generator does not need to know whether Equals() or == operator
  // are available for members.
  template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

  template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
  bool operator==(const T& rhs) const { return Equals(rhs); }

  template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
  bool operator!=(const T& rhs) const { return !operator==(rhs); }

  template <mojo::internal::SendValidation send_validation, typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        HDRMetadata::DataView, ::blink::Vector<uint8_t>, send_validation>(input);
  }

  template <typename UserType>
  static ::blink::Vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        HDRMetadata::DataView, ::blink::Vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        HDRMetadata::DataView>(input);
  }

  // The returned Message is serialized only if the message is moved
  // cross-process or cross-language. Otherwise if the message is Deserialized
  // as the same UserType |input| will just be moved to |output| in
  // DeserializeFromMessage.
  template <typename UserType>
  static mojo::Message WrapAsMessage(UserType input) {
    return mojo::Message(std::make_unique<
        internal::HDRMetadata_UnserializedMessageContext<
            UserType, HDRMetadata::DataView>>(0, 0, std::move(input)),
        MOJO_CREATE_MESSAGE_FLAG_NONE);
  }

  template <typename UserType>
  static bool Deserialize(const void* data,
                          size_t data_num_bytes,
                          UserType* output) {
    mojo::Message message;
    return mojo::internal::DeserializeImpl<HDRMetadata::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return HDRMetadata::Deserialize(
        input.empty() ? nullptr : input.data(), input.size(), output);
  }

  template <typename UserType>
  static bool DeserializeFromMessage(mojo::Message input,
                                     UserType* output) {
    auto context = input.TakeUnserializedContext<
        internal::HDRMetadata_UnserializedMessageContext<
            UserType, HDRMetadata::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<HDRMetadata::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  std::optional<::skhdr::MasteringDisplayColorVolume> mdcv;
  
  std::optional<::skhdr::ContentLightLevelInformation> clli;
  
  std::optional<float> ndwl;
  
  HdrMetadataExtendedRangePtr extended_range;
  
  std::optional<::skhdr::AdaptiveGlobalToneMap> agtm;

  // Serialise this struct into a trace.
  void WriteIntoTrace(perfetto::TracedValue traced_context) const;

 private:
  static bool Validate(const void* data,
                       mojo::internal::ValidationContext* validation_context);
};

// The comparison operators are templates, so they are only instantiated if they
// are used. Thus, the bindings generator does not need to know whether
// comparison operators are available for members.
template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
bool operator<=(const T& lhs, const T& rhs) {
  return !(rhs < lhs);
}

template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
bool operator>(const T& lhs, const T& rhs) {
  return rhs < lhs;
}

template <typename T, HDRMetadata::EnableIfSame<T>* = nullptr>
bool operator>=(const T& lhs, const T& rhs) {
  return !(lhs < rhs);
}

template <typename StructPtrType>
HdrMetadataExtendedRangePtr HdrMetadataExtendedRange::Clone() const {
  return New(
      mojo::Clone(current_headroom),
      mojo::Clone(desired_headroom)
  );
}

template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>*>
bool HdrMetadataExtendedRange::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->current_headroom, other_struct.current_headroom))
    return false;
  if (!mojo::Equals(this->desired_headroom, other_struct.desired_headroom))
    return false;
  return true;
}

template <typename T, HdrMetadataExtendedRange::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.current_headroom < rhs.current_headroom)
    return true;
  if (rhs.current_headroom < lhs.current_headroom)
    return false;
  if (lhs.desired_headroom < rhs.desired_headroom)
    return true;
  if (rhs.desired_headroom < lhs.desired_headroom)
    return false;
  return false;
}
template <typename StructPtrType>
HDRMetadataPtr HDRMetadata::Clone() const {
  return New(
      mojo::Clone(mdcv),
      mojo::Clone(clli),
      mojo::Clone(ndwl),
      mojo::Clone(extended_range),
      mojo::Clone(agtm)
  );
}

template <typename T, HDRMetadata::EnableIfSame<T>*>
bool HDRMetadata::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->mdcv, other_struct.mdcv))
    return false;
  if (!mojo::Equals(this->clli, other_struct.clli))
    return false;
  if (!mojo::Equals(this->ndwl, other_struct.ndwl))
    return false;
  if (!mojo::Equals(this->extended_range, other_struct.extended_range))
    return false;
  if (!mojo::Equals(this->agtm, other_struct.agtm))
    return false;
  return true;
}

template <typename T, HDRMetadata::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.mdcv < rhs.mdcv)
    return true;
  if (rhs.mdcv < lhs.mdcv)
    return false;
  if (lhs.clli < rhs.clli)
    return true;
  if (rhs.clli < lhs.clli)
    return false;
  if (lhs.ndwl < rhs.ndwl)
    return true;
  if (rhs.ndwl < lhs.ndwl)
    return false;
  if (lhs.extended_range < rhs.extended_range)
    return true;
  if (rhs.extended_range < lhs.extended_range)
    return false;
  if (lhs.agtm < rhs.agtm)
    return true;
  if (rhs.agtm < lhs.agtm)
    return false;
  return false;
}


}  // gfx::mojom::blink

namespace mojo {


template <>
struct  StructTraits<::gfx::mojom::blink::HdrMetadataExtendedRange::DataView,
                                         ::gfx::mojom::blink::HdrMetadataExtendedRangePtr> {
  static bool IsNull(const ::gfx::mojom::blink::HdrMetadataExtendedRangePtr& input) { return !input; }
  static void SetToNull(::gfx::mojom::blink::HdrMetadataExtendedRangePtr* output) { output->reset(); }

  static decltype(::gfx::mojom::blink::HdrMetadataExtendedRange::current_headroom) current_headroom(
      const ::gfx::mojom::blink::HdrMetadataExtendedRangePtr& input) {
    return input->current_headroom;
  }

  static decltype(::gfx::mojom::blink::HdrMetadataExtendedRange::desired_headroom) desired_headroom(
      const ::gfx::mojom::blink::HdrMetadataExtendedRangePtr& input) {
    return input->desired_headroom;
  }

  static bool Read(::gfx::mojom::blink::HdrMetadataExtendedRange::DataView input, ::gfx::mojom::blink::HdrMetadataExtendedRangePtr* output);
};


template <>
struct  StructTraits<::gfx::mojom::blink::HDRMetadata::DataView,
                                         ::gfx::mojom::blink::HDRMetadataPtr> {
  static bool IsNull(const ::gfx::mojom::blink::HDRMetadataPtr& input) { return !input; }
  static void SetToNull(::gfx::mojom::blink::HDRMetadataPtr* output) { output->reset(); }

  static const decltype(::gfx::mojom::blink::HDRMetadata::mdcv)& mdcv(
      const ::gfx::mojom::blink::HDRMetadataPtr& input) {
    return input->mdcv;
  }

  static const decltype(::gfx::mojom::blink::HDRMetadata::clli)& clli(
      const ::gfx::mojom::blink::HDRMetadataPtr& input) {
    return input->clli;
  }

  static decltype(::gfx::mojom::blink::HDRMetadata::ndwl) ndwl(
      const ::gfx::mojom::blink::HDRMetadataPtr& input) {
    return input->ndwl;
  }

  static const decltype(::gfx::mojom::blink::HDRMetadata::extended_range)& extended_range(
      const ::gfx::mojom::blink::HDRMetadataPtr& input) {
    return input->extended_range;
  }

  static const decltype(::gfx::mojom::blink::HDRMetadata::agtm)& agtm(
      const ::gfx::mojom::blink::HDRMetadataPtr& input) {
    return input->agtm;
  }

  static bool Read(::gfx::mojom::blink::HDRMetadata::DataView input, ::gfx::mojom::blink::HDRMetadataPtr* output);
};

}  // namespace mojo

#endif  // UI_GFX_MOJOM_HDR_METADATA_MOJOM_BLINK_H_