ftp: reenable disabled date parsing test
[chromium-blink-merge.git] / gpu / ipc / gpu_command_buffer_traits.cc
blob8d2148de0f7842d9741cbb61ba6fed3f18450810
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"
7 #include "gpu/command_buffer/common/mailbox_holder.h"
8 #include "gpu/command_buffer/common/value_state.h"
10 // Generate param traits write methods.
11 #include "ipc/param_traits_write_macros.h"
12 namespace IPC {
13 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
14 } // namespace IPC
16 // Generate param traits read methods.
17 #include "ipc/param_traits_read_macros.h"
18 namespace IPC {
19 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
20 } // namespace IPC
22 // Generate param traits log methods.
23 #include "ipc/param_traits_log_macros.h"
24 namespace IPC {
25 #include "gpu/ipc/gpu_command_buffer_traits_multi.h"
26 } // namespace IPC
28 namespace IPC {
30 void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m,
31 const param_type& p) {
32 WriteParam(m, p.get_offset);
33 WriteParam(m, p.token);
34 WriteParam(m, static_cast<int32>(p.error));
35 WriteParam(m, p.generation);
38 bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m,
39 base::PickleIterator* iter,
40 param_type* p) {
41 int32 temp;
42 if (ReadParam(m, iter, &p->get_offset) &&
43 ReadParam(m, iter, &p->token) &&
44 ReadParam(m, iter, &temp) &&
45 ReadParam(m, iter, &p->generation)) {
46 p->error = static_cast<gpu::error::Error>(temp);
47 return true;
48 } else {
49 return false;
53 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p,
54 std::string* l) {
55 l->append("<CommandBuffer::State>");
58 void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) {
59 m->WriteBytes(p.name, sizeof(p.name));
62 bool ParamTraits<gpu::Mailbox> ::Read(const Message* m,
63 base::PickleIterator* iter,
64 param_type* p) {
65 const char* bytes = NULL;
66 if (!iter->ReadBytes(&bytes, sizeof(p->name)))
67 return false;
68 DCHECK(bytes);
69 memcpy(p->name, bytes, sizeof(p->name));
70 return true;
73 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) {
74 for (size_t i = 0; i < sizeof(p.name); ++i)
75 *l += base::StringPrintf("%02x", p.name[i]);
78 void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) {
79 WriteParam(m, p.mailbox);
80 WriteParam(m, p.texture_target);
81 WriteParam(m, p.sync_point);
84 bool ParamTraits<gpu::MailboxHolder> ::Read(const Message* m,
85 base::PickleIterator* iter,
86 param_type* p) {
87 if (!ReadParam(m, iter, &p->mailbox) ||
88 !ReadParam(m, iter, &p->texture_target) ||
89 !ReadParam(m, iter, &p->sync_point))
90 return false;
91 return true;
94 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) {
95 ParamTraits<gpu::Mailbox>::Log(p.mailbox, l);
96 *l += base::StringPrintf(":%04x@%d", p.texture_target, p.sync_point);
99 void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) {
100 m->WriteData(reinterpret_cast<const char*>(&p),
101 sizeof(gpu::ValueState));
104 bool ParamTraits<gpu::ValueState> ::Read(const Message* m,
105 base::PickleIterator* iter,
106 param_type* p) {
107 int length;
108 const char* data = NULL;
109 if (!iter->ReadData(&data, &length) || length != sizeof(gpu::ValueState))
110 return false;
111 DCHECK(data);
112 memcpy(p, data, sizeof(gpu::ValueState));
113 return true;
116 void ParamTraits<gpu::ValueState>::Log(const param_type& p, std::string* l) {
117 l->append("<ValueState (");
118 for (size_t i = 0; i < sizeof(p.int_value); ++i)
119 *l += base::StringPrintf("%i ", p.int_value[i]);
120 l->append(" int values ");
121 for (size_t i = 0; i < sizeof(p.float_value); ++i)
122 *l += base::StringPrintf("%f ", p.float_value[i]);
123 l->append(" float values)>");
126 } // namespace IPC