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

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

Issue 2646213002: Write mojom and StructTraits for DisplaySnapshot. (Closed)
Patch Set: fix format/comments. Refactor structure/code. Created 3 years, 10 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_snapshot_mojo_struct_traits.h
diff --git a/ui/display/mojo/display_snapshot_mojo_struct_traits.h b/ui/display/mojo/display_snapshot_mojo_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..f4eaecc296df5a095b1b4b40ce4e6363c5391b0b
--- /dev/null
+++ b/ui/display/mojo/display_snapshot_mojo_struct_traits.h
@@ -0,0 +1,115 @@
+// 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_SNAPSHOT_MOJO_STRUCT_TRAITS_H_
+#define UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_MOJO_STRUCT_TRAITS_H_
+
+#include "ui/display/display_snapshot_mojo.h"
+#include "ui/display/mojo/display_snapshot_mojo.mojom.h"
+#include "ui/display/types/display_mode.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<display::mojom::DisplaySnapshotMojoDataView,
+ std::unique_ptr<display::DisplaySnapshotMojo>> {
+ static int64_t display_id(const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->display_id();
+ }
+
+ static gfx::Point origin(const std::unique_ptr<display::DisplaySnapshotMojo>&
kylechar 2017/02/13 22:01:24 Return const references if possible, which should
thanhph1 2017/02/14 20:20:53 Done.
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->origin();
+ }
+
+ static gfx::Size physical_size(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->physical_size();
+ }
+
+ static display::DisplayConnectionType type(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->type();
+ }
+
+ static bool is_aspect_preserving_scaling(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->is_aspect_preserving_scaling();
+ }
+
+ static bool has_overscan(const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->has_overscan();
+ }
+
+ static bool has_color_correction_matrix(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->has_color_correction_matrix();
+ }
+
+ static std::string display_name(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->display_name();
+ }
+
+ static const base::FilePath sys_path(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->sys_path();
+ }
+
+ static std::vector<uint8_t> edid(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->edid();
+ }
+
+ static std::vector<std::unique_ptr<display::DisplayMode>> modes(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo);
+
+ static uint64_t current_mode_index(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo);
+
+ static bool current_mode_exist(
kylechar 2017/02/13 22:01:24 has_current_mode
thanhph1 2017/02/14 20:20:53 Done.
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->current_mode_exist();
+ }
+
+ static uint64_t native_mode_index(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo);
+
+ static bool native_mode_exist(
kylechar 2017/02/13 22:01:24 has_native_mode
thanhph1 2017/02/14 20:20:53 Done.
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->native_mode_exist();
+ }
+
+ static int64_t product_id(const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->product_id();
+ }
+
+ static gfx::Size maximum_cursor_size(
+ const std::unique_ptr<display::DisplaySnapshotMojo>&
+ display_snapshot_mojo) {
+ return display_snapshot_mojo->maximum_cursor_size();
+ }
+
+ static bool Read(display::mojom::DisplaySnapshotMojoDataView data,
+ std::unique_ptr<display::DisplaySnapshotMojo>* out);
+};
+
+} // namespace mojo
+
+#endif // UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_MOJO_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698