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.
5 #include "gpu/ipc/gpu_command_buffer_traits.h"
6 #include "gpu/command_buffer/common/mailbox.h"
10 void ParamTraits
<gpu::CommandBuffer::State
> ::Write(Message
* m
,
11 const param_type
& p
) {
12 WriteParam(m
, p
.num_entries
);
13 WriteParam(m
, p
.get_offset
);
14 WriteParam(m
, p
.put_offset
);
15 WriteParam(m
, p
.token
);
16 WriteParam(m
, static_cast<int32
>(p
.error
));
17 WriteParam(m
, p
.generation
);
20 bool ParamTraits
<gpu::CommandBuffer::State
> ::Read(const Message
* m
,
24 if (ReadParam(m
, iter
, &p
->num_entries
) &&
25 ReadParam(m
, iter
, &p
->get_offset
) &&
26 ReadParam(m
, iter
, &p
->put_offset
) &&
27 ReadParam(m
, iter
, &p
->token
) &&
28 ReadParam(m
, iter
, &temp
) &&
29 ReadParam(m
, iter
, &p
->generation
)) {
30 p
->error
= static_cast<gpu::error::Error
>(temp
);
37 void ParamTraits
<gpu::CommandBuffer::State
> ::Log(const param_type
& p
,
39 l
->append("<CommandBuffer::State>");
42 void ParamTraits
<gpu::Mailbox
>::Write(Message
* m
, const param_type
& p
) {
43 m
->WriteBytes(p
.name
, sizeof(p
.name
));
46 bool ParamTraits
<gpu::Mailbox
>::Read(const Message
* m
,
49 const char* bytes
= NULL
;
50 if (!m
->ReadBytes(iter
, &bytes
, sizeof(p
->name
)))
53 memcpy(p
->name
, bytes
, sizeof(p
->name
));
57 void ParamTraits
<gpu::Mailbox
>::Log(const param_type
& p
, std::string
* l
) {
58 for (size_t i
= 0; i
< sizeof(p
.name
); ++i
)
59 *l
+= base::StringPrintf("%02x", p
.name
[i
]);