// services/viz/public/mojom/compositing/transferable_resource.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 "services/viz/public/mojom/compositing/transferable_resource.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 "services/viz/public/mojom/compositing/transferable_resource.mojom-params-data.h"
#include "services/viz/public/mojom/compositing/transferable_resource.mojom-shared-message-ids.h"

#include "services/viz/public/mojom/compositing/transferable_resource.mojom-import-headers.h"
#include "services/viz/public/mojom/compositing/transferable_resource.mojom-test-utils.h"


namespace viz::mojom {
MetadataOverride::MetadataOverride()
    : is_overlay_candidate(),
      color_space(),
      alpha_type() {}

MetadataOverride::MetadataOverride(
    std::optional<bool> is_overlay_candidate_in,
    const std::optional<::gfx::ColorSpace>& color_space_in,
    std::optional<::SkAlphaType> alpha_type_in)
    : is_overlay_candidate(std::move(is_overlay_candidate_in)),
      color_space(std::move(color_space_in)),
      alpha_type(std::move(alpha_type_in)) {}

MetadataOverride::~MetadataOverride() = default;

void MetadataOverride::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_overlay_candidate"), this->is_overlay_candidate,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<bool>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "color_space"), this->color_space,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::gfx::ColorSpace>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "alpha_type"), this->alpha_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::SkAlphaType>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

bool MetadataOverride::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
TransferableResource::TransferableResource()
    : id(),
      shared_image(),
      sync_token(),
      synchronization_type(),
      is_backed_by_surface_view(),
      wants_promotion_hint(),
      hdr_metadata(),
      needs_detiling(),
      ycbcr_info(),
      resource_source(),
      metadata_override() {}

TransferableResource::TransferableResource(
    const ::viz::ResourceId& id_in,
    ::gpu::ExportedSharedImage shared_image_in,
    const ::gpu::SyncToken& sync_token_in,
    SynchronizationType synchronization_type_in,
    bool is_backed_by_surface_view_in,
    bool wants_promotion_hint_in,
    const ::gfx::HDRMetadata& hdr_metadata_in,
    bool needs_detiling_in,
    std::optional<::gpu::VulkanYCbCrInfo> ycbcr_info_in,
    ResourceSource resource_source_in,
    MetadataOverridePtr metadata_override_in)
    : id(std::move(id_in)),
      shared_image(std::move(shared_image_in)),
      sync_token(std::move(sync_token_in)),
      synchronization_type(std::move(synchronization_type_in)),
      is_backed_by_surface_view(std::move(is_backed_by_surface_view_in)),
      wants_promotion_hint(std::move(wants_promotion_hint_in)),
      hdr_metadata(std::move(hdr_metadata_in)),
      needs_detiling(std::move(needs_detiling_in)),
      ycbcr_info(std::move(ycbcr_info_in)),
      resource_source(std::move(resource_source_in)),
      metadata_override(std::move(metadata_override_in)) {}

TransferableResource::~TransferableResource() = default;

void TransferableResource::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "id"), this->id,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::viz::ResourceId&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "shared_image"), this->shared_image,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::gpu::ExportedSharedImage>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "sync_token"), this->sync_token,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gpu::SyncToken&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "synchronization_type"), this->synchronization_type,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type SynchronizationType>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_backed_by_surface_view"), this->is_backed_by_surface_view,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "wants_promotion_hint"), this->wants_promotion_hint,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "hdr_metadata"), this->hdr_metadata,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gfx::HDRMetadata&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "needs_detiling"), this->needs_detiling,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ycbcr_info"), this->ycbcr_info,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<::gpu::VulkanYCbCrInfo>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "resource_source"), this->resource_source,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ResourceSource>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "metadata_override"), this->metadata_override,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type MetadataOverridePtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // viz::mojom


namespace mojo {


// static
bool StructTraits<::viz::mojom::MetadataOverride::DataView, ::viz::mojom::MetadataOverridePtr>::Read(
    ::viz::mojom::MetadataOverride::DataView input,
    ::viz::mojom::MetadataOverridePtr* output) {
  bool success = true;
  ::viz::mojom::MetadataOverridePtr result(::viz::mojom::MetadataOverride::New());
  
      if (success) {
        result->is_overlay_candidate = input.is_overlay_candidate();
      }
      if (success && !input.ReadColorSpace(&result->color_space))
        success = false;
      if (success && !input.ReadAlphaType(&result->alpha_type)) {
        success = false;
      }
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::viz::mojom::TransferableResource::DataView, ::viz::mojom::TransferableResourcePtr>::Read(
    ::viz::mojom::TransferableResource::DataView input,
    ::viz::mojom::TransferableResourcePtr* output) {
  bool success = true;
  ::viz::mojom::TransferableResourcePtr result(::viz::mojom::TransferableResource::New());
  
      if (success && !input.ReadId(&result->id))
        success = false;
      if (success && !input.ReadSharedImage(&result->shared_image))
        success = false;
      if (success && !input.ReadSyncToken(&result->sync_token))
        success = false;
      if (success && !input.ReadSynchronizationType(&result->synchronization_type))
        success = false;
      if (success)
        result->is_backed_by_surface_view = input.is_backed_by_surface_view();
      if (success)
        result->wants_promotion_hint = input.wants_promotion_hint();
      if (success && !input.ReadHdrMetadata(&result->hdr_metadata))
        success = false;
      if (success)
        result->needs_detiling = input.needs_detiling();
      if (success && !input.ReadYcbcrInfo(&result->ycbcr_info))
        success = false;
      if (success && !input.ReadResourceSource(&result->resource_source))
        success = false;
      if (success && !input.ReadMetadataOverride(&result->metadata_override))
        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 viz::mojom {




}  // viz::mojom


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