1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_GFX_MOJOM_PRESENTATION_FEEDBACK_MOJOM_TRAITS_H_
#define UI_GFX_MOJOM_PRESENTATION_FEEDBACK_MOJOM_TRAITS_H_
#include <cstdint>
#include "base/time/time.h"
#include "build/build_config.h"
#include "mojo/public/cpp/base/time_mojom_traits.h"
#include "ui/gfx/ca_layer_result.h"
#include "ui/gfx/mojom/presentation_feedback.mojom-shared.h"
#include "ui/gfx/presentation_feedback.h"
#if BUILDFLAG(IS_APPLE)
#include "ui/gfx/mojom/ca_layer_result_mojom_traits.h"
#endif
namespace mojo {
template <>
struct StructTraits<gfx::mojom::PresentationFeedbackDataView,
gfx::PresentationFeedback> {
static base::TimeTicks timestamp(const gfx::PresentationFeedback& input) {
return input.timestamp;
}
static base::TimeDelta interval(const gfx::PresentationFeedback& input) {
return input.interval;
}
static uint32_t flags(const gfx::PresentationFeedback& input) {
return input.flags;
}
static base::TimeTicks available_timestamp(
const gfx::PresentationFeedback& input) {
return input.available_timestamp;
}
static base::TimeTicks ready_timestamp(
const gfx::PresentationFeedback& input) {
return input.ready_timestamp;
}
static base::TimeTicks latch_timestamp(
const gfx::PresentationFeedback& input) {
return input.latch_timestamp;
}
static base::TimeTicks writes_done_timestamp(
const gfx::PresentationFeedback& input) {
return input.writes_done_timestamp;
}
#if BUILDFLAG(IS_APPLE)
static gfx::CALayerResult ca_layer_error_code(
const gfx::PresentationFeedback& input) {
return input.ca_layer_error_code;
}
#endif
static std::optional<int64_t> display_trace_id(
const gfx::PresentationFeedback& input) {
return input.display_trace_id;
}
static bool Read(gfx::mojom::PresentationFeedbackDataView data,
gfx::PresentationFeedback* out) {
out->flags = data.flags();
out->display_trace_id = data.display_trace_id();
return data.ReadTimestamp(&out->timestamp) &&
data.ReadInterval(&out->interval) &&
data.ReadAvailableTimestamp(&out->available_timestamp) &&
data.ReadReadyTimestamp(&out->ready_timestamp) &&
data.ReadLatchTimestamp(&out->latch_timestamp) &&
#if BUILDFLAG(IS_APPLE)
data.ReadCaLayerErrorCode(&out->ca_layer_error_code) &&
#endif
data.ReadWritesDoneTimestamp(&out->writes_done_timestamp);
}
};
} // namespace mojo
#endif // UI_GFX_MOJOM_PRESENTATION_FEEDBACK_MOJOM_TRAITS_H_
|