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

Unified Diff: ui/display/mojo/display_mode_struct_traits.h

Issue 2636073002: Create mojom and StructTraits for ui/display/types/display_mode.cc (Closed)
Patch Set: Change structure not to use display_mode_mojo.(cc|h). Instead, use friend class in display_mode.h. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/display/mojo/display_mode_struct_traits.h
diff --git a/ui/display/mojo/display_mode_struct_traits.h b/ui/display/mojo/display_mode_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..5b8e87011f8ea63c72256899fcb2bbc80ca84fd4
--- /dev/null
+++ b/ui/display/mojo/display_mode_struct_traits.h
@@ -0,0 +1,44 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_DISPLAY_MOJO_DISPLAY_MODE_STRUCT_TRAITS_H_
+#define UI_DISPLAY_MOJO_DISPLAY_MODE_STRUCT_TRAITS_H_
+
+#include "ui/display/types/display_mode.h"
+#include "ui/display/mojo/display_mode.mojom.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<display::mojom::DisplayModeDataView,
+ display::DisplayMode> {
kylechar 2017/01/25 16:59:45 Please run "git cl format".
thanhph1 2017/01/25 20:28:39 Done.
+ static const gfx::Size& size(
+ const display::DisplayMode& display_mode) {
+ return display_mode.size();
+ }
+
+ static bool is_interlaced(const display::DisplayMode& display_mode) {
+ return display_mode.is_interlaced();
+ }
+
+ static float refresh_rate(const display::DisplayMode& display_mode) {
+ return display_mode.refresh_rate();
+ }
+
+ static bool Read(display::mojom::DisplayModeDataView data,
+ display::DisplayMode* out) {
+ if (!data.ReadSize(&out->size_ ))
+ return false;
+
+ out->is_interlaced_ = data.is_interlaced();
+ out->refresh_rate_ = data.refresh_rate();
+
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_DISPLAY_MOJO_DISPLAY_MODE_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698