OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ | 5 #ifndef CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ |
6 #define CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ | 6 #define CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "cc/ipc/begin_frame_args.mojom-shared.h" | 8 #include "cc/ipc/begin_frame_args.mojom-shared.h" |
9 #include "cc/output/begin_frame_args.h" | 9 #include "cc/output/begin_frame_args.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 | 12 |
13 template <> | 13 template <> |
14 struct StructTraits<cc::mojom::BeginFrameArgsDataView, cc::BeginFrameArgs> { | 14 struct StructTraits<cc::mojom::BeginFrameArgsDataView, cc::BeginFrameArgs> { |
| 15 static uint64_t source_id(const cc::BeginFrameArgs& args) { |
| 16 return args.source_id; |
| 17 } |
| 18 |
| 19 static uint64_t sequence_number(const cc::BeginFrameArgs& args) { |
| 20 return args.sequence_number; |
| 21 } |
| 22 |
15 static base::TimeTicks frame_time(const cc::BeginFrameArgs& args) { | 23 static base::TimeTicks frame_time(const cc::BeginFrameArgs& args) { |
16 return args.frame_time; | 24 return args.frame_time; |
17 } | 25 } |
18 | 26 |
19 static base::TimeTicks deadline(const cc::BeginFrameArgs& args) { | 27 static base::TimeTicks deadline(const cc::BeginFrameArgs& args) { |
20 return args.deadline; | 28 return args.deadline; |
21 } | 29 } |
22 | 30 |
23 static base::TimeDelta interval(const cc::BeginFrameArgs& args) { | 31 static base::TimeDelta interval(const cc::BeginFrameArgs& args) { |
24 return args.interval; | 32 return args.interval; |
25 } | 33 } |
26 | 34 |
27 static cc::mojom::BeginFrameArgsType type(const cc::BeginFrameArgs& args) { | 35 static cc::mojom::BeginFrameArgsType type(const cc::BeginFrameArgs& args) { |
28 return static_cast<cc::mojom::BeginFrameArgsType>(args.type); | 36 return static_cast<cc::mojom::BeginFrameArgsType>(args.type); |
29 } | 37 } |
30 | 38 |
31 static bool on_critical_path(const cc::BeginFrameArgs& args) { | 39 static bool on_critical_path(const cc::BeginFrameArgs& args) { |
32 return args.on_critical_path; | 40 return args.on_critical_path; |
33 } | 41 } |
34 | 42 |
35 static bool Read(cc::mojom::BeginFrameArgsDataView data, | 43 static bool Read(cc::mojom::BeginFrameArgsDataView data, |
36 cc::BeginFrameArgs* out) { | 44 cc::BeginFrameArgs* out) { |
37 if (!data.ReadFrameTime(&out->frame_time) || | 45 if (!data.ReadFrameTime(&out->frame_time) || |
38 !data.ReadDeadline(&out->deadline) || | 46 !data.ReadDeadline(&out->deadline) || |
39 !data.ReadInterval(&out->interval)) { | 47 !data.ReadInterval(&out->interval)) { |
40 return false; | 48 return false; |
41 } | 49 } |
| 50 out->source_id = data.source_id(); |
| 51 out->sequence_number = data.sequence_number(); |
42 out->type = | 52 out->type = |
43 static_cast<cc::BeginFrameArgs::BeginFrameArgsType>(data.type()); | 53 static_cast<cc::BeginFrameArgs::BeginFrameArgsType>(data.type()); |
44 out->on_critical_path = data.on_critical_path(); | 54 out->on_critical_path = data.on_critical_path(); |
45 return true; | 55 return true; |
46 } | 56 } |
47 }; | 57 }; |
48 | 58 |
| 59 template <> |
| 60 struct StructTraits<cc::mojom::BeginFrameAckDataView, cc::BeginFrameAck> { |
| 61 static uint64_t source_id(const cc::BeginFrameAck& ack) { |
| 62 return ack.source_id; |
| 63 } |
| 64 |
| 65 static uint64_t sequence_number(const cc::BeginFrameAck& ack) { |
| 66 return ack.sequence_number; |
| 67 } |
| 68 |
| 69 static uint64_t oldest_incorporated_frame(const cc::BeginFrameAck& ack) { |
| 70 return ack.oldest_incorporated_frame; |
| 71 } |
| 72 |
| 73 static uint32_t remaining_frames(const cc::BeginFrameAck& ack) { |
| 74 return ack.remaining_frames; |
| 75 } |
| 76 |
| 77 static bool has_updates(const cc::BeginFrameAck& ack) { |
| 78 return ack.has_updates; |
| 79 } |
| 80 |
| 81 static bool Read(cc::mojom::BeginFrameAckDataView data, |
| 82 cc::BeginFrameAck* out) { |
| 83 out->source_id = data.source_id(); |
| 84 out->sequence_number = data.sequence_number(); |
| 85 out->oldest_incorporated_frame = data.oldest_incorporated_frame(); |
| 86 out->remaining_frames = data.remaining_frames(); |
| 87 out->has_updates = data.has_updates(); |
| 88 return true; |
| 89 } |
| 90 }; |
| 91 |
49 } // namespace mojo | 92 } // namespace mojo |
50 | 93 |
51 #endif // CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ | 94 #endif // CC_IPC_BEGIN_FRAME_ARGS_STRUCT_TRAITS_H_ |
OLD | NEW |