Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
|
kylechar
2017/02/09 15:05:54
I don't understand why this file exists again? Ple
thanhph1
2017/02/10 19:54:33
Removed.
| |
| 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_STRUCT_TRAITS_H_ | |
| 6 #define UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_STRUCT_TRAITS_H_ | |
| 7 | |
| 8 #include "ui/display/mojo/display_constants.mojom-shared.h" | |
| 9 #include "ui/display/mojo/display_constants_struct_traits.h" | |
| 10 #include "ui/display/mojo/display_snapshot.mojom.h" | |
| 11 #include "ui/display/types/display_constants.h" | |
| 12 #include "ui/gfx/geometry/size.h" | |
| 13 | |
| 14 namespace mojo { | |
| 15 | |
| 16 template <> | |
| 17 struct StructTraits<display::mojom::DisplaySnapshotDataView, | |
| 18 std::unique_ptr<display::DisplaySnapshot>> { | |
| 19 static int64_t display_id( | |
| 20 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 21 return display_snapshot->display_id; | |
| 22 } | |
| 23 | |
| 24 static gfx::Point origin( | |
| 25 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 26 return display_snapshot->origin; | |
| 27 } | |
| 28 | |
| 29 static gfx::Size physical_size( | |
| 30 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 31 return display_snapshot->physical_size; | |
| 32 } | |
| 33 | |
| 34 static const display::DisplayConnectionType& type( | |
| 35 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 36 return display_snapshot->type; | |
| 37 } | |
| 38 | |
| 39 static bool is_aspect_preserving_scaling( | |
| 40 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 41 return display_snapshot->is_aspect_preserving_scaling; | |
| 42 } | |
| 43 | |
| 44 static bool has_overscan( | |
| 45 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 46 return display_snapshot->has_overscan; | |
| 47 } | |
| 48 | |
| 49 static bool has_color_correction_matrix( | |
| 50 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 51 return display_snapshot->has_color_correction_matrix; | |
| 52 } | |
| 53 | |
| 54 static std::string display_name( | |
| 55 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 56 return display_snapshot->display_name; | |
| 57 } | |
| 58 | |
| 59 static std::string sys_path( | |
| 60 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 61 return display_snapshot->sys_path.value(); | |
| 62 } | |
| 63 | |
| 64 static std::vector<display::DisplayMode> modes( | |
| 65 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 66 return display_snapshot->modes; | |
| 67 } | |
| 68 | |
| 69 static std::vector<uint8_t> edid( | |
| 70 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 71 return display_snapshot->edid; | |
| 72 } | |
| 73 | |
| 74 static display::DisplayMode current_mode( | |
| 75 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 76 return display_snapshot->current_mode; | |
| 77 } | |
| 78 | |
| 79 static display::DisplayMode native_mode( | |
| 80 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 81 return display_snapshot->native_mode; | |
| 82 } | |
| 83 | |
| 84 static int64_t product_id( | |
| 85 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 86 return display_snapshot->product_id; | |
| 87 } | |
| 88 | |
| 89 static gfx::Size maximum_cursor_size( | |
| 90 const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) { | |
| 91 return display_snapshot->maximum_cursor_size; | |
| 92 } | |
| 93 | |
| 94 static bool Read(display::mojom::DisplaySnapshotDataView data, | |
| 95 std::unique_ptr<display::DisplaySnapshot>* out) { | |
| 96 out->display_id = data.display_id(); | |
| 97 | |
| 98 if (!data.ReadOrigin(&out->origin)) | |
| 99 return false; | |
| 100 | |
| 101 if (!data.ReadPhysicalSize(&out->physical_size)) | |
| 102 return false; | |
| 103 | |
| 104 if (!data.ReadType(&out->type)) | |
| 105 return false; | |
| 106 | |
| 107 out->is_aspect_preserving_scaling = data.is_aspect_preserving_scaling(); | |
| 108 out->has_overscan = data.has_overscan(); | |
| 109 out->has_color_correction_matrix = data.has_color_correction_matrix(); | |
| 110 | |
| 111 if (!data.ReadDisplayName(&out->display_name)) | |
| 112 return false; | |
| 113 | |
| 114 base::StringPiece sys_path; | |
| 115 if (!data.ReadSysPath(&sys_path)) | |
| 116 return false; | |
| 117 out->sys_path = base::FilePath(sys_path); | |
| 118 | |
| 119 if (!data.ReadModes(&out->modes)) | |
| 120 return false; | |
| 121 | |
| 122 if (!data.ReadEdid(&out->edid)) | |
| 123 return false; | |
| 124 | |
| 125 if (!data.ReadCurrentMode(&out->current_mode)) | |
| 126 return false; | |
| 127 | |
| 128 if (!data.ReadNativeMode(&out->native_mode)) | |
| 129 return false; | |
| 130 | |
| 131 out->product_id = data.product_id(); | |
| 132 | |
| 133 if (!data.ReadMaximumCursorSize(&out->maximum_cursor_size)) | |
| 134 return false; | |
| 135 | |
| 136 return true; | |
| 137 } | |
| 138 }; | |
| 139 | |
| 140 } // namespace mojo | |
| 141 | |
| 142 #endif // UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_STRUCT_TRAITS_H_ | |
| OLD | NEW |