| // camera/mojo/camera_features.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 CAMERA_MOJO_CAMERA_FEATURES_MOJOM_SHARED_H_ |
| #define CAMERA_MOJO_CAMERA_FEATURES_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/enum_traits.h" |
| #include "mojo/public/cpp/bindings/interface_data_view.h" |
| #include "mojo/public/cpp/bindings/lib/bindings_internal.h" |
| #include "mojo/public/cpp/bindings/lib/serialization.h" |
| #include "mojo/public/cpp/bindings/map_data_view.h" |
| #include "mojo/public/cpp/bindings/string_data_view.h" |
| |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value_forward.h" |
| |
| #include "camera/mojo/camera_features.mojom-shared-internal.h" |
| |
| |
| |
| |
| |
| |
| |
| namespace cros::mojom { |
| class PortraitModeConfigDataView; |
| |
| class Camera3StreamEffectDataView; |
| |
| |
| } // cros::mojom |
| |
| namespace mojo { |
| namespace internal { |
| |
| template <> |
| struct MojomTypeTraits<::cros::mojom::PortraitModeConfigDataView> { |
| using Data = ::cros::mojom::internal::PortraitModeConfig_Data; |
| using DataAsArrayElement = Pointer<Data>; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kStruct; |
| }; |
| |
| template <> |
| struct MojomTypeTraits<::cros::mojom::Camera3StreamEffectDataView> { |
| using Data = ::cros::mojom::internal::Camera3StreamEffect_Data; |
| using DataAsArrayElement = Data; |
| static constexpr MojomTypeCategory category = MojomTypeCategory::kUnion; |
| }; |
| |
| } // namespace internal |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| |
| enum class PortraitModeSegResult : int32_t { |
| |
| kSuccess = 0, |
| |
| kFailure = 1, |
| |
| kTimeout = 2, |
| |
| kNoFaces = 3, |
| |
| kUnknown = 4, |
| kMinValue = 0, |
| kMaxValue = 4, |
| }; |
| |
| std::ostream& operator<<(std::ostream& os, PortraitModeSegResult value); |
| inline bool IsKnownEnumValue(PortraitModeSegResult value) { |
| return internal::PortraitModeSegResult_Data::IsKnownValue( |
| static_cast<int32_t>(value)); |
| } |
| |
| |
| class PortraitModeConfigDataView { |
| public: |
| PortraitModeConfigDataView() = default; |
| |
| PortraitModeConfigDataView( |
| internal::PortraitModeConfig_Data* data, |
| mojo::Message* message) |
| : data_(data) {} |
| |
| bool is_null() const { return !data_; } |
| bool enable_rectiface() const { |
| return data_->enable_rectiface; |
| } |
| private: |
| internal::PortraitModeConfig_Data* data_ = nullptr; |
| }; |
| |
| |
| class Camera3StreamEffectDataView { |
| public: |
| using Tag = internal::Camera3StreamEffect_Data::Camera3StreamEffect_Tag; |
| |
| Camera3StreamEffectDataView() = default; |
| |
| Camera3StreamEffectDataView( |
| internal::Camera3StreamEffect_Data* data, |
| mojo::Message* message) |
| : data_(data), message_(message) {} |
| |
| bool is_null() const { |
| // For inlined unions, |data_| is always non-null. In that case we need to |
| // check |data_->is_null()|. |
| return !data_ || data_->is_null(); |
| } |
| |
| Tag tag() const { return data_->tag; } |
| bool is_unknown_config() const { return data_->tag == Tag::kUnknownConfig; } |
| uint8_t unknown_config() const { |
| CHECK(is_unknown_config()); |
| return data_->data.f_unknown_config; |
| } |
| bool is_portrait_mode_config() const { return data_->tag == Tag::kPortraitModeConfig; } |
| inline void GetPortraitModeConfigDataView( |
| PortraitModeConfigDataView* output) const; |
| |
| template <typename UserType> |
| [[nodiscard]] bool ReadPortraitModeConfig(UserType* output) const { |
| |
| CHECK(is_portrait_mode_config()); |
| return mojo::internal::Deserialize<::cros::mojom::PortraitModeConfigDataView>( |
| data_->data.f_portrait_mode_config.Get(), output, message_); |
| } |
| |
| private: |
| internal::Camera3StreamEffect_Data* data_ = nullptr; |
| mojo::Message* message_ = nullptr; |
| }; |
| |
| |
| |
| } // cros::mojom |
| |
| namespace std { |
| |
| template <> |
| struct hash<::cros::mojom::PortraitModeSegResult> |
| : public mojo::internal::EnumHashImpl<::cros::mojom::PortraitModeSegResult> {}; |
| |
| } // namespace std |
| |
| namespace mojo { |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::PortraitModeSegResult, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = EnumTraits<::cros::mojom::PortraitModeSegResult, 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) { |
| return Traits::FromMojom(::mojo::internal::ToKnownEnumValueHelper( |
| static_cast<::cros::mojom::PortraitModeSegResult>(input)), output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::PortraitModeConfigDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = StructTraits<::cros::mojom::PortraitModeConfigDataView, UserType>; |
| |
| static void Serialize( |
| MaybeConstUserType& input, |
| mojo::internal::MessageFragment<::cros::mojom::internal::PortraitModeConfig_Data>& fragment) { |
| if (CallIsNullIfExists<Traits>(input)) |
| return; |
| fragment.Allocate(); |
| fragment->enable_rectiface = Traits::enable_rectiface(input); |
| } |
| |
| static bool Deserialize(::cros::mojom::internal::PortraitModeConfig_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::cros::mojom::PortraitModeConfigDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| |
| namespace internal { |
| |
| template <typename MaybeConstUserType> |
| struct Serializer<::cros::mojom::Camera3StreamEffectDataView, MaybeConstUserType> { |
| using UserType = typename std::remove_const<MaybeConstUserType>::type; |
| using Traits = UnionTraits<::cros::mojom::Camera3StreamEffectDataView, UserType>; |
| |
| static void Serialize(MaybeConstUserType& input, |
| MessageFragment<::cros::mojom::internal::Camera3StreamEffect_Data>& fragment, |
| bool inlined) { |
| if (CallIsNullIfExists<Traits>(input)) { |
| if (inlined) |
| fragment->set_null(); |
| return; |
| } |
| |
| if (!inlined) |
| fragment.Allocate(); |
| |
| // TODO(azani): Handle unknown and objects. |
| // Set the not-null flag. |
| fragment->size = kUnionDataSize; |
| fragment->tag = Traits::GetTag(input); |
| switch (fragment->tag) { |
| case ::cros::mojom::Camera3StreamEffectDataView::Tag::kUnknownConfig: { |
| decltype(Traits::unknown_config(input)) |
| in_unknown_config = Traits::unknown_config(input); |
| fragment->data.f_unknown_config = in_unknown_config; |
| break; |
| } |
| case ::cros::mojom::Camera3StreamEffectDataView::Tag::kPortraitModeConfig: { |
| decltype(Traits::portrait_mode_config(input)) |
| in_portrait_mode_config = Traits::portrait_mode_config(input); |
| mojo::internal::MessageFragment< |
| typename decltype(fragment->data.f_portrait_mode_config)::BaseType> |
| value_fragment(fragment.message()); |
| mojo::internal::Serialize<::cros::mojom::PortraitModeConfigDataView>( |
| in_portrait_mode_config, value_fragment); |
| MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
| value_fragment.is_null(), |
| mojo::internal::VALIDATION_ERROR_UNEXPECTED_NULL_POINTER, |
| "null portrait_mode_config in Camera3StreamEffect union"); |
| fragment->data.f_portrait_mode_config.Set( |
| value_fragment.is_null() ? nullptr : value_fragment.data()); |
| break; |
| } |
| } |
| } |
| |
| static bool Deserialize(::cros::mojom::internal::Camera3StreamEffect_Data* input, |
| UserType* output, |
| Message* message) { |
| if (!input || input->is_null()) |
| return CallSetToNullIfExists<Traits>(output); |
| |
| ::cros::mojom::Camera3StreamEffectDataView data_view(input, message); |
| return Traits::Read(data_view, output); |
| } |
| }; |
| |
| } // namespace internal |
| |
| } // namespace mojo |
| |
| |
| namespace cros::mojom { |
| |
| |
| |
| inline void Camera3StreamEffectDataView::GetPortraitModeConfigDataView( |
| PortraitModeConfigDataView* output) const { |
| CHECK(is_portrait_mode_config()); |
| *output = PortraitModeConfigDataView(data_->data.f_portrait_mode_config.Get(), message_); |
| } |
| |
| |
| } // cros::mojom |
| |
| // Declare TraceFormatTraits for enums, which should be defined in ::perfetto |
| // namespace. |
| |
| namespace perfetto { |
| |
| template <> |
| struct TraceFormatTraits<::cros::mojom::PortraitModeSegResult> { |
| static void WriteIntoTrace(perfetto::TracedValue context, ::cros::mojom::PortraitModeSegResult value); |
| }; |
| |
| } // namespace perfetto |
| |
| #endif // CAMERA_MOJO_CAMERA_FEATURES_MOJOM_SHARED_H_ |