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

Side by Side Diff: ui/display/mojo/display_snapshot_mojo_struct_traits.h

Issue 2646213002: Write mojom and StructTraits for DisplaySnapshot. (Closed)
Patch Set: Create more unit tests. Refactor/Enhance code readility/format. Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_MOJO_STRUCT_TRAITS_H_
6 #define UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_MOJO_STRUCT_TRAITS_H_
7
8 #include "ui/display/display_snapshot_mojo.h"
9 #include "ui/display/mojo/display_snapshot_mojo.mojom.h"
10 #include "ui/display/types/display_mode.h"
11
12 namespace mojo {
13
14 template <>
15 struct StructTraits<display::mojom::DisplaySnapshotMojoDataView,
16 std::unique_ptr<display::DisplaySnapshotMojo>> {
17 static int64_t display_id(const std::unique_ptr<display::DisplaySnapshotMojo>&
18 display_snapshot_mojo) {
kylechar 2017/02/14 21:35:28 optional nit: If you named your parameter |snapsho
thanhph1 2017/02/15 15:37:56 Done.
19 return display_snapshot_mojo->display_id();
20 }
21
22 static const gfx::Point& origin(
23 const std::unique_ptr<display::DisplaySnapshotMojo>&
24 display_snapshot_mojo) {
25 return display_snapshot_mojo->origin();
26 }
27
28 static const gfx::Size& physical_size(
29 const std::unique_ptr<display::DisplaySnapshotMojo>&
30 display_snapshot_mojo) {
31 return display_snapshot_mojo->physical_size();
32 }
33
34 static display::DisplayConnectionType type(
35 const std::unique_ptr<display::DisplaySnapshotMojo>&
36 display_snapshot_mojo) {
37 return display_snapshot_mojo->type();
38 }
39
40 static bool is_aspect_preserving_scaling(
41 const std::unique_ptr<display::DisplaySnapshotMojo>&
42 display_snapshot_mojo) {
43 return display_snapshot_mojo->is_aspect_preserving_scaling();
44 }
45
46 static bool has_overscan(const std::unique_ptr<display::DisplaySnapshotMojo>&
47 display_snapshot_mojo) {
48 return display_snapshot_mojo->has_overscan();
49 }
50
51 static bool has_color_correction_matrix(
52 const std::unique_ptr<display::DisplaySnapshotMojo>&
53 display_snapshot_mojo) {
54 return display_snapshot_mojo->has_color_correction_matrix();
55 }
56
57 static std::string display_name(
58 const std::unique_ptr<display::DisplaySnapshotMojo>&
59 display_snapshot_mojo) {
60 return display_snapshot_mojo->display_name();
61 }
62
63 static const base::FilePath& sys_path(
64 const std::unique_ptr<display::DisplaySnapshotMojo>&
65 display_snapshot_mojo) {
66 return display_snapshot_mojo->sys_path();
67 }
68
69 static std::vector<uint8_t> edid(
70 const std::unique_ptr<display::DisplaySnapshotMojo>&
71 display_snapshot_mojo) {
72 return display_snapshot_mojo->edid();
73 }
74
75 static std::vector<std::unique_ptr<display::DisplayMode>> modes(
76 const std::unique_ptr<display::DisplaySnapshotMojo>&
77 display_snapshot_mojo);
78
79 static uint64_t current_mode_index(
80 const std::unique_ptr<display::DisplaySnapshotMojo>&
81 display_snapshot_mojo);
82
83 // True if display_snapshot_mojo->current_mode() is not null.
84 static bool has_current_mode(
85 const std::unique_ptr<display::DisplaySnapshotMojo>&
86 display_snapshot_mojo) {
87 return display_snapshot_mojo->current_mode();
kylechar 2017/02/14 21:35:28 Instad of your comment you could just do the follo
thanhph1 2017/02/15 15:37:56 Done.
88 }
89
90 static uint64_t native_mode_index(
91 const std::unique_ptr<display::DisplaySnapshotMojo>&
92 display_snapshot_mojo);
93
94 // True if display_snapshot_mojo->native_mode() is not null.
95 static bool has_native_mode(
96 const std::unique_ptr<display::DisplaySnapshotMojo>&
97 display_snapshot_mojo) {
98 return display_snapshot_mojo->native_mode();
99 }
100
101 static int64_t product_id(const std::unique_ptr<display::DisplaySnapshotMojo>&
102 display_snapshot_mojo) {
103 return display_snapshot_mojo->product_id();
104 }
105
106 static const gfx::Size& maximum_cursor_size(
107 const std::unique_ptr<display::DisplaySnapshotMojo>&
108 display_snapshot_mojo) {
109 return display_snapshot_mojo->maximum_cursor_size();
110 }
111
112 static bool Read(display::mojom::DisplaySnapshotMojoDataView data,
113 std::unique_ptr<display::DisplaySnapshotMojo>* out);
114 };
115
116 } // namespace mojo
117
118 #endif // UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_MOJO_STRUCT_TRAITS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698