Chromium Code Reviews| 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..efa02a2b039de153a78ee3ad36df19805f78070a |
| --- /dev/null |
| +++ b/ui/gfx/mojo/accelerated_widget_struct_traits.h |
| @@ -0,0 +1,39 @@ |
| +// 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) |
| + return uint64_t(widget); |
|
dcheng
2016/06/22 14:18:08
Nit: static_cast here and below rather than using
|
| +#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(); |
| + *out = gfx::AcceleratedWidget(w); |
| +#else |
| + NOTIMPLEMENTED(); |
| + *out = 0; |
| +#endif |
| + return true; |
| + } |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // UI_GFX_MOJO_ACCELERATED_WIDGET_STRUCT_TRAITS_H_ |