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

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

Issue 2646213002: Write mojom and StructTraits for DisplaySnapshot. (Closed)
Patch Set: use FILE_PATH_LITERAL to create base::FilePath::StringType 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_struct_traits.h
diff --git a/ui/display/mojo/display_snapshot_struct_traits.h b/ui/display/mojo/display_snapshot_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..aa3de974984b46b049265fc0d03b6ffc2d6bd562
--- /dev/null
+++ b/ui/display/mojo/display_snapshot_struct_traits.h
@@ -0,0 +1,142 @@
+// 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.
+// 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_STRUCT_TRAITS_H_
+#define UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_STRUCT_TRAITS_H_
+
+#include "ui/display/mojo/display_constants.mojom-shared.h"
+#include "ui/display/mojo/display_constants_struct_traits.h"
+#include "ui/display/mojo/display_snapshot.mojom.h"
+#include "ui/display/types/display_constants.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<display::mojom::DisplaySnapshotDataView,
+ std::unique_ptr<display::DisplaySnapshot>> {
+ static int64_t display_id(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->display_id;
+ }
+
+ static gfx::Point origin(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->origin;
+ }
+
+ static gfx::Size physical_size(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->physical_size;
+ }
+
+ static const display::DisplayConnectionType& type(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->type;
+ }
+
+ static bool is_aspect_preserving_scaling(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->is_aspect_preserving_scaling;
+ }
+
+ static bool has_overscan(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->has_overscan;
+ }
+
+ static bool has_color_correction_matrix(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->has_color_correction_matrix;
+ }
+
+ static std::string display_name(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->display_name;
+ }
+
+ static std::string sys_path(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->sys_path.value();
+ }
+
+ static std::vector<display::DisplayMode> modes(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->modes;
+ }
+
+ static std::vector<uint8_t> edid(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->edid;
+ }
+
+ static display::DisplayMode current_mode(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->current_mode;
+ }
+
+ static display::DisplayMode native_mode(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->native_mode;
+ }
+
+ static int64_t product_id(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->product_id;
+ }
+
+ static gfx::Size maximum_cursor_size(
+ const std::unique_ptr<display::DisplaySnapshot>& display_snapshot) {
+ return display_snapshot->maximum_cursor_size;
+ }
+
+ static bool Read(display::mojom::DisplaySnapshotDataView data,
+ std::unique_ptr<display::DisplaySnapshot>* out) {
+ out->display_id = data.display_id();
+
+ if (!data.ReadOrigin(&out->origin))
+ return false;
+
+ if (!data.ReadPhysicalSize(&out->physical_size))
+ return false;
+
+ if (!data.ReadType(&out->type))
+ return false;
+
+ out->is_aspect_preserving_scaling = data.is_aspect_preserving_scaling();
+ out->has_overscan = data.has_overscan();
+ out->has_color_correction_matrix = data.has_color_correction_matrix();
+
+ if (!data.ReadDisplayName(&out->display_name))
+ return false;
+
+ base::StringPiece sys_path;
+ if (!data.ReadSysPath(&sys_path))
+ return false;
+ out->sys_path = base::FilePath(sys_path);
+
+ if (!data.ReadModes(&out->modes))
+ return false;
+
+ if (!data.ReadEdid(&out->edid))
+ return false;
+
+ if (!data.ReadCurrentMode(&out->current_mode))
+ return false;
+
+ if (!data.ReadNativeMode(&out->native_mode))
+ return false;
+
+ out->product_id = data.product_id();
+
+ if (!data.ReadMaximumCursorSize(&out->maximum_cursor_size))
+ return false;
+
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_DISPLAY_MOJO_DISPLAY_SNAPSHOT_STRUCT_TRAITS_H_

Powered by Google App Engine
This is Rietveld 408576698