blob: 15aebf6c2b22142f9339630036b8dbcd56fdfb98 [file] [log] [blame]
// camera/mojo/gpu/mjpeg_decode_accelerator.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/gpu/mjpeg_decode_accelerator.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/gpu/mjpeg_decode_accelerator.mojom-params-data.h"
namespace cros {
namespace mojom {
NOINLINE static const char* DecodeErrorToStringHelper(DecodeError value) {
// Defined in a helper function to ensure that Clang generates a lookup table.
switch(value) {
case DecodeError::NO_ERRORS:
return "NO_ERRORS";
case DecodeError::INVALID_ARGUMENT:
return "INVALID_ARGUMENT";
case DecodeError::UNREADABLE_INPUT:
return "UNREADABLE_INPUT";
case DecodeError::PARSE_JPEG_FAILED:
return "PARSE_JPEG_FAILED";
case DecodeError::UNSUPPORTED_JPEG:
return "UNSUPPORTED_JPEG";
case DecodeError::PLATFORM_FAILURE:
return "PLATFORM_FAILURE";
default:
return nullptr;
}
}
std::string DecodeErrorToString(DecodeError value) {
const char *str = DecodeErrorToStringHelper(value);
if (!str) {
return base::StringPrintf("Unknown DecodeError value: %i", static_cast<int32_t>(value));
}
return str;
}
std::ostream& operator<<(std::ostream& os, DecodeError value) {
return os << DecodeErrorToString(value);
}
namespace internal {
// static
bool MjpegDecodeAccelerator_Initialize_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
data, 8, 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 MjpegDecodeAccelerator_Initialize_Params_Data* object =
static_cast<const MjpegDecodeAccelerator_Initialize_Params_Data*>(data);
return true;
}
MjpegDecodeAccelerator_Initialize_Params_Data::MjpegDecodeAccelerator_Initialize_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool MjpegDecodeAccelerator_Initialize_ResponseParams_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 MjpegDecodeAccelerator_Initialize_ResponseParams_Data* object =
static_cast<const MjpegDecodeAccelerator_Initialize_ResponseParams_Data*>(data);
return true;
}
MjpegDecodeAccelerator_Initialize_ResponseParams_Data::MjpegDecodeAccelerator_Initialize_ResponseParams_Data()
: header_({sizeof(*this), 0}) {}
// static
bool MjpegDecodeAccelerator_DecodeWithDmaBuf_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
data, 32, 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 MjpegDecodeAccelerator_DecodeWithDmaBuf_Params_Data* object =
static_cast<const MjpegDecodeAccelerator_DecodeWithDmaBuf_Params_Data*>(data);
if (!mojo::internal::ValidateHandleOrInterfaceNonNullable(
object->src_dmabuf_fd, 2, validation_context)) {
return false;
}
if (!mojo::internal::ValidateHandleOrInterface(object->src_dmabuf_fd,
validation_context)) {
return false;
}
if (!mojo::internal::ValidatePointerNonNullable(
object->dst_frame, 5, validation_context)) {
return false;
}
if (!mojo::internal::ValidateStruct(object->dst_frame, validation_context))
return false;
return true;
}
MjpegDecodeAccelerator_DecodeWithDmaBuf_Params_Data::MjpegDecodeAccelerator_DecodeWithDmaBuf_Params_Data()
: header_({sizeof(*this), 0}) {}
// static
bool MjpegDecodeAccelerator_DecodeWithDmaBuf_ResponseParams_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 MjpegDecodeAccelerator_DecodeWithDmaBuf_ResponseParams_Data* object =
static_cast<const MjpegDecodeAccelerator_DecodeWithDmaBuf_ResponseParams_Data*>(data);
if (!::cros::mojom::internal::DecodeError_Data
::Validate(object->error, validation_context))
return false;
return true;
}
MjpegDecodeAccelerator_DecodeWithDmaBuf_ResponseParams_Data::MjpegDecodeAccelerator_DecodeWithDmaBuf_ResponseParams_Data()
: header_({sizeof(*this), 0}) {}
// static
bool MjpegDecodeAccelerator_Uninitialize_Params_Data::Validate(
const void* data,
mojo::internal::ValidationContext* validation_context) {
if (!data)
return true;
if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
data, 8, 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 MjpegDecodeAccelerator_Uninitialize_Params_Data* object =
static_cast<const MjpegDecodeAccelerator_Uninitialize_Params_Data*>(data);
return true;
}
MjpegDecodeAccelerator_Uninitialize_Params_Data::MjpegDecodeAccelerator_Uninitialize_Params_Data()
: header_({sizeof(*this), 0}) {}
} // namespace internal
} // namespace mojom
} // namespace cros
namespace perfetto {
// static
void TraceFormatTraits<::cros::mojom::DecodeError>::WriteIntoTrace(
perfetto::TracedValue context, ::cros::mojom::DecodeError value) {
return std::move(context).WriteString(::cros::mojom::DecodeErrorToString(value));
}
} // namespace perfetto