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

Unified Diff: ui/gfx/mojo/accelerated_widget_struct_traits.h

Issue 2071163002: Add StructTraits for AcceleratedWidget instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 6 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/gfx/mojo/accelerated_widget.typemap ('k') | ui/gfx/mojo/struct_traits_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/mojo/accelerated_widget_struct_traits.h
diff --git a/ui/gfx/mojo/accelerated_widget_struct_traits.h b/ui/gfx/mojo/accelerated_widget_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..922a07ba6b7d6b39ca04ecbabb077633dba0ddcb
--- /dev/null
+++ b/ui/gfx/mojo/accelerated_widget_struct_traits.h
@@ -0,0 +1,47 @@
+// Copyright 2016 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_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_
+#define UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_
+
+#include "ui/gfx/mojo/accelerated_widget.mojom.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<gfx::mojom::AcceleratedWidget, gfx::AcceleratedWidget> {
+ static uint64_t widget(const gfx::AcceleratedWidget& widget) {
+#if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11)
+#if defined(OS_WIN)
+ return reinterpret_cast<uint64_t>(widget);
+#else
+ return static_cast<uint64_t>(widget);
+#endif
+#else
+ NOTIMPLEMENTED();
+ return 0;
+#endif
+ }
+
+ static bool Read(gfx::mojom::AcceleratedWidgetDataView data,
+ gfx::AcceleratedWidget* out) {
+#if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11)
+ uint64_t w = data.widget();
+#if defined(OS_WIN)
+ *out = reinterpret_cast<gfx::AcceleratedWidget>(w);
+#else
+ *out = static_cast<gfx::AcceleratedWidget>(w);
+#endif
+#else
+ NOTIMPLEMENTED();
+ *out = 0;
+#endif
+ return true;
+ }
+};
+
+} // namespace mojo
+
+#endif // UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_
« no previous file with comments | « ui/gfx/mojo/accelerated_widget.typemap ('k') | ui/gfx/mojo/struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698