OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_ |
| 6 #define UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include "ui/gfx/mojo/accelerated_widget.mojom.h" |
| 9 #include "ui/gfx/native_widget_types.h" |
| 10 |
| 11 namespace mojo { |
| 12 |
| 13 template <> |
| 14 struct StructTraits<gfx::mojom::AcceleratedWidget, gfx::AcceleratedWidget> { |
| 15 static uint64_t widget(const gfx::AcceleratedWidget& widget) { |
| 16 #if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11) |
| 17 #if defined(OS_WIN) |
| 18 return reinterpret_cast<uint64_t>(widget); |
| 19 #else |
| 20 return static_cast<uint64_t>(widget); |
| 21 #endif |
| 22 #else |
| 23 NOTIMPLEMENTED(); |
| 24 return 0; |
| 25 #endif |
| 26 } |
| 27 |
| 28 static bool Read(gfx::mojom::AcceleratedWidgetDataView data, |
| 29 gfx::AcceleratedWidget* out) { |
| 30 #if defined(OS_WIN) || defined(USE_OZONE) || defined(USE_X11) |
| 31 uint64_t w = data.widget(); |
| 32 #if defined(OS_WIN) |
| 33 *out = reinterpret_cast<gfx::AcceleratedWidget>(w); |
| 34 #else |
| 35 *out = static_cast<gfx::AcceleratedWidget>(w); |
| 36 #endif |
| 37 #else |
| 38 NOTIMPLEMENTED(); |
| 39 *out = 0; |
| 40 #endif |
| 41 return true; |
| 42 } |
| 43 }; |
| 44 |
| 45 } // namespace mojo |
| 46 |
| 47 #endif // UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_ |
OLD | NEW |