| // camera/mojo/gpu/dmabuf.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 CAMERA_MOJO_GPU_DMABUF_MOJOM_H_ |
| #define CAMERA_MOJO_GPU_DMABUF_MOJOM_H_ |
| |
| #include <stdint.h> |
| |
| #include <limits> |
| #include <optional> |
| #include <type_traits> |
| #include <utility> |
| |
| #include "base/types/cxx23_to_underlying.h" |
| #include "mojo/public/cpp/bindings/clone_traits.h" |
| #include "mojo/public/cpp/bindings/equals_traits.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.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 "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
| |
| #include "camera/mojo/gpu/dmabuf.mojom-features.h" |
| #include "camera/mojo/gpu/dmabuf.mojom-shared.h" |
| #include "camera/mojo/gpu/dmabuf.mojom-forward.h" |
| #include <string> |
| #include <vector> |
| |
| #include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
| #include "mojo/public/cpp/bindings/lib/message_size_estimator.h" |
| #include "mojo/public/cpp/bindings/raw_ptr_impl_ref_traits.h" |
| |
| |
| |
| |
| |
| |
| namespace cros::mojom { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| class DmaBufPlane { |
| public: |
| template <typename T> |
| using EnableIfSame = std::enable_if_t<std::is_same<DmaBufPlane, T>::value>; |
| using DataView = DmaBufPlaneDataView; |
| using Data_ = internal::DmaBufPlane_Data; |
| |
| template <typename... Args> |
| static DmaBufPlanePtr New(Args&&... args) { |
| return DmaBufPlanePtr( |
| std::in_place, std::forward<Args>(args)...); |
| } |
| |
| template <typename U> |
| static DmaBufPlanePtr From(const U& u) { |
| return mojo::TypeConverter<DmaBufPlanePtr, U>::Convert(u); |
| } |
| |
| template <typename U> |
| U To() const { |
| return mojo::TypeConverter<U, DmaBufPlane>::Convert(*this); |
| } |
| |
| |
| DmaBufPlane(); |
| |
| DmaBufPlane( |
| ::mojo::ScopedHandle fd_handle, |
| int32_t stride, |
| uint32_t offset, |
| uint32_t size); |
| |
| DmaBufPlane(const DmaBufPlane&) = delete; |
| DmaBufPlane& operator=(const DmaBufPlane&) = delete; |
| |
| ~DmaBufPlane(); |
| |
| // 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 = DmaBufPlanePtr> |
| DmaBufPlanePtr 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, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool Equals(const T& other) const; |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool operator==(const T& rhs) const { return Equals(rhs); } |
| |
| template <typename T, DmaBufPlane::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< |
| DmaBufPlane::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::DmaBufPlane_UnserializedMessageContext< |
| UserType, DmaBufPlane::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<DmaBufPlane::DataView>( |
| message, data, data_num_bytes, output, Validate); |
| } |
| |
| template <typename UserType> |
| static bool Deserialize(const std::vector<uint8_t>& input, |
| UserType* output) { |
| return DmaBufPlane::Deserialize( |
| input.size() == 0 ? nullptr : &input.front(), input.size(), output); |
| } |
| |
| template <typename UserType> |
| static bool DeserializeFromMessage(mojo::Message input, |
| UserType* output) { |
| auto context = input.TakeUnserializedContext< |
| internal::DmaBufPlane_UnserializedMessageContext< |
| UserType, DmaBufPlane::DataView>>(); |
| if (context) { |
| *output = std::move(context->TakeData()); |
| return true; |
| } |
| input.SerializeIfNecessary(); |
| return mojo::internal::DeserializeImpl<DmaBufPlane::DataView>( |
| input, input.payload(), input.payload_num_bytes(), output, Validate); |
| } |
| |
| |
| ::mojo::ScopedHandle fd_handle; |
| |
| int32_t stride; |
| |
| uint32_t offset; |
| |
| uint32_t size; |
| |
| // 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, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool operator<(const T& lhs, const T& rhs); |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool operator<=(const T& lhs, const T& rhs) { |
| return !(rhs < lhs); |
| } |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool operator>(const T& lhs, const T& rhs) { |
| return rhs < lhs; |
| } |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>* = nullptr> |
| bool operator>=(const T& lhs, const T& rhs) { |
| return !(lhs < rhs); |
| } |
| |
| |
| |
| |
| |
| class DmaBufVideoFrame { |
| public: |
| template <typename T> |
| using EnableIfSame = std::enable_if_t<std::is_same<DmaBufVideoFrame, T>::value>; |
| using DataView = DmaBufVideoFrameDataView; |
| using Data_ = internal::DmaBufVideoFrame_Data; |
| |
| template <typename... Args> |
| static DmaBufVideoFramePtr New(Args&&... args) { |
| return DmaBufVideoFramePtr( |
| std::in_place, std::forward<Args>(args)...); |
| } |
| |
| template <typename U> |
| static DmaBufVideoFramePtr From(const U& u) { |
| return mojo::TypeConverter<DmaBufVideoFramePtr, U>::Convert(u); |
| } |
| |
| template <typename U> |
| U To() const { |
| return mojo::TypeConverter<U, DmaBufVideoFrame>::Convert(*this); |
| } |
| |
| |
| DmaBufVideoFrame(); |
| |
| DmaBufVideoFrame( |
| VideoPixelFormat format, |
| uint32_t coded_width, |
| uint32_t coded_height, |
| std::vector<DmaBufPlanePtr> planes); |
| |
| DmaBufVideoFrame( |
| VideoPixelFormat format, |
| uint32_t coded_width, |
| uint32_t coded_height, |
| std::vector<DmaBufPlanePtr> planes, |
| bool has_modifier, |
| uint64_t modifier); |
| |
| DmaBufVideoFrame(const DmaBufVideoFrame&) = delete; |
| DmaBufVideoFrame& operator=(const DmaBufVideoFrame&) = delete; |
| |
| ~DmaBufVideoFrame(); |
| |
| // 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 = DmaBufVideoFramePtr> |
| DmaBufVideoFramePtr 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, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool Equals(const T& other) const; |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool operator==(const T& rhs) const { return Equals(rhs); } |
| |
| template <typename T, DmaBufVideoFrame::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< |
| DmaBufVideoFrame::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::DmaBufVideoFrame_UnserializedMessageContext< |
| UserType, DmaBufVideoFrame::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<DmaBufVideoFrame::DataView>( |
| message, data, data_num_bytes, output, Validate); |
| } |
| |
| template <typename UserType> |
| static bool Deserialize(const std::vector<uint8_t>& input, |
| UserType* output) { |
| return DmaBufVideoFrame::Deserialize( |
| input.size() == 0 ? nullptr : &input.front(), input.size(), output); |
| } |
| |
| template <typename UserType> |
| static bool DeserializeFromMessage(mojo::Message input, |
| UserType* output) { |
| auto context = input.TakeUnserializedContext< |
| internal::DmaBufVideoFrame_UnserializedMessageContext< |
| UserType, DmaBufVideoFrame::DataView>>(); |
| if (context) { |
| *output = std::move(context->TakeData()); |
| return true; |
| } |
| input.SerializeIfNecessary(); |
| return mojo::internal::DeserializeImpl<DmaBufVideoFrame::DataView>( |
| input, input.payload(), input.payload_num_bytes(), output, Validate); |
| } |
| |
| |
| VideoPixelFormat format; |
| |
| uint32_t coded_width; |
| |
| uint32_t coded_height; |
| |
| std::vector<DmaBufPlanePtr> planes; |
| |
| bool has_modifier; |
| |
| uint64_t modifier; |
| |
| // 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, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool operator<(const T& lhs, const T& rhs); |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool operator<=(const T& lhs, const T& rhs) { |
| return !(rhs < lhs); |
| } |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool operator>(const T& lhs, const T& rhs) { |
| return rhs < lhs; |
| } |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>* = nullptr> |
| bool operator>=(const T& lhs, const T& rhs) { |
| return !(lhs < rhs); |
| } |
| |
| template <typename StructPtrType> |
| DmaBufPlanePtr DmaBufPlane::Clone() const { |
| return New( |
| mojo::Clone(fd_handle), |
| mojo::Clone(stride), |
| mojo::Clone(offset), |
| mojo::Clone(size) |
| ); |
| } |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>*> |
| bool DmaBufPlane::Equals(const T& other_struct) const { |
| if (!mojo::Equals(this->fd_handle, other_struct.fd_handle)) |
| return false; |
| if (!mojo::Equals(this->stride, other_struct.stride)) |
| return false; |
| if (!mojo::Equals(this->offset, other_struct.offset)) |
| return false; |
| if (!mojo::Equals(this->size, other_struct.size)) |
| return false; |
| return true; |
| } |
| |
| template <typename T, DmaBufPlane::EnableIfSame<T>*> |
| bool operator<(const T& lhs, const T& rhs) { |
| if (lhs.fd_handle < rhs.fd_handle) |
| return true; |
| if (rhs.fd_handle < lhs.fd_handle) |
| return false; |
| if (lhs.stride < rhs.stride) |
| return true; |
| if (rhs.stride < lhs.stride) |
| return false; |
| if (lhs.offset < rhs.offset) |
| return true; |
| if (rhs.offset < lhs.offset) |
| return false; |
| if (lhs.size < rhs.size) |
| return true; |
| if (rhs.size < lhs.size) |
| return false; |
| return false; |
| } |
| template <typename StructPtrType> |
| DmaBufVideoFramePtr DmaBufVideoFrame::Clone() const { |
| return New( |
| mojo::Clone(format), |
| mojo::Clone(coded_width), |
| mojo::Clone(coded_height), |
| mojo::Clone(planes), |
| mojo::Clone(has_modifier), |
| mojo::Clone(modifier) |
| ); |
| } |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>*> |
| bool DmaBufVideoFrame::Equals(const T& other_struct) const { |
| if (!mojo::Equals(this->format, other_struct.format)) |
| return false; |
| if (!mojo::Equals(this->coded_width, other_struct.coded_width)) |
| return false; |
| if (!mojo::Equals(this->coded_height, other_struct.coded_height)) |
| return false; |
| if (!mojo::Equals(this->planes, other_struct.planes)) |
| return false; |
| if (!mojo::Equals(this->has_modifier, other_struct.has_modifier)) |
| return false; |
| if (!mojo::Equals(this->modifier, other_struct.modifier)) |
| return false; |
| return true; |
| } |
| |
| template <typename T, DmaBufVideoFrame::EnableIfSame<T>*> |
| bool operator<(const T& lhs, const T& rhs) { |
| if (lhs.format < rhs.format) |
| return true; |
| if (rhs.format < lhs.format) |
| return false; |
| if (lhs.coded_width < rhs.coded_width) |
| return true; |
| if (rhs.coded_width < lhs.coded_width) |
| return false; |
| if (lhs.coded_height < rhs.coded_height) |
| return true; |
| if (rhs.coded_height < lhs.coded_height) |
| return false; |
| if (lhs.planes < rhs.planes) |
| return true; |
| if (rhs.planes < lhs.planes) |
| return false; |
| if (lhs.has_modifier < rhs.has_modifier) |
| return true; |
| if (rhs.has_modifier < lhs.has_modifier) |
| return false; |
| if (lhs.modifier < rhs.modifier) |
| return true; |
| if (rhs.modifier < lhs.modifier) |
| return false; |
| return false; |
| } |
| |
| |
| } // cros::mojom |
| |
| namespace mojo { |
| |
| |
| template <> |
| struct StructTraits<::cros::mojom::DmaBufPlane::DataView, |
| ::cros::mojom::DmaBufPlanePtr> { |
| static bool IsNull(const ::cros::mojom::DmaBufPlanePtr& input) { return !input; } |
| static void SetToNull(::cros::mojom::DmaBufPlanePtr* output) { output->reset(); } |
| |
| static decltype(::cros::mojom::DmaBufPlane::fd_handle)& fd_handle( |
| ::cros::mojom::DmaBufPlanePtr& input) { |
| return input->fd_handle; |
| } |
| |
| static decltype(::cros::mojom::DmaBufPlane::stride) stride( |
| const ::cros::mojom::DmaBufPlanePtr& input) { |
| return input->stride; |
| } |
| |
| static decltype(::cros::mojom::DmaBufPlane::offset) offset( |
| const ::cros::mojom::DmaBufPlanePtr& input) { |
| return input->offset; |
| } |
| |
| static decltype(::cros::mojom::DmaBufPlane::size) size( |
| const ::cros::mojom::DmaBufPlanePtr& input) { |
| return input->size; |
| } |
| |
| static bool Read(::cros::mojom::DmaBufPlane::DataView input, ::cros::mojom::DmaBufPlanePtr* output); |
| }; |
| |
| |
| template <> |
| struct StructTraits<::cros::mojom::DmaBufVideoFrame::DataView, |
| ::cros::mojom::DmaBufVideoFramePtr> { |
| static bool IsNull(const ::cros::mojom::DmaBufVideoFramePtr& input) { return !input; } |
| static void SetToNull(::cros::mojom::DmaBufVideoFramePtr* output) { output->reset(); } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::format) format( |
| const ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->format; |
| } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::coded_width) coded_width( |
| const ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->coded_width; |
| } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::coded_height) coded_height( |
| const ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->coded_height; |
| } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::planes)& planes( |
| ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->planes; |
| } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::has_modifier) has_modifier( |
| const ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->has_modifier; |
| } |
| |
| static decltype(::cros::mojom::DmaBufVideoFrame::modifier) modifier( |
| const ::cros::mojom::DmaBufVideoFramePtr& input) { |
| return input->modifier; |
| } |
| |
| static bool Read(::cros::mojom::DmaBufVideoFrame::DataView input, ::cros::mojom::DmaBufVideoFramePtr* output); |
| }; |
| |
| } // namespace mojo |
| |
| #endif // CAMERA_MOJO_GPU_DMABUF_MOJOM_H_ |