// gpu/ipc/common/exported_shared_image.mojom.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 "gpu/ipc/common/exported_shared_image.mojom.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 "gpu/ipc/common/exported_shared_image.mojom-params-data.h"
#include "gpu/ipc/common/exported_shared_image.mojom-shared-message-ids.h"

#include "gpu/ipc/common/exported_shared_image.mojom-import-headers.h"
#include "gpu/ipc/common/exported_shared_image.mojom-test-utils.h"


namespace gpu::mojom {
SharedImageExportResult::SharedImageExportResult()
    : sync_tokens() {}

SharedImageExportResult::SharedImageExportResult(
    std::vector<::gpu::SyncToken> sync_tokens_in)
    : sync_tokens(std::move(sync_tokens_in)) {}

SharedImageExportResult::~SharedImageExportResult() = default;

void SharedImageExportResult::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "sync_tokens"), this->sync_tokens,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::vector<::gpu::SyncToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool SharedImageExportResult::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
ExportedSharedImage::ExportedSharedImage()
    : mailbox(),
      metadata(),
      creation_sync_token(),
      managed_sync_tokens(),
      debug_label(),
      buffer_handle(),
      buffer_usage(),
      texture_target(),
      is_software() {}

ExportedSharedImage::ExportedSharedImage(
    const ::gpu::Mailbox& mailbox_in,
    const ::gpu::SharedImageMetadata& metadata_in,
    const ::gpu::SyncToken& creation_sync_token_in,
    std::vector<::gpu::SyncToken> managed_sync_tokens_in,
    const std::string& debug_label_in,
    std::optional<::gfx::GpuMemoryBufferHandle> buffer_handle_in,
    std::optional<::gfx::BufferUsage> buffer_usage_in,
    uint32_t texture_target_in,
    bool is_software_in)
    : mailbox(std::move(mailbox_in)),
      metadata(std::move(metadata_in)),
      creation_sync_token(std::move(creation_sync_token_in)),
      managed_sync_tokens(std::move(managed_sync_tokens_in)),
      debug_label(std::move(debug_label_in)),
      buffer_handle(std::move(buffer_handle_in)),
      buffer_usage(std::move(buffer_usage_in)),
      texture_target(std::move(texture_target_in)),
      is_software(std::move(is_software_in)) {}

ExportedSharedImage::~ExportedSharedImage() = default;

void ExportedSharedImage::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "mailbox"), this->mailbox,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gpu::Mailbox&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "metadata"), this->metadata,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gpu::SharedImageMetadata&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "creation_sync_token"), this->creation_sync_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gpu::SyncToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "managed_sync_tokens"), this->managed_sync_tokens,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::vector<::gpu::SyncToken>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "debug_label"), this->debug_label,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::string&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "buffer_handle"), this->buffer_handle,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::gfx::GpuMemoryBufferHandle>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "buffer_usage"), this->buffer_usage,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::gfx::BufferUsage>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "texture_target"), this->texture_target,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type uint32_t>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_software"), this->is_software,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // gpu::mojom


namespace mojo {


// static
bool StructTraits<::gpu::mojom::SharedImageExportResult::DataView, ::gpu::mojom::SharedImageExportResultPtr>::Read(
    ::gpu::mojom::SharedImageExportResult::DataView input,
    ::gpu::mojom::SharedImageExportResultPtr* output) {
  bool success = true;
  ::gpu::mojom::SharedImageExportResultPtr result(::gpu::mojom::SharedImageExportResult::New());
  
      if (success && !input.ReadSyncTokens(&result->sync_tokens))
        success = false;
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::gpu::mojom::ExportedSharedImage::DataView, ::gpu::mojom::ExportedSharedImagePtr>::Read(
    ::gpu::mojom::ExportedSharedImage::DataView input,
    ::gpu::mojom::ExportedSharedImagePtr* output) {
  bool success = true;
  ::gpu::mojom::ExportedSharedImagePtr result(::gpu::mojom::ExportedSharedImage::New());
  
      if (success && !input.ReadMailbox(&result->mailbox))
        success = false;
      if (success && !input.ReadMetadata(&result->metadata))
        success = false;
      if (success && !input.ReadCreationSyncToken(&result->creation_sync_token))
        success = false;
      if (success && !input.ReadManagedSyncTokens(&result->managed_sync_tokens))
        success = false;
      if (success && !input.ReadDebugLabel(&result->debug_label))
        success = false;
      if (success && !input.ReadBufferHandle(&result->buffer_handle))
        success = false;
      if (success && !input.ReadBufferUsage(&result->buffer_usage)) {
        success = false;
      }
      if (success)
        result->texture_target = input.texture_target();
      if (success)
        result->is_software = input.is_software();
  *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 gpu::mojom {




}  // gpu::mojom


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