Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: ui/events/mojo/latency_info_struct_traits.h

Issue 2039853004: Replace ui::LatencyInfo::InputCoordinate with gfx::PointF (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing gyp dep Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/mojo/latency_info.typemap ('k') | ui/events/mojo/latency_info_struct_traits.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
10 11
11 namespace mojo { 12 namespace mojo {
12 13
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
30 // A buffer used to read bytes directly from LatencyInfoDataView into 14 // A buffer used to read bytes directly from LatencyInfoDataView into
31 // ui::LatencyInfo's input_coordinates_. 15 // ui::LatencyInfo's input_coordinates_.
32 struct InputCoordinateArray { 16 struct InputCoordinateArray {
33 size_t size; 17 size_t size;
34 ui::LatencyInfo::InputCoordinate* data; 18 gfx::PointF* data;
35 }; 19 };
36 20
37 // TODO(fsamuel): We should add a common ArrayTraits<CArray<T>> utility struct. 21 // TODO(fsamuel): We should add a common ArrayTraits<CArray<T>> utility struct.
38 template <> 22 template <>
39 struct ArrayTraits<InputCoordinateArray> { 23 struct ArrayTraits<InputCoordinateArray> {
40 using Element = ui::LatencyInfo::InputCoordinate; 24 using Element = gfx::PointF;
41 static size_t GetSize(const InputCoordinateArray& b); 25 static size_t GetSize(const InputCoordinateArray& b);
42 static Element* GetData(InputCoordinateArray& b); 26 static Element* GetData(InputCoordinateArray& b);
43 static const Element* GetData(const InputCoordinateArray& b); 27 static const Element* GetData(const InputCoordinateArray& b);
44 static Element& GetAt(InputCoordinateArray& b, size_t i); 28 static Element& GetAt(InputCoordinateArray& b, size_t i);
45 static const Element& GetAt(const InputCoordinateArray& b, size_t i); 29 static const Element& GetAt(const InputCoordinateArray& b, size_t i);
46 static bool Resize(InputCoordinateArray& b, size_t size); 30 static bool Resize(InputCoordinateArray& b, size_t size);
47 }; 31 };
48 32
49 template <> 33 template <>
50 struct StructTraits<ui::mojom::LatencyComponent, 34 struct StructTraits<ui::mojom::LatencyComponent,
(...skipping 30 matching lines...) Expand all
81 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info); 65 static InputCoordinateArray input_coordinates(const ui::LatencyInfo& info);
82 static int64_t trace_id(const ui::LatencyInfo& info); 66 static int64_t trace_id(const ui::LatencyInfo& info);
83 static bool coalesced(const ui::LatencyInfo& info); 67 static bool coalesced(const ui::LatencyInfo& info);
84 static bool terminated(const ui::LatencyInfo& info); 68 static bool terminated(const ui::LatencyInfo& info);
85 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out); 69 static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out);
86 }; 70 };
87 71
88 } // namespace mojo 72 } // namespace mojo
89 73
90 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_ 74 #endif // UI_EVENTS_MOJO_LATENCY_INFO_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « ui/events/mojo/latency_info.typemap ('k') | ui/events/mojo/latency_info_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698