// ui/base/cursor/mojom/cursor.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_BASE_CURSOR_MOJOM_CURSOR_MOJOM_BLINK_H_
#define UI_BASE_CURSOR_MOJOM_CURSOR_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/base/cursor/mojom/cursor.mojom-features.h"  // IWYU pragma: export
#include "ui/base/cursor/mojom/cursor.mojom-shared.h"  // IWYU pragma: export
#include "ui/base/cursor/mojom/cursor.mojom-blink-forward.h"  // IWYU pragma: export
#include "skia/public/mojom/bitmap.mojom-blink.h"
#include "ui/base/cursor/mojom/cursor_type.mojom-blink-forward.h"
#include "ui/gfx/geometry/mojom/geometry.mojom-blink.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"

#include "mojo/public/cpp/bindings/lib/control_message_handler.h"
#include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h"


#include "ui/base/cursor/mojom/cursor_mojom_traits.h"
#if !BLINK_MOJO_IMPL && !INSIDE_BLINK
#error "File must only be imported inside blink"
#endif




namespace ui::mojom::blink {








class  Cursor {
 public:
  template <typename T>
  using EnableIfSame = std::enable_if_t<std::is_same<Cursor, T>::value>;
  using DataView = CursorDataView;
  using Data_ = internal::Cursor_Data;

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

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

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


  Cursor();

  Cursor(
      ::ui::mojom::blink::CursorType type,
      const ::gfx::Point& hotspot,
      const ::SkBitmap& bitmap,
      float image_scale_factor);


  ~Cursor();

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

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

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

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

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

  
  ::ui::mojom::blink::CursorType type;
  
  ::gfx::Point hotspot;
  
  ::SkBitmap bitmap;
  
  float image_scale_factor;

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

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

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

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

template <typename StructPtrType>
CursorPtr Cursor::Clone() const {
  return New(
      mojo::Clone(type),
      mojo::Clone(hotspot),
      mojo::Clone(bitmap),
      mojo::Clone(image_scale_factor)
  );
}

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

template <typename T, Cursor::EnableIfSame<T>*>
bool operator<(const T& lhs, const T& rhs) {
  if (lhs.type < rhs.type)
    return true;
  if (rhs.type < lhs.type)
    return false;
  if (lhs.hotspot < rhs.hotspot)
    return true;
  if (rhs.hotspot < lhs.hotspot)
    return false;
  if (lhs.bitmap < rhs.bitmap)
    return true;
  if (rhs.bitmap < lhs.bitmap)
    return false;
  if (lhs.image_scale_factor < rhs.image_scale_factor)
    return true;
  if (rhs.image_scale_factor < lhs.image_scale_factor)
    return false;
  return false;
}


}  // ui::mojom::blink

namespace mojo {


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

  static decltype(::ui::mojom::blink::Cursor::type) type(
      const ::ui::mojom::blink::CursorPtr& input) {
    return input->type;
  }

  static const decltype(::ui::mojom::blink::Cursor::hotspot)& hotspot(
      const ::ui::mojom::blink::CursorPtr& input) {
    return input->hotspot;
  }

  static  decltype(::ui::mojom::blink::Cursor::bitmap)& bitmap(
       ::ui::mojom::blink::CursorPtr& input) {
    return input->bitmap;
  }

  static decltype(::ui::mojom::blink::Cursor::image_scale_factor) image_scale_factor(
      const ::ui::mojom::blink::CursorPtr& input) {
    return input->image_scale_factor;
  }

  static bool Read(::ui::mojom::blink::Cursor::DataView input, ::ui::mojom::blink::CursorPtr* output);
};

}  // namespace mojo

#endif  // UI_BASE_CURSOR_MOJOM_CURSOR_MOJOM_BLINK_H_