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

#include "ui/display/mojom/display_mode.mojom-import-headers.h"
#include "ui/display/mojom/display_mode.mojom-test-utils.h"


namespace display::mojom {
DisplayMode::DisplayMode()
    : size(),
      is_interlaced(),
      refresh_rate(),
      vsync_rate_min() {}

DisplayMode::DisplayMode(
    const ::gfx::Size& size_in,
    bool is_interlaced_in,
    float refresh_rate_in,
    std::optional<float> vsync_rate_min_in)
    : size(std::move(size_in)),
      is_interlaced(std::move(is_interlaced_in)),
      refresh_rate(std::move(refresh_rate_in)),
      vsync_rate_min(std::move(vsync_rate_min_in)) {}

DisplayMode::~DisplayMode() = default;

void DisplayMode::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "size"), this->size,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gfx::Size&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "is_interlaced"), this->is_interlaced,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type bool>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "refresh_rate"), this->refresh_rate,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type float>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "vsync_rate_min"), this->vsync_rate_min,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type std::optional<float>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // display::mojom


namespace mojo {


// static
bool StructTraits<::display::mojom::DisplayMode::DataView, ::display::mojom::DisplayModePtr>::Read(
    ::display::mojom::DisplayMode::DataView input,
    ::display::mojom::DisplayModePtr* output) {
  bool success = true;
  ::display::mojom::DisplayModePtr result(::display::mojom::DisplayMode::New());
  
      if (success && !input.ReadSize(&result->size))
        success = false;
      if (success)
        result->is_interlaced = input.is_interlaced();
      if (success)
        result->refresh_rate = input.refresh_rate();
      if (success) {
        result->vsync_rate_min = input.vsync_rate_min();
      }
  *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 display::mojom {




}  // display::mojom


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