Home | History | Annotate | Download | only in ipc
      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 #include "gpu/command_buffer/common/mailbox.h"
      7 
      8 namespace IPC {
      9 
     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);
     18 }
     19 
     20 bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m,
     21                                                    PickleIterator* iter,
     22                                                    param_type* p) {
     23   int32 temp;
     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);
     31     return true;
     32   } else {
     33     return false;
     34   }
     35 }
     36 
     37 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p,
     38                                                   std::string* l) {
     39   l->append("<CommandBuffer::State>");
     40 }
     41 
     42 void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) {
     43   m->WriteBytes(p.name, sizeof(p.name));
     44 }
     45 
     46 bool ParamTraits<gpu::Mailbox>::Read(const Message* m,
     47                                      PickleIterator* iter,
     48                                      param_type* p) {
     49   const char* bytes = NULL;
     50   if (!m->ReadBytes(iter, &bytes, sizeof(p->name)))
     51     return false;
     52   DCHECK(bytes);
     53   memcpy(p->name, bytes, sizeof(p->name));
     54   return true;
     55 }
     56 
     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]);
     60 }
     61 
     62 
     63 }  // namespace IPC
     64