// ui/gfx/mojom/transform.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 "ui/gfx/mojom/transform.mojom-shared.h"
#include <utility>
#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 "ui/gfx/mojom/transform.mojom-params-data.h"
namespace gfx {
namespace mojom {

namespace internal {
// static
bool TransformData_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 TransformData_Data* object = static_cast<const TransformData_Data*>(data);

  if (inlined && object->is_null())
    return true;

  switch (object->tag) {

    case TransformData_Tag::kAxis2d: {

      if (!mojo::internal::ValidatePointerNonNullable(
              object->data.f_axis_2d, 1, validation_context)) {
        return false;
      }
      if (!mojo::internal::ValidateStruct(object->data.f_axis_2d, validation_context))
        return false;
      return true;
    }
    case TransformData_Tag::kMatrix: {

      if (!mojo::internal::ValidatePointerNonNullable(
              object->data.f_matrix, 2, validation_context)) {
        return false;
      }
      constexpr const mojo::internal::ContainerValidateParams& matrix_validate_params =
          mojo::internal::GetArrayValidator<16, false, nullptr>();
      if (!mojo::internal::ValidateContainer(object->data.f_matrix, validation_context,
                                             &matrix_validate_params)) {
        return false;
      }
      return true;
    }
    default: {

      ReportValidationError(
          validation_context,
          mojo::internal::VALIDATION_ERROR_UNKNOWN_UNION_TAG,
          "unknown tag in TransformData");
      return false;
    }
  }
}


// static
bool Transform_Data::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  if (!data)
    return true;
  if (!ValidateUnversionedStructHeaderAndSizeAndClaimMemory(
          data, 24, 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 Transform_Data* object =
      static_cast<const Transform_Data*>(data);

  if (!mojo::internal::ValidateInlinedUnion(object->data, validation_context))
    return false;

  return true;
}

Transform_Data::Transform_Data()
    : header_({sizeof(*this), 0}) {}

}  // namespace internal
}  // namespace mojom
}  // namespace gfx