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

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

Powered by Google App Engine
This is Rietveld 408576698