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

Side by Side Diff: services/ui/public/interfaces/display/display_struct_traits.cc

Issue 2123613002: Add a mojom/StructTrait for display::Display. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move unit test target. Created 4 years, 5 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 2016 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 "services/ui/public/interfaces/display/display_struct_traits.h"
6
7 #include "ui/gfx/geometry/mojo/geometry_struct_traits.h"
8
9 namespace mojo {
10
11 display::mojom::Rotation
12 EnumTraits<display::mojom::Rotation, display::Display::Rotation>::ToMojom(
13 display::Display::Rotation rotation) {
14 switch (rotation) {
15 case display::Display::ROTATE_0:
16 return display::mojom::Rotation::VALUE_0;
17 case display::Display::ROTATE_90:
18 return display::mojom::Rotation::VALUE_90;
19 case display::Display::ROTATE_180:
20 return display::mojom::Rotation::VALUE_180;
21 case display::Display::ROTATE_270:
22 return display::mojom::Rotation::VALUE_270;
23 }
24 NOTREACHED();
25 return display::mojom::Rotation::VALUE_0;
26 }
27
28 bool EnumTraits<display::mojom::Rotation, display::Display::Rotation>::
29 FromMojom(display::mojom::Rotation rotation,
30 display::Display::Rotation* out) {
31 switch (rotation) {
32 case display::mojom::Rotation::VALUE_0:
33 *out = display::Display::ROTATE_0;
34 return true;
35 case display::mojom::Rotation::VALUE_90:
36 *out = display::Display::ROTATE_90;
37 return true;
38 case display::mojom::Rotation::VALUE_180:
39 *out = display::Display::ROTATE_180;
40 return true;
41 case display::mojom::Rotation::VALUE_270:
42 *out = display::Display::ROTATE_270;
43 return true;
44 }
45 NOTREACHED();
46 return false;
47 }
48
49 display::mojom::TouchSupport
50 EnumTraits<display::mojom::TouchSupport, display::Display::TouchSupport>::
51 ToMojom(display::Display::TouchSupport touch_support) {
52 switch (touch_support) {
53 case display::Display::TOUCH_SUPPORT_UNKNOWN:
54 return display::mojom::TouchSupport::UNKNOWN;
55 case display::Display::TOUCH_SUPPORT_AVAILABLE:
56 return display::mojom::TouchSupport::AVAILABLE;
57 case display::Display::TOUCH_SUPPORT_UNAVAILABLE:
58 return display::mojom::TouchSupport::UNAVAILABLE;
59 }
60 NOTREACHED();
61 return display::mojom::TouchSupport::UNKNOWN;
62 }
63
64 bool EnumTraits<display::mojom::TouchSupport, display::Display::TouchSupport>::
65 FromMojom(display::mojom::TouchSupport touch_support,
66 display::Display::TouchSupport* out) {
67 switch (touch_support) {
68 case display::mojom::TouchSupport::UNKNOWN:
69 *out = display::Display::TOUCH_SUPPORT_UNKNOWN;
70 return true;
71 case display::mojom::TouchSupport::AVAILABLE:
72 *out = display::Display::TOUCH_SUPPORT_AVAILABLE;
73 return true;
74 case display::mojom::TouchSupport::UNAVAILABLE:
75 *out = display::Display::TOUCH_SUPPORT_UNAVAILABLE;
76 return true;
77 }
78 NOTREACHED();
79 return display::Display::TOUCH_SUPPORT_UNKNOWN;
80 }
81
82 bool StructTraits<display::mojom::Display, display::Display>::Read(
83 display::mojom::DisplayDataView data,
84 display::Display* out) {
85 out->set_id(data.id());
86
87 if (!data.ReadBounds(&out->bounds_))
88 return false;
89
90 if (!data.ReadWorkArea(&out->work_area_))
91 return false;
92
93 out->set_device_scale_factor(data.device_scale_factor());
94
95 if (!data.ReadRotation(&out->rotation_))
96 return false;
97
98 if (!data.ReadTouchSupport(&out->touch_support_))
99 return false;
100
101 if (!data.ReadMaximumCursorSize(&out->maximum_cursor_size_))
102 return false;
103
104 return true;
105 }
106
107 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698