| 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 #include "gpu/ipc/common/mailbox_struct_traits.h" | 5 #include "gpu/ipc/common/mailbox_struct_traits.h" |
| 6 | 6 |
| 7 namespace mojo { | 7 namespace mojo { |
| 8 | 8 |
| 9 // static | 9 // static |
| 10 size_t ArrayTraits<MailboxName>::GetSize(const MailboxName& b) { | |
| 11 return GL_MAILBOX_SIZE_CHROMIUM; | |
| 12 } | |
| 13 | |
| 14 // static | |
| 15 int8_t* ArrayTraits<MailboxName>::GetData(MailboxName& b) { | |
| 16 return b.data; | |
| 17 } | |
| 18 | |
| 19 // static | |
| 20 const int8_t* ArrayTraits<MailboxName>::GetData(const MailboxName& b) { | |
| 21 return b.data; | |
| 22 } | |
| 23 | |
| 24 // static | |
| 25 int8_t& ArrayTraits<MailboxName>::GetAt(MailboxName& b, size_t i) { | |
| 26 return b.data[i]; | |
| 27 } | |
| 28 | |
| 29 // static | |
| 30 const int8_t& ArrayTraits<MailboxName>::GetAt(const MailboxName& b, size_t i) { | |
| 31 return b.data[i]; | |
| 32 } | |
| 33 | |
| 34 // static | |
| 35 bool ArrayTraits<MailboxName>::Resize(MailboxName& b, size_t size) { | |
| 36 return GL_MAILBOX_SIZE_CHROMIUM == size; | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 MailboxName StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::name( | 10 MailboxName StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::name( |
| 41 const gpu::Mailbox& mailbox) { | 11 const gpu::Mailbox& mailbox) { |
| 42 MailboxName mailbox_name; | 12 MailboxName mailbox_name = {GL_MAILBOX_SIZE_CHROMIUM, |
| 43 mailbox_name.data = const_cast<int8_t*>(&mailbox.name[0]); | 13 GL_MAILBOX_SIZE_CHROMIUM, |
| 14 const_cast<int8_t*>(&mailbox.name[0])}; |
| 44 return mailbox_name; | 15 return mailbox_name; |
| 45 } | 16 } |
| 46 | 17 |
| 47 // static | 18 // static |
| 48 bool StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::Read( | 19 bool StructTraits<gpu::mojom::Mailbox, gpu::Mailbox>::Read( |
| 49 gpu::mojom::MailboxDataView data, | 20 gpu::mojom::MailboxDataView data, |
| 50 gpu::Mailbox* out) { | 21 gpu::Mailbox* out) { |
| 51 MailboxName mailbox_name; | 22 MailboxName mailbox_name = {0, GL_MAILBOX_SIZE_CHROMIUM, &out->name[0]}; |
| 52 mailbox_name.data = &out->name[0]; | |
| 53 return data.ReadName(&mailbox_name); | 23 return data.ReadName(&mailbox_name); |
| 54 } | 24 } |
| 55 | 25 |
| 56 } // namespace mojo | 26 } // namespace mojo |
| OLD | NEW |