// ui/gfx/mojom/hdr_metadata.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 "ui/gfx/mojom/hdr_metadata.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 "ui/gfx/mojom/hdr_metadata.mojom-params-data.h"
#include "ui/gfx/mojom/hdr_metadata.mojom-shared-message-ids.h"

#include "ui/gfx/mojom/hdr_metadata.mojom-import-headers.h"
#include "ui/gfx/mojom/hdr_metadata.mojom-test-utils.h"


namespace gfx::mojom {
HdrMetadataExtendedRange::HdrMetadataExtendedRange()
    : current_headroom(),
      desired_headroom() {}

HdrMetadataExtendedRange::HdrMetadataExtendedRange(
    float current_headroom_in,
    float desired_headroom_in)
    : current_headroom(std::move(current_headroom_in)),
      desired_headroom(std::move(desired_headroom_in)) {}

HdrMetadataExtendedRange::~HdrMetadataExtendedRange() = default;

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

bool HdrMetadataExtendedRange::Validate(
    const void* data,
    mojo::internal::ValidationContext* validation_context) {
  return Data_::Validate(data, validation_context);
}
HDRMetadata::HDRMetadata()
    : mdcv(),
      clli(),
      ndwl(),
      extended_range(),
      agtm() {}

HDRMetadata::HDRMetadata(
    const std::optional<::skhdr::MasteringDisplayColorVolume>& mdcv_in,
    const std::optional<::skhdr::ContentLightLevelInformation>& clli_in,
    std::optional<float> ndwl_in,
    const std::optional<::gfx::HdrMetadataExtendedRange>& extended_range_in,
    const std::optional<::skhdr::AdaptiveGlobalToneMap>& agtm_in)
    : mdcv(std::move(mdcv_in)),
      clli(std::move(clli_in)),
      ndwl(std::move(ndwl_in)),
      extended_range(std::move(extended_range_in)),
      agtm(std::move(agtm_in)) {}

HDRMetadata::~HDRMetadata() = default;

void HDRMetadata::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "mdcv"), this->mdcv,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::skhdr::MasteringDisplayColorVolume>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "clli"), this->clli,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::skhdr::ContentLightLevelInformation>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "ndwl"), this->ndwl,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<float>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "extended_range"), this->extended_range,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::gfx::HdrMetadataExtendedRange>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "agtm"), this->agtm,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::skhdr::AdaptiveGlobalToneMap>&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // gfx::mojom


namespace mojo {


// static
bool StructTraits<::gfx::mojom::HdrMetadataExtendedRange::DataView, ::gfx::mojom::HdrMetadataExtendedRangePtr>::Read(
    ::gfx::mojom::HdrMetadataExtendedRange::DataView input,
    ::gfx::mojom::HdrMetadataExtendedRangePtr* output) {
  bool success = true;
  ::gfx::mojom::HdrMetadataExtendedRangePtr result(::gfx::mojom::HdrMetadataExtendedRange::New());
  
      if (success)
        result->current_headroom = input.current_headroom();
      if (success)
        result->desired_headroom = input.desired_headroom();
  *output = std::move(result);
  return success;
}


// static
bool StructTraits<::gfx::mojom::HDRMetadata::DataView, ::gfx::mojom::HDRMetadataPtr>::Read(
    ::gfx::mojom::HDRMetadata::DataView input,
    ::gfx::mojom::HDRMetadataPtr* output) {
  bool success = true;
  ::gfx::mojom::HDRMetadataPtr result(::gfx::mojom::HDRMetadata::New());
  
      if (success && !input.ReadMdcv(&result->mdcv))
        success = false;
      if (success && !input.ReadClli(&result->clli))
        success = false;
      if (success) {
        result->ndwl = input.ndwl();
      }
      if (success && !input.ReadExtendedRange(&result->extended_range))
        success = false;
      if (success && !input.ReadAgtm(&result->agtm))
        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 gfx::mojom {




}  // gfx::mojom


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