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

Side by Side Diff: gpu/ipc/common/mailbox_struct_traits.cc

Issue 2046563005: Add ArrayTraits<CArray<T>> utility template (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Yuzhu's comment 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 unified diff | Download patch
OLDNEW
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,
Tom Sepez 2016/06/08 17:38:47 nit: can this be just return {GL_MAILBOX_SIZE_C
Fady Samuel 2016/06/08 17:48:03 Done.
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698