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 UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 5 #ifndef UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
6 #define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 6 #define UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
7 | 7 |
8 #include "ui/events/latency_info.h" | 8 #include "ui/events/latency_info.h" |
9 #include "ui/events/mojo/latency_info.mojom.h" | 9 #include "ui/events/mojo/latency_info.mojom.h" |
10 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h" | |
11 | 10 |
12 namespace mojo { | 11 namespace mojo { |
13 | 12 |
| 13 template <> |
| 14 struct StructTraits<ui::mojom::InputCoordinate, |
| 15 ui::LatencyInfo::InputCoordinate> { |
| 16 static float x(const ui::LatencyInfo::InputCoordinate& input) { |
| 17 return input.x; |
| 18 } |
| 19 static float y(const ui::LatencyInfo::InputCoordinate& input) { |
| 20 return input.y; |
| 21 } |
| 22 static bool Read(ui::mojom::InputCoordinateDataView data, |
| 23 ui::LatencyInfo::InputCoordinate* out) { |
| 24 out->x = data.x(); |
| 25 out->y = data.y(); |
| 26 return true; |
| 27 } |
| 28 }; |
| 29 |
14 // A buffer used to read bytes directly from LatencyInfoDataView into | 30 // A buffer used to read bytes directly from LatencyInfoDataView into |
15 // ui::LatencyInfo's input_coordinates_. | 31 // ui::LatencyInfo's input_coordinates_. |
16 struct InputCoordinateArray { | 32 struct InputCoordinateArray { |
17 size_t size; | 33 size_t size; |
18 gfx::PointF* data; | 34 ui::LatencyInfo::InputCoordinate* data; |
19 }; | 35 }; |
20 | 36 |
21 // TODO(fsamuel): We should add a common ArrayTraits<CArray<T>> utility struct. | 37 // TODO(fsamuel): We should add a common ArrayTraits<CArray<T>> utility struct. |
22 template <> | 38 template <> |
23 struct ArrayTraits<InputCoordinateArray> { | 39 struct ArrayTraits<InputCoordinateArray> { |
24 using Element = gfx::PointF; | 40 using Element = ui::LatencyInfo::InputCoordinate; |
25 static size_t GetSize(const InputCoordinateArray& b); | 41 static size_t GetSize(const InputCoordinateArray& b); |
26 static Element* GetData(InputCoordinateArray& b); | 42 static Element* GetData(InputCoordinateArray& b); |
27 static const Element* GetData(const InputCoordinateArray& b); | 43 static const Element* GetData(const InputCoordinateArray& b); |
28 static Element& GetAt(InputCoordinateArray& b, size_t i); | 44 static Element& GetAt(InputCoordinateArray& b, size_t i); |
29 static const Element& GetAt(const InputCoordinateArray& b, size_t i); | 45 static const Element& GetAt(const InputCoordinateArray& b, size_t i); |
30 static bool Resize(InputCoordinateArray& b, size_t size); | 46 static bool Resize(InputCoordinateArray& b, size_t size); |
31 }; | 47 }; |
32 | 48 |
33 template <> | 49 template <> |
34 struct StructTraits<ui::mojom::LatencyComponent, | 50 struct StructTraits<ui::mojom::LatencyComponent, |
(...skipping 30 matching lines...) Expand all Loading... |
65 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); | 81 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); |
66 static int64_t trace_id(const ui::LatencyInfo& info); | 82 static int64_t trace_id(const ui::LatencyInfo& info); |
67 static bool coalesced(const ui::LatencyInfo& info); | 83 static bool coalesced(const ui::LatencyInfo& info); |
68 static bool terminated(const ui::LatencyInfo& info); | 84 static bool terminated(const ui::LatencyInfo& info); |
69 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); | 85 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); |
70 }; | 86 }; |
71 | 87 |
72 } // namespace mojo | 88 } // namespace mojo |
73 | 89 |
74 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ | 90 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ |
OLD | NEW |