// skia/public/mojom/image_info.mojom-blink.cc is auto generated by mojom_bindings_generator.py, do not edit

// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-private-field"
#endif

#include "skia/public/mojom/image_info.mojom-blink.h"
#include <stdint.h>
#include <utility>
#include "mojo/public/cpp/bindings/lib/default_construct_tag_internal.h"
#include "mojo/public/cpp/bindings/lib/serialization.h"
#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/bindings/mojo_buildflags.h"
#include "third_party/perfetto/include/perfetto/tracing/traced_value.h"

#include "skia/public/mojom/image_info.mojom-params-data.h"
#include "skia/public/mojom/image_info.mojom-shared-message-ids.h"

#include "skia/public/mojom/image_info.mojom-blink-import-headers.h"
#include "skia/public/mojom/image_info.mojom-blink-test-utils.h"
#include "mojo/public/cpp/bindings/lib/wtf_serialization.h"


namespace skia::mojom::blink {
ImageInfo::ImageInfo()
    : color_type(),
      alpha_type(),
      width(),
      height(),
      color_transfer_function(),
      color_to_xyz_matrix() {}

ImageInfo::ImageInfo(
    ::SkColorType color_type_in,
    ::SkAlphaType alpha_type_in,
    uint32_t width_in,
    uint32_t height_in,
    std::optional<::blink::Vector<float>> color_transfer_function_in,
    std::optional<::blink::Vector<float>> color_to_xyz_matrix_in)
    : color_type(std::move(color_type_in)),
      alpha_type(std::move(alpha_type_in)),
      width(std::move(width_in)),
      height(std::move(height_in)),
      color_transfer_function(std::move(color_transfer_function_in)),
      color_to_xyz_matrix(std::move(color_to_xyz_matrix_in)) {}

ImageInfo::~ImageInfo() = default;

void ImageInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_type"), this->color_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::SkColorType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "alpha_type"), this->alpha_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::SkAlphaType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "width"), this->width,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "height"), this->height,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_transfer_function"), this->color_transfer_function,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::Vector<float>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_to_xyz_matrix"), this->color_to_xyz_matrix,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::Vector<float>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool ImageInfo::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
BitmapN32ImageInfo::BitmapN32ImageInfo()
    : alpha_type(),
      width(),
      height(),
      color_transfer_function(),
      color_to_xyz_matrix() {}

BitmapN32ImageInfo::BitmapN32ImageInfo(
    ::SkAlphaType alpha_type_in,
    uint32_t width_in,
    uint32_t height_in,
    std::optional<::blink::Vector<float>> color_transfer_function_in,
    std::optional<::blink::Vector<float>> color_to_xyz_matrix_in)
    : alpha_type(std::move(alpha_type_in)),
      width(std::move(width_in)),
      height(std::move(height_in)),
      color_transfer_function(std::move(color_transfer_function_in)),
      color_to_xyz_matrix(std::move(color_to_xyz_matrix_in)) {}

BitmapN32ImageInfo::~BitmapN32ImageInfo() = default;

void BitmapN32ImageInfo::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "alpha_type"), this->alpha_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::SkAlphaType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "width"), this->width,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "height"), this->height,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_transfer_function"), this->color_transfer_function,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::Vector<float>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_to_xyz_matrix"), this->color_to_xyz_matrix,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::blink::Vector<float>>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool BitmapN32ImageInfo::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}


}  // skia::mojom::blink


namespace mojo {


// static
bool StructTraits<::skia::mojom::blink::ImageInfo::DataView, ::skia::mojom::blink::ImageInfoPtr>::Read(
    ::skia::mojom::blink::ImageInfo::DataView input,
    ::skia::mojom::blink::ImageInfoPtr* output) {
  bool success = true;
  ::skia::mojom::blink::ImageInfoPtr result(::skia::mojom::blink::ImageInfo::New());
  
      if (success && !input.ReadColorType(&result->color_type))
        success = false;
      if (success && !input.ReadAlphaType(&result->alpha_type))
        success = false;
      if (success)
        result->width = input.width();
      if (success)
        result->height = input.height();
      if (success && !input.ReadColorTransferFunction(&result->color_transfer_function))
        success = false;
      if (success && !input.ReadColorToXyzMatrix(&result->color_to_xyz_matrix))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::skia::mojom::blink::BitmapN32ImageInfo::DataView, ::skia::mojom::blink::BitmapN32ImageInfoPtr>::Read(
    ::skia::mojom::blink::BitmapN32ImageInfo::DataView input,
    ::skia::mojom::blink::BitmapN32ImageInfoPtr* output) {
  bool success = true;
  ::skia::mojom::blink::BitmapN32ImageInfoPtr result(::skia::mojom::blink::BitmapN32ImageInfo::New());
  
      if (success && !input.ReadAlphaType(&result->alpha_type))
        success = false;
      if (success)
        result->width = input.width();
      if (success)
        result->height = input.height();
      if (success && !input.ReadColorTransferFunction(&result->color_transfer_function))
        success = false;
      if (success && !input.ReadColorToXyzMatrix(&result->color_to_xyz_matrix))
        success = false;
  *output = std::move(result);
  return success;
}

}  // namespace mojo


// Symbols declared in the -test-utils.h header are defined here instead of a
// separate .cc file to save compile time.


namespace skia::mojom::blink {




}  // skia::mojom::blink


#if defined(__clang__)
#pragma clang diagnostic pop
#endif