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

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


namespace viz::mojom {
CopyOutputResult::CopyOutputResult()
    : format(),
      destination(),
      rect(),
      bitmap(),
      mailbox(),
      color_space(),
      releaser(),
      tracked_element_rects(),
      error() {}

CopyOutputResult::CopyOutputResult(
    CopyOutputResultFormat format_in,
    CopyOutputResultDestination destination_in,
    const ::gfx::Rect& rect_in,
    ::viz::mojom::BitmapInSharedMemoryPtr bitmap_in,
    const std::optional<::gpu::Mailbox>& mailbox_in,
    const std::optional<::gfx::ColorSpace>& color_space_in,
    ::mojo::PendingRemote<::viz::mojom::TextureReleaser> releaser_in,
    const ::viz::TrackedElementRects& tracked_element_rects_in,
    CopyOutputResultError error_in)
    : format(std::move(format_in)),
      destination(std::move(destination_in)),
      rect(std::move(rect_in)),
      bitmap(std::move(bitmap_in)),
      mailbox(std::move(mailbox_in)),
      color_space(std::move(color_space_in)),
      releaser(std::move(releaser_in)),
      tracked_element_rects(std::move(tracked_element_rects_in)),
      error(std::move(error_in)) {}

CopyOutputResult::~CopyOutputResult() = default;

void CopyOutputResult::WriteIntoTrace(
    perfetto::TracedValue traced_context) const {
  [[maybe_unused]] auto dict = std::move(traced_context).WriteDictionary();
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "format"), this->format,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CopyOutputResultFormat>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "destination"), this->destination,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CopyOutputResultDestination>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "rect"), this->rect,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::gfx::Rect&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "bitmap"), this->bitmap,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::viz::mojom::BitmapInSharedMemoryPtr>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "mailbox"), this->mailbox,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const std::optional<::gpu::Mailbox>&>"
#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(
      "releaser"), this->releaser,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type ::mojo::PendingRemote<::viz::mojom::TextureReleaser>>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "tracked_element_rects"), this->tracked_element_rects,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type const ::viz::TrackedElementRects&>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
  perfetto::WriteIntoTracedValueWithFallback(
    dict.AddItem(
      "error"), this->error,
#if BUILDFLAG(MOJO_TRACE_ENABLED)
      "<value of type CopyOutputResultError>"
#else
      "<value>"
#endif  // BUILDFLAG(MOJO_TRACE_ENABLED)
    );
}

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


}  // viz::mojom


namespace mojo {


// static
bool StructTraits<::viz::mojom::CopyOutputResult::DataView, ::viz::mojom::CopyOutputResultPtr>::Read(
    ::viz::mojom::CopyOutputResult::DataView input,
    ::viz::mojom::CopyOutputResultPtr* output) {
  bool success = true;
  ::viz::mojom::CopyOutputResultPtr result(::viz::mojom::CopyOutputResult::New());
  
      if (success && !input.ReadFormat(&result->format))
        success = false;
      if (success && !input.ReadDestination(&result->destination))
        success = false;
      if (success && !input.ReadRect(&result->rect))
        success = false;
      if (success && !input.ReadBitmap(&result->bitmap))
        success = false;
      if (success && !input.ReadMailbox(&result->mailbox))
        success = false;
      if (success && !input.ReadColorSpace(&result->color_space))
        success = false;
      if (success) {
        result->releaser =
            input.TakeReleaser<decltype(result->releaser)>();
      }
      if (success && !input.ReadTrackedElementRects(&result->tracked_element_rects))
        success = false;
      if (success && !input.ReadError(&result->error))
        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