// services/viz/public/mojom/compositing/tracked_element_rects.mojom.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 SERVICES_VIZ_PUBLIC_MOJOM_COMPOSITING_TRACKED_ELEMENT_RECTS_MOJOM_H_
#define SERVICES_VIZ_PUBLIC_MOJOM_COMPOSITING_TRACKED_ELEMENT_RECTS_MOJOM_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 "services/viz/public/mojom/compositing/tracked_element_rects.mojom-features.h"  // IWYU pragma: export
#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-shared.h"  // IWYU pragma: export
#include "services/viz/public/mojom/compositing/tracked_element_rects.mojom-forward.h"  // IWYU pragma: export
#include "mojo/public/mojom/base/token.mojom.h"
#include "third_party/blink/public/mojom/tokens/tokens.mojom.h"
#include "ui/gfx/geometry/mojom/geometry.mojom.h"
#include <string>
#include <vector>




#include "services/viz/public/cpp/compositing/tracked_element_rects_mojom_traits.h"




namespace viz::mojom {









class  TrackedElementRect {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<TrackedElementRect, T>::value>;
  using DataView = TrackedElementRectDataView;
  using Data_ = internal::TrackedElementRect_Data;

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

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

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


  TrackedElementRect();

  TrackedElementRect(
      const ::base::Token& tracked_element_id,
      const ::gfx::Rect& visible_bounds,
      bool should_add_to_compositor_frame_metadata,
      bool should_exclude_fixed_and_sticky_occlusions,
      const std::optional<::blink::FrameToken>& frame_token,
      const std::optional<::blink::LocalFrameToken>& parent_frame_token);


  ~TrackedElementRect();

  // 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 = TrackedElementRectPtr>
  TrackedElementRectPtr 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, TrackedElementRect::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

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

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

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        TrackedElementRect::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        TrackedElementRect::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::TrackedElementRect_UnserializedMessageContext<
            UserType, TrackedElementRect::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<TrackedElementRect::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return TrackedElementRect::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::TrackedElementRect_UnserializedMessageContext<
            UserType, TrackedElementRect::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<TrackedElementRect::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  ::base::Token tracked_element_id;
  
  ::gfx::Rect visible_bounds;
  
  bool should_add_to_compositor_frame_metadata;
  
  bool should_exclude_fixed_and_sticky_occlusions;
  
  std::optional<::blink::FrameToken> frame_token;
  
  std::optional<::blink::LocalFrameToken> parent_frame_token;

  // 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, TrackedElementRect::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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





class  TrackedElementRects {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<TrackedElementRects, T>::value>;
  using DataView = TrackedElementRectsDataView;
  using Data_ = internal::TrackedElementRects_Data;

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

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

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


  TrackedElementRects();

  explicit TrackedElementRects(
      base::flat_map<int32_t, std::vector<TrackedElementRectPtr>> element_data);

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

  ~TrackedElementRects();

  // 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 = TrackedElementRectsPtr>
  TrackedElementRectsPtr 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, TrackedElementRects::EnableIfSame<T>* = nullptr>
  bool Equals(const T& other) const;

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

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

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

  template <typename UserType>
  static std::vector<uint8_t> Serialize(UserType* input) {
    return mojo::internal::SerializeImpl<
        TrackedElementRects::DataView, std::vector<uint8_t>>(input);
  }

  template <typename UserType>
  static mojo::Message SerializeAsMessage(UserType* input) {
    return mojo::internal::SerializeAsMessageImpl<
        TrackedElementRects::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::TrackedElementRects_UnserializedMessageContext<
            UserType, TrackedElementRects::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<TrackedElementRects::DataView>(
        message, data, data_num_bytes, output, Validate);
  }

  template <typename UserType>
  static bool Deserialize(base::span<const uint8_t> input,
                          UserType* output) {
    return TrackedElementRects::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::TrackedElementRects_UnserializedMessageContext<
            UserType, TrackedElementRects::DataView>>();
    if (context) {
      *output = std::move(context->TakeData());
      return true;
    }
    input.SerializeIfNecessary();
    return mojo::internal::DeserializeImpl<TrackedElementRects::DataView>(
        input, input.payload(), input.payload_num_bytes(), output, Validate);
  }

  
  base::flat_map<int32_t, std::vector<TrackedElementRectPtr>> element_data;

  // 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, TrackedElementRects::EnableIfSame<T>* = nullptr>
bool operator<(const T& lhs, const T& rhs);

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

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

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

template <typename StructPtrType>
TrackedElementRectPtr TrackedElementRect::Clone() const {
  return New(
      mojo::Clone(tracked_element_id),
      mojo::Clone(visible_bounds),
      mojo::Clone(should_add_to_compositor_frame_metadata),
      mojo::Clone(should_exclude_fixed_and_sticky_occlusions),
      mojo::Clone(frame_token),
      mojo::Clone(parent_frame_token)
  );
}

template <typename T, TrackedElementRect::EnableIfSame<T>*>
bool TrackedElementRect::Equals(const T& other_struct) const {
  if (!mojo::Equals(this->tracked_element_id, other_struct.tracked_element_id))
    return false;
  if (!mojo::Equals(this->visible_bounds, other_struct.visible_bounds))
    return false;
  if (!mojo::Equals(this->should_add_to_compositor_frame_metadata, other_struct.should_add_to_compositor_frame_metadata))
    return false;
  if (!mojo::Equals(this->should_exclude_fixed_and_sticky_occlusions, other_struct.should_exclude_fixed_and_sticky_occlusions))
    return false;
  if (!mojo::Equals(this->frame_token, other_struct.frame_token))
    return false;
  if (!mojo::Equals(this->parent_frame_token, other_struct.parent_frame_token))
    return false;
  return true;
}

template <typename T, TrackedElementRect::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.tracked_element_id < rhs.tracked_element_id)
    return true;
  if (rhs.tracked_element_id < lhs.tracked_element_id)
    return false;
  if (lhs.visible_bounds < rhs.visible_bounds)
    return true;
  if (rhs.visible_bounds < lhs.visible_bounds)
    return false;
  if (lhs.should_add_to_compositor_frame_metadata < rhs.should_add_to_compositor_frame_metadata)
    return true;
  if (rhs.should_add_to_compositor_frame_metadata < lhs.should_add_to_compositor_frame_metadata)
    return false;
  if (lhs.should_exclude_fixed_and_sticky_occlusions < rhs.should_exclude_fixed_and_sticky_occlusions)
    return true;
  if (rhs.should_exclude_fixed_and_sticky_occlusions < lhs.should_exclude_fixed_and_sticky_occlusions)
    return false;
  if (lhs.frame_token < rhs.frame_token)
    return true;
  if (rhs.frame_token < lhs.frame_token)
    return false;
  if (lhs.parent_frame_token < rhs.parent_frame_token)
    return true;
  if (rhs.parent_frame_token < lhs.parent_frame_token)
    return false;
  return false;
}
template <typename StructPtrType>
TrackedElementRectsPtr TrackedElementRects::Clone() const {
  return New(
      mojo::Clone(element_data)
  );
}

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

template <typename T, TrackedElementRects::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.element_data < rhs.element_data)
    return true;
  if (rhs.element_data < lhs.element_data)
    return false;
  return false;
}


}  // viz::mojom

namespace mojo {


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

  static const decltype(::viz::mojom::TrackedElementRect::tracked_element_id)& tracked_element_id(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->tracked_element_id;
  }

  static const decltype(::viz::mojom::TrackedElementRect::visible_bounds)& visible_bounds(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->visible_bounds;
  }

  static decltype(::viz::mojom::TrackedElementRect::should_add_to_compositor_frame_metadata) should_add_to_compositor_frame_metadata(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->should_add_to_compositor_frame_metadata;
  }

  static decltype(::viz::mojom::TrackedElementRect::should_exclude_fixed_and_sticky_occlusions) should_exclude_fixed_and_sticky_occlusions(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->should_exclude_fixed_and_sticky_occlusions;
  }

  static const decltype(::viz::mojom::TrackedElementRect::frame_token)& frame_token(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->frame_token;
  }

  static const decltype(::viz::mojom::TrackedElementRect::parent_frame_token)& parent_frame_token(
      const ::viz::mojom::TrackedElementRectPtr& input) {
    return input->parent_frame_token;
  }

  static bool Read(::viz::mojom::TrackedElementRect::DataView input, ::viz::mojom::TrackedElementRectPtr* output);
};


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

  static const decltype(::viz::mojom::TrackedElementRects::element_data)& element_data(
      const ::viz::mojom::TrackedElementRectsPtr& input) {
    return input->element_data;
  }

  static bool Read(::viz::mojom::TrackedElementRects::DataView input, ::viz::mojom::TrackedElementRectsPtr* output);
};

}  // namespace mojo

#endif  // SERVICES_VIZ_PUBLIC_MOJOM_COMPOSITING_TRACKED_ELEMENT_RECTS_MOJOM_H_