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

Side by Side Diff: gpu/ipc/gpu_command_buffer_traits.cc

Issue 1714903003: mustash: Move gpu/ipc to gpu/ipc/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Win64 build Created 4 years, 9 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
« no previous file with comments | « gpu/ipc/gpu_command_buffer_traits.h ('k') | gpu/ipc/gpu_command_buffer_traits_multi.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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 #include "gpu/ipc/gpu_command_buffer_traits.h"
6
7 #include <stddef.h>
8 #include <stdint.h>
9
10 #include "gpu/command_buffer/common/command_buffer_id.h"
11 #include "gpu/command_buffer/common/mailbox_holder.h"
12 #include "gpu/command_buffer/common/sync_token.h"
13 #include "gpu/command_buffer/common/value_state.h"
14
15 // Generate param traits size methods.
16 #include "ipc/param_traits_size_macros.h"
17 namespace IPC {
18 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
19 } // namespace IPC
20
21 // Generate param traits write methods.
22 #include "ipc/param_traits_write_macros.h"
23 namespace IPC {
24 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
25 } // namespace IPC
26
27 // Generate param traits read methods.
28 #include "ipc/param_traits_read_macros.h"
29 namespace IPC {
30 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
31 } // namespace IPC
32
33 // Generate param traits log methods.
34 #include "ipc/param_traits_log_macros.h"
35 namespace IPC {
36 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
37 } // namespace IPC
38
39 namespace IPC {
40
41 void ParamTraits<gpu::CommandBuffer::State>::GetSize(base::PickleSizer* s,
42 const param_type& p) {
43 GetParamSize(s, p.get_offset);
44 GetParamSize(s, p.token);
45 GetParamSize(s, p.error);
46 GetParamSize(s, p.generation);
47 }
48
49 void ParamTraits<gpu::CommandBuffer::State>::Write(base::Pickle* m,
50 const param_type& p) {
51 WriteParam(m, p.get_offset);
52 WriteParam(m, p.token);
53 WriteParam(m, p.error);
54 WriteParam(m, p.generation);
55 }
56
57 bool ParamTraits<gpu::CommandBuffer::State>::Read(const base::Pickle* m,
58 base::PickleIterator* iter,
59 param_type* p) {
60 if (ReadParam(m, iter, &p->get_offset) &&
61 ReadParam(m, iter, &p->token) &&
62 ReadParam(m, iter, &p->error) &&
63 ReadParam(m, iter, &p->generation)) {
64 return true;
65 } else {
66 return false;
67 }
68 }
69
70 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p,
71 std::string* l) {
72 l->append("<CommandBuffer::State>");
73 }
74
75 void ParamTraits<gpu::SyncToken>::GetSize(base::PickleSizer* s,
76 const param_type& p) {
77 DCHECK(!p.HasData() || p.verified_flush());
78 GetParamSize(s, p.verified_flush());
79 GetParamSize(s, p.namespace_id());
80 GetParamSize(s, p.command_buffer_id());
81 GetParamSize(s, p.release_count());
82 }
83
84 void ParamTraits<gpu::SyncToken>::Write(base::Pickle* m, const param_type& p) {
85 DCHECK(!p.HasData() || p.verified_flush());
86
87 WriteParam(m, p.verified_flush());
88 WriteParam(m, p.namespace_id());
89 WriteParam(m, p.command_buffer_id());
90 WriteParam(m, p.release_count());
91 }
92
93 bool ParamTraits<gpu::SyncToken>::Read(const base::Pickle* m,
94 base::PickleIterator* iter,
95 param_type* p) {
96 bool verified_flush = false;
97 gpu::CommandBufferNamespace namespace_id =
98 gpu::CommandBufferNamespace::INVALID;
99 gpu::CommandBufferId command_buffer_id;
100 uint64_t release_count = 0;
101
102 if (!ReadParam(m, iter, &verified_flush) ||
103 !ReadParam(m, iter, &namespace_id) ||
104 !ReadParam(m, iter, &command_buffer_id) ||
105 !ReadParam(m, iter, &release_count)) {
106 return false;
107 }
108
109 p->Set(namespace_id, 0, command_buffer_id, release_count);
110 if (p->HasData()) {
111 if (!verified_flush)
112 return false;
113 p->SetVerifyFlush();
114 }
115
116 return true;
117 }
118
119 void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) {
120 *l += base::StringPrintf(
121 "[%" PRId8 ":%" PRIX64 "] %" PRIu64, p.namespace_id(),
122 p.command_buffer_id().GetUnsafeValue(), p.release_count());
123 }
124
125 void ParamTraits<gpu::Mailbox>::GetSize(base::PickleSizer* s,
126 const param_type& p) {
127 s->AddBytes(sizeof(p.name));
128 }
129
130 void ParamTraits<gpu::Mailbox>::Write(base::Pickle* m, const param_type& p) {
131 m->WriteBytes(p.name, sizeof(p.name));
132 }
133
134 bool ParamTraits<gpu::Mailbox>::Read(const base::Pickle* m,
135 base::PickleIterator* iter,
136 param_type* p) {
137 const char* bytes = NULL;
138 if (!iter->ReadBytes(&bytes, sizeof(p->name)))
139 return false;
140 DCHECK(bytes);
141 memcpy(p->name, bytes, sizeof(p->name));
142 return true;
143 }
144
145 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) {
146 for (size_t i = 0; i < sizeof(p.name); ++i)
147 *l += base::StringPrintf("%02x", p.name[i]);
148 }
149
150 void ParamTraits<gpu::MailboxHolder>::GetSize(base::PickleSizer* s,
151 const param_type& p) {
152 GetParamSize(s, p.mailbox);
153 GetParamSize(s, p.sync_token);
154 GetParamSize(s, p.texture_target);
155 }
156
157 void ParamTraits<gpu::MailboxHolder>::Write(base::Pickle* m,
158 const param_type& p) {
159 WriteParam(m, p.mailbox);
160 WriteParam(m, p.sync_token);
161 WriteParam(m, p.texture_target);
162 }
163
164 bool ParamTraits<gpu::MailboxHolder>::Read(const base::Pickle* m,
165 base::PickleIterator* iter,
166 param_type* p) {
167 if (!ReadParam(m, iter, &p->mailbox) || !ReadParam(m, iter, &p->sync_token) ||
168 !ReadParam(m, iter, &p->texture_target))
169 return false;
170 return true;
171 }
172
173 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) {
174 LogParam(p.mailbox, l);
175 LogParam(p.sync_token, l);
176 *l += base::StringPrintf(":%04x@", p.texture_target);
177 }
178
179 void ParamTraits<gpu::ValueState>::GetSize(base::PickleSizer* s,
180 const param_type& p) {
181 s->AddData(sizeof(gpu::ValueState));
182 }
183
184 void ParamTraits<gpu::ValueState>::Write(base::Pickle* m, const param_type& p) {
185 m->WriteData(reinterpret_cast<const char*>(&p),
186 sizeof(gpu::ValueState));
187 }
188
189 bool ParamTraits<gpu::ValueState>::Read(const base::Pickle* m,
190 base::PickleIterator* iter,
191 param_type* p) {
192 int length;
193 const char* data = NULL;
194 if (!iter->ReadData(&data, &length) || length != sizeof(gpu::ValueState))
195 return false;
196 DCHECK(data);
197 memcpy(p, data, sizeof(gpu::ValueState));
198 return true;
199 }
200
201 void ParamTraits<gpu::ValueState>::Log(const param_type& p, std::string* l) {
202 l->append("<ValueState (");
203 for (int value : p.int_value)
204 *l += base::StringPrintf("%i ", value);
205 l->append(" int values ");
206 for (float value : p.float_value)
207 *l += base::StringPrintf("%f ", value);
208 l->append(" float values)>");
209 }
210
211 } // namespace IPC
OLDNEW
« no previous file with comments | « gpu/ipc/gpu_command_buffer_traits.h ('k') | gpu/ipc/gpu_command_buffer_traits_multi.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698