| // media/capture/video/chromeos/mojom/camera_features.mojom-shared.cc 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. |
| |
| #include "media/capture/video/chromeos/mojom/camera_features.mojom-shared.h" |
| |
| // Used to support stream output operator for enums. |
| // TODO(dcheng): Consider omitting this somehow if not needed. |
| #include <ostream> |
| #include <utility> |
| |
| #include "base/strings/stringprintf.h" |
| #include "mojo/public/cpp/bindings/lib/validate_params.h" |
| #include "mojo/public/cpp/bindings/lib/validation_errors.h" |
| #include "mojo/public/cpp/bindings/lib/validation_util.h" |
| #include "third_party/perfetto/include/perfetto/tracing/traced_value.h" |
| |
| #include "media/capture/video/chromeos/mojom/camera_features.mojom-params-data.h" |
| namespace cros { |
| namespace mojom { |
| |
| NOINLINE static const char* PortraitModeSegResultToStringHelper(PortraitModeSegResult value) { |
| // Defined in a helper function to ensure that Clang generates a lookup table. |
| switch(value) { |
| case PortraitModeSegResult::kSuccess: |
| return "kSuccess"; |
| case PortraitModeSegResult::kFailure: |
| return "kFailure"; |
| case PortraitModeSegResult::kTimeout: |
| return "kTimeout"; |
| case PortraitModeSegResult::kNoFaces: |
| return "kNoFaces"; |
| case PortraitModeSegResult::kUnknown: |
| return "kUnknown"; |
| default: |
| return nullptr; |
| } |
| } |
| |
| std::string PortraitModeSegResultToString(PortraitModeSegResult value) { |
| const char *str = PortraitModeSegResultToStringHelper(value); |
| if (!str) { |
| return base::StringPrintf("Unknown PortraitModeSegResult value: %i", static_cast<int32_t>(value)); |
| } |
| return str; |
| } |
| |
| std::ostream& operator<<(std::ostream& os, PortraitModeSegResult value) { |
| return os << PortraitModeSegResultToString(value); |
| } |
| |
| namespace internal { |
| // static |
| bool Camera3StreamEffect_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context, |
| bool inlined) { |
| if (!data) { |
| DCHECK(!inlined); |
| return true; |
| } |
| |
| // If it is inlined, the alignment is already enforced by its enclosing |
| // object. We don't have to validate that. |
| DCHECK(!inlined || mojo::internal::IsAligned(data)); |
| |
| if (!inlined && |
| !mojo::internal::ValidateNonInlinedUnionHeaderAndClaimMemory( |
| data, validation_context)) { |
| return false; |
| } |
| |
| const Camera3StreamEffect_Data* object = static_cast<const Camera3StreamEffect_Data*>(data); |
| |
| if (inlined && object->is_null()) |
| return true; |
| |
| switch (object->tag) { |
| |
| case Camera3StreamEffect_Tag::kUnknownConfig: { |
| |
| return true; |
| } |
| case Camera3StreamEffect_Tag::kPortraitModeConfig: { |
| |
| if (!mojo::internal::ValidatePointerNonNullable( |
| object->data.f_portrait_mode_config, 2, validation_context)) { |
| return false; |
| } |
| if (!mojo::internal::ValidateStruct(object->data.f_portrait_mode_config, validation_context)) |
| return false; |
| return true; |
| } |
| default: { |
| |
| return true; |
| } |
| } |
| } |
| |
| |
| // static |
| bool PortraitModeConfig_Data::Validate( |
| const void* data, |
| mojo::internal::ValidationContext* validation_context) { |
| if (!data) |
| return true; |
| if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory( |
| data, 16, validation_context)) { |
| return false; |
| } |
| |
| // NOTE: The memory backing |object| may be smaller than |sizeof(*object)| if |
| // the message comes from an older version. |
| [[maybe_unused]] const PortraitModeConfig_Data* object = |
| static_cast<const PortraitModeConfig_Data*>(data); |
| |
| return true; |
| } |
| |
| PortraitModeConfig_Data::PortraitModeConfig_Data() |
| : header_({sizeof(*this), 0}) {} |
| |
| } // namespace internal |
| } // namespace mojom |
| } // namespace cros |
| |
| namespace perfetto { |
| |
| // static |
| void TraceFormatTraits<::cros::mojom::PortraitModeSegResult>::WriteIntoTrace( |
| perfetto::TracedValue context, ::cros::mojom::PortraitModeSegResult value) { |
| return std::move(context).WriteString(::cros::mojom::PortraitModeSegResultToString(value)); |
| } |
| |
| } // namespace perfetto |