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

Side by Side Diff: ui/display/mojo/display_layout_struct_traits.cc

Issue 2661663002: Add DisplayPlacement/Layout mojoms + StructTraits. (Closed)
Patch Set: Remove empty comments. 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 #include "ui/display/mojo/display_layout_struct_traits.h"
6
7 namespace mojo {
8
9 display::mojom::Position
10 EnumTraits<display::mojom::Position, display::DisplayPlacement::Position>::
11 ToMojom(display::DisplayPlacement::Position rotation) {
12 switch (rotation) {
13 case display::DisplayPlacement::TOP:
14 return display::mojom::Position::TOP;
15 case display::DisplayPlacement::RIGHT:
16 return display::mojom::Position::RIGHT;
17 case display::DisplayPlacement::BOTTOM:
18 return display::mojom::Position::BOTTOM;
19 case display::DisplayPlacement::LEFT:
20 return display::mojom::Position::LEFT;
21 }
22 NOTREACHED();
23 return display::mojom::Position::TOP;
24 }
25
26 bool EnumTraits<display::mojom::Position, display::DisplayPlacement::Position>::
27 FromMojom(display::mojom::Position rotation,
28 display::DisplayPlacement::Position* out) {
29 switch (rotation) {
30 case display::mojom::Position::TOP:
31 *out = display::DisplayPlacement::TOP;
32 return true;
33 case display::mojom::Position::RIGHT:
34 *out = display::DisplayPlacement::RIGHT;
35 return true;
36 case display::mojom::Position::BOTTOM:
37 *out = display::DisplayPlacement::BOTTOM;
38 return true;
39 case display::mojom::Position::LEFT:
40 *out = display::DisplayPlacement::LEFT;
41 return true;
42 }
43 return false;
44 }
45
46 display::mojom::OffsetReference
47 EnumTraits<display::mojom::OffsetReference,
48 display::DisplayPlacement::OffsetReference>::
49 ToMojom(display::DisplayPlacement::OffsetReference rotation) {
50 switch (rotation) {
51 case display::DisplayPlacement::TOP_LEFT:
52 return display::mojom::OffsetReference::TOP_LEFT;
53 case display::DisplayPlacement::BOTTOM_RIGHT:
54 return display::mojom::OffsetReference::BOTTOM_RIGHT;
55 }
56 NOTREACHED();
57 return display::mojom::OffsetReference::TOP_LEFT;
58 }
59
60 bool EnumTraits<display::mojom::OffsetReference,
61 display::DisplayPlacement::OffsetReference>::
62 FromMojom(display::mojom::OffsetReference rotation,
63 display::DisplayPlacement::OffsetReference* out) {
64 switch (rotation) {
65 case display::mojom::OffsetReference::TOP_LEFT:
66 *out = display::DisplayPlacement::TOP_LEFT;
67 return true;
68 case display::mojom::OffsetReference::BOTTOM_RIGHT:
69 *out = display::DisplayPlacement::BOTTOM_RIGHT;
70 return true;
71 }
72 return false;
73 }
74
75 bool StructTraits<display::mojom::DisplayPlacementDataView,
76 display::DisplayPlacement>::
77 Read(display::mojom::DisplayPlacementDataView data,
78 display::DisplayPlacement* out) {
79 out->display_id = data.display_id();
80 out->parent_display_id = data.parent_display_id();
81 out->offset = data.offset();
82
83 if (!data.ReadPosition(&out->position))
84 return false;
85
86 if (!data.ReadOffsetReference(&out->offset_reference))
87 return false;
88
89 return true;
90 }
91
92 bool StructTraits<display::mojom::DisplayLayoutDataView,
93 std::unique_ptr<display::DisplayLayout>>::
94 Read(display::mojom::DisplayLayoutDataView data,
95 std::unique_ptr<display::DisplayLayout>* out) {
96 auto display_layout = base::MakeUnique<display::DisplayLayout>();
97
98 if (!data.ReadPlacementList(&display_layout->placement_list))
99 return false;
100
101 display_layout->mirrored = data.mirrored();
102 display_layout->default_unified = data.default_unified();
103 display_layout->primary_id = data.primary_display_id();
104
105 *out = std::move(display_layout);
106
107 return true;
108 }
109
110 } // namespace mojo
OLDNEW
« no previous file with comments | « ui/display/mojo/display_layout_struct_traits.h ('k') | ui/display/mojo/display_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698