blob: 81b77584bf194096b0b4d701af912696d7234b13 [file] [log] [blame]
// camera/mojo/effects/effects_pipeline.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 "camera/mojo/effects/effects_pipeline.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 "camera/mojo/effects/effects_pipeline.mojom-params-data.h"
namespace cros {
namespace mojom {
NOINLINE static const char* CameraEffectToStringHelper(CameraEffect value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case CameraEffect::kNone:
return "kNone";
case CameraEffect::kBackgroundBlur:
return "kBackgroundBlur";
case CameraEffect::kBackgroundReplace:
return "kBackgroundReplace";
case CameraEffect::kPortraitRelight:
return "kPortraitRelight";
case CameraEffect::kBackgroundBlurPortraitRelight:
return "kBackgroundBlurPortraitRelight";
case CameraEffect::kCount:
return "kCount";
default:
return nullptr;
}
}
std::string CameraEffectToString(CameraEffect value) {
const char *str = CameraEffectToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown CameraEffect value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, CameraEffect value) {
return os << CameraEffectToString(value);
}
NOINLINE static const char* GpuApiToStringHelper(GpuApi value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case GpuApi::kOpenCL:
return "kOpenCL";
case GpuApi::kOpenGL:
return "kOpenGL";
case GpuApi::kAny:
return "kAny";
default:
return nullptr;
}
}
std::string GpuApiToString(GpuApi value) {
const char *str = GpuApiToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown GpuApi value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, GpuApi value) {
return os << GpuApiToString(value);
}
NOINLINE static const char* BlurLevelToStringHelper(BlurLevel value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case BlurLevel::kLowest:
return "kLowest";
case BlurLevel::kLight:
return "kLight";
case BlurLevel::kMedium:
return "kMedium";
case BlurLevel::kHeavy:
return "kHeavy";
case BlurLevel::kMaximum:
return "kMaximum";
default:
return nullptr;
}
}
std::string BlurLevelToString(BlurLevel value) {
const char *str = BlurLevelToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown BlurLevel value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, BlurLevel value) {
return os << BlurLevelToString(value);
}
NOINLINE static const char* SegmentationModelToStringHelper(SegmentationModel value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case SegmentationModel::kAuto:
return "kAuto";
case SegmentationModel::kHighResolution:
return "kHighResolution";
case SegmentationModel::kLowerResolution:
return "kLowerResolution";
default:
return nullptr;
}
}
std::string SegmentationModelToString(SegmentationModel value) {
const char *str = SegmentationModelToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown SegmentationModel value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, SegmentationModel value) {
return os << SegmentationModelToString(value);
}
namespace internal {
// static
bool EffectsConfig_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
static constexpr mojo::internal::StructVersionSize kVersionSizes[] = {
{ 0, 24 },
{ 1, 24 },
{ 2, 32 },
{ 3, 40 },
{ 4, 40 },
};
if (!ValidateStructHeaderAndVersionSizeAndClaimMemory(
data, kVersionSizes, 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 EffectsConfig_Data* object =
static_cast<const EffectsConfig_Data*>(data);
if (!::cros::mojom::internal::CameraEffect_Data
::Validate(object->effect, validation_context))
return false;
if (!::cros::mojom::internal::BlurLevel_Data
::Validate(object->blur_level, validation_context))
return false;
if (!::cros::mojom::internal::GpuApi_Data
::Validate(object->segmentation_gpu_api, validation_context))
return false;
if (object->header_.version < 2)
return true;
if (!::cros::mojom::internal::SegmentationModel_Data
::Validate(object->segmentation_model, validation_context))
return false;
if (object->header_.version < 3)
return true;
if (!mojo::internal::ValidateStruct(object->background_filepath, validation_context))
return false;
return true;
}
EffectsConfig_Data::EffectsConfig_Data()
: header_({sizeof(*this), 4}) {}
} // namespace internal
} // namespace mojom
} // namespace cros
namespace perfetto {
// static
void TraceFormatTraits<::cros::mojom::CameraEffect>::WriteIntoTrace(
perfetto::TracedValue context, ::cros::mojom::CameraEffect value) {
return std::move(context).WriteString(::cros::mojom::CameraEffectToString(value));
}
} // namespace perfetto
namespace perfetto {
// static
void TraceFormatTraits<::cros::mojom::GpuApi>::WriteIntoTrace(
perfetto::TracedValue context, ::cros::mojom::GpuApi value) {
return std::move(context).WriteString(::cros::mojom::GpuApiToString(value));
}
} // namespace perfetto
namespace perfetto {
// static
void TraceFormatTraits<::cros::mojom::BlurLevel>::WriteIntoTrace(
perfetto::TracedValue context, ::cros::mojom::BlurLevel value) {
return std::move(context).WriteString(::cros::mojom::BlurLevelToString(value));
}
} // namespace perfetto
namespace perfetto {
// static
void TraceFormatTraits<::cros::mojom::SegmentationModel>::WriteIntoTrace(
perfetto::TracedValue context, ::cros::mojom::SegmentationModel value) {
return std::move(context).WriteString(::cros::mojom::SegmentationModelToString(value));
}
} // namespace perfetto