// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "gpu/ipc/gpu_command_buffer_traits.h" #include "gpu/command_buffer/common/mailbox.h" namespace IPC { void ParamTraits ::Write(Message* m, const param_type& p) { WriteParam(m, p.num_entries); WriteParam(m, p.get_offset); WriteParam(m, p.put_offset); WriteParam(m, p.token); WriteParam(m, static_cast(p.error)); WriteParam(m, p.generation); } bool ParamTraits ::Read(const Message* m, PickleIterator* iter, param_type* p) { int32 temp; if (ReadParam(m, iter, &p->num_entries) && ReadParam(m, iter, &p->get_offset) && ReadParam(m, iter, &p->put_offset) && ReadParam(m, iter, &p->token) && ReadParam(m, iter, &temp) && ReadParam(m, iter, &p->generation)) { p->error = static_cast(temp); return true; } else { return false; } } void ParamTraits ::Log(const param_type& p, std::string* l) { l->append(""); } void ParamTraits::Write(Message* m, const param_type& p) { m->WriteBytes(p.name, sizeof(p.name)); } bool ParamTraits::Read(const Message* m, PickleIterator* iter, param_type* p) { const char* bytes = NULL; if (!m->ReadBytes(iter, &bytes, sizeof(p->name))) return false; DCHECK(bytes); memcpy(p->name, bytes, sizeof(p->name)); return true; } void ParamTraits::Log(const param_type& p, std::string* l) { for (size_t i = 0; i < sizeof(p.name); ++i) *l += base::StringPrintf("%02x", p.name[i]); } } // namespace IPC