| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ | 5 #ifndef GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ |
| 6 #define GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ | 6 #define GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ |
| 7 | 7 |
| 8 #include "gpu/command_buffer/common/mailbox.h" | 8 #include "gpu/command_buffer/common/mailbox.h" |
| 9 #include "gpu/ipc/common/mailbox.mojom.h" | 9 #include "gpu/ipc/common/mailbox.mojom.h" |
| 10 #include "mojo/public/cpp/bindings/array_traits.h" | 10 #include "mojo/public/cpp/bindings/array_traits.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 | 13 |
| 14 // A buffer used to read bytes directly from MailboxDataView to gpu::Mailbox | 14 // A buffer used to read bytes directly from MailboxDataView to gpu::Mailbox |
| 15 // name. | 15 // name. |
| 16 struct MailboxName { | 16 struct MailboxName { |
| 17 int8_t* data; | 17 int8_t* data; |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 // ArrayTraits needed for ReadName use with MailboxName. | 20 // ArrayTraits needed for ReadName use with MailboxName. |
| 21 template <> | 21 template <> |
| 22 struct ArrayTraits<MailboxName> { | 22 struct ArrayTraits<MailboxName> { |
| 23 using Element = int8_t; | 23 using Element = int8_t; |
| 24 static size_t GetSize(const MailboxName& b); | 24 static size_t GetSize(const MailboxName& b); |
| 25 static int8_t* GetData(MailboxName& b); | 25 static int8_t* GetData(MailboxName& b); |
| 26 static const int8_t* GetData(const MailboxName& b); | 26 static const int8_t* GetData(const MailboxName& b); |
| 27 static int8_t& GetAt(MailboxName& b, size_t i); | 27 static int8_t& GetAt(MailboxName& b, size_t i); |
| 28 static const int8_t& GetAt(const MailboxName& b, size_t i); | 28 static const int8_t& GetAt(const MailboxName& b, size_t i); |
| 29 static void Resize(MailboxName& b, size_t size); | 29 static bool Resize(MailboxName& b, size_t size); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 template <> | 32 template <> |
| 33 struct StructTraits<gpu::mojom::Mailbox, gpu::Mailbox> { | 33 struct StructTraits<gpu::mojom::Mailbox, gpu::Mailbox> { |
| 34 static MailboxName name(const gpu::Mailbox& mailbox); | 34 static MailboxName name(const gpu::Mailbox& mailbox); |
| 35 static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out); | 35 static bool Read(gpu::mojom::MailboxDataView data, gpu::Mailbox* out); |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 } // namespace mojo | 38 } // namespace mojo |
| 39 | 39 |
| 40 #endif // GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ | 40 #endif // GPU_IPC_COMMON_MAILBOX_STRUCT_TRAITS_H_ |
| OLD | NEW |