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_holder.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
]);
62 void ParamTraits
<gpu::MailboxHolder
>::Write(Message
* m
, const param_type
& p
) {
63 WriteParam(m
, p
.mailbox
);
64 WriteParam(m
, p
.texture_target
);
65 WriteParam(m
, p
.sync_point
);
68 bool ParamTraits
<gpu::MailboxHolder
>::Read(const Message
* m
,
71 if (!ReadParam(m
, iter
, &p
->mailbox
) ||
72 !ReadParam(m
, iter
, &p
->texture_target
) ||
73 !ReadParam(m
, iter
, &p
->sync_point
))
78 void ParamTraits
<gpu::MailboxHolder
>::Log(const param_type
& p
, std::string
* l
) {
79 ParamTraits
<gpu::Mailbox
>::Log(p
.mailbox
, l
);
80 *l
+= base::StringPrintf(":%04x@%d", p
.texture_target
, p
.sync_point
);