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

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: remove expect_true in void function 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
« no previous file with comments | « ui/display/mojo/display_mode.typemap ('k') | ui/display/mojo/display_struct_traits_test.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..8d7d2bc08c42308841978b1bcffa6988435b9d90
--- /dev/null
+++ b/ui/display/mojo/display_mode_struct_traits.h
@@ -0,0 +1,45 @@
+// 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,
+ std::unique_ptr<display::DisplayMode>> {
+ static const gfx::Size& size(
+ const std::unique_ptr<display::DisplayMode>& display_mode) {
+ return display_mode->size();
+ }
+
+ static bool is_interlaced(
+ const std::unique_ptr<display::DisplayMode>& display_mode) {
+ return display_mode->is_interlaced();
+ }
+
+ static float refresh_rate(
+ const std::unique_ptr<display::DisplayMode>& display_mode) {
+ return display_mode->refresh_rate();
+ }
+
+ static bool Read(display::mojom::DisplayModeDataView data,
+ std::unique_ptr<display::DisplayMode>* out) {
+ gfx::Size size;
+ if (!data.ReadSize(&size))
+ return false;
+ *out = base::MakeUnique<display::DisplayMode>(size, data.is_interlaced(),
+ data.refresh_rate());
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_DISPLAY_MOJO_DISPLAY_MODE_STRUCT_TRAITS_H_
« no previous file with comments | « ui/display/mojo/display_mode.typemap ('k') | ui/display/mojo/display_struct_traits_test.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698