Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: gpu/ipc/gpu_command_buffer_traits.cc

Issue 1154283003: Change most uses of Pickle to base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/user_script_set.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/ipc/gpu_command_buffer_traits.h" 5 #include "gpu/ipc/gpu_command_buffer_traits.h"
6 6
7 #include "gpu/command_buffer/common/mailbox_holder.h" 7 #include "gpu/command_buffer/common/mailbox_holder.h"
8 #include "gpu/command_buffer/common/value_state.h" 8 #include "gpu/command_buffer/common/value_state.h"
9 9
10 // Generate param traits write methods. 10 // Generate param traits write methods.
(...skipping 18 matching lines...) Expand all
29 29
30 void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m, 30 void ParamTraits<gpu::CommandBuffer::State> ::Write(Message* m,
31 const param_type& p) { 31 const param_type& p) {
32 WriteParam(m, p.get_offset); 32 WriteParam(m, p.get_offset);
33 WriteParam(m, p.token); 33 WriteParam(m, p.token);
34 WriteParam(m, static_cast<int32>(p.error)); 34 WriteParam(m, static_cast<int32>(p.error));
35 WriteParam(m, p.generation); 35 WriteParam(m, p.generation);
36 } 36 }
37 37
38 bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m, 38 bool ParamTraits<gpu::CommandBuffer::State> ::Read(const Message* m,
39 PickleIterator* iter, 39 base::PickleIterator* iter,
40 param_type* p) { 40 param_type* p) {
41 int32 temp; 41 int32 temp;
42 if (ReadParam(m, iter, &p->get_offset) && 42 if (ReadParam(m, iter, &p->get_offset) &&
43 ReadParam(m, iter, &p->token) && 43 ReadParam(m, iter, &p->token) &&
44 ReadParam(m, iter, &temp) && 44 ReadParam(m, iter, &temp) &&
45 ReadParam(m, iter, &p->generation)) { 45 ReadParam(m, iter, &p->generation)) {
46 p->error = static_cast<gpu::error::Error>(temp); 46 p->error = static_cast<gpu::error::Error>(temp);
47 return true; 47 return true;
48 } else { 48 } else {
49 return false; 49 return false;
50 } 50 }
51 } 51 }
52 52
53 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p, 53 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p,
54 std::string* l) { 54 std::string* l) {
55 l->append("<CommandBuffer::State>"); 55 l->append("<CommandBuffer::State>");
56 } 56 }
57 57
58 void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) { 58 void ParamTraits<gpu::Mailbox>::Write(Message* m, const param_type& p) {
59 m->WriteBytes(p.name, sizeof(p.name)); 59 m->WriteBytes(p.name, sizeof(p.name));
60 } 60 }
61 61
62 bool ParamTraits<gpu::Mailbox>::Read(const Message* m, 62 bool ParamTraits<gpu::Mailbox> ::Read(const Message* m,
63 PickleIterator* iter, 63 base::PickleIterator* iter,
64 param_type* p) { 64 param_type* p) {
65 const char* bytes = NULL; 65 const char* bytes = NULL;
66 if (!iter->ReadBytes(&bytes, sizeof(p->name))) 66 if (!iter->ReadBytes(&bytes, sizeof(p->name)))
67 return false; 67 return false;
68 DCHECK(bytes); 68 DCHECK(bytes);
69 memcpy(p->name, bytes, sizeof(p->name)); 69 memcpy(p->name, bytes, sizeof(p->name));
70 return true; 70 return true;
71 } 71 }
72 72
73 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) { 73 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) {
74 for (size_t i = 0; i < sizeof(p.name); ++i) 74 for (size_t i = 0; i < sizeof(p.name); ++i)
75 *l += base::StringPrintf("%02x", p.name[i]); 75 *l += base::StringPrintf("%02x", p.name[i]);
76 } 76 }
77 77
78 void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) { 78 void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) {
79 WriteParam(m, p.mailbox); 79 WriteParam(m, p.mailbox);
80 WriteParam(m, p.texture_target); 80 WriteParam(m, p.texture_target);
81 WriteParam(m, p.sync_point); 81 WriteParam(m, p.sync_point);
82 } 82 }
83 83
84 bool ParamTraits<gpu::MailboxHolder>::Read(const Message* m, 84 bool ParamTraits<gpu::MailboxHolder> ::Read(const Message* m,
85 PickleIterator* iter, 85 base::PickleIterator* iter,
86 param_type* p) { 86 param_type* p) {
87 if (!ReadParam(m, iter, &p->mailbox) || 87 if (!ReadParam(m, iter, &p->mailbox) ||
88 !ReadParam(m, iter, &p->texture_target) || 88 !ReadParam(m, iter, &p->texture_target) ||
89 !ReadParam(m, iter, &p->sync_point)) 89 !ReadParam(m, iter, &p->sync_point))
90 return false; 90 return false;
91 return true; 91 return true;
92 } 92 }
93 93
94 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) { 94 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) {
95 ParamTraits<gpu::Mailbox>::Log(p.mailbox, l); 95 ParamTraits<gpu::Mailbox>::Log(p.mailbox, l);
96 *l += base::StringPrintf(":%04x@%d", p.texture_target, p.sync_point); 96 *l += base::StringPrintf(":%04x@%d", p.texture_target, p.sync_point);
97 } 97 }
98 98
99 void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) { 99 void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) {
100 m->WriteData(reinterpret_cast<const char*>(&p), 100 m->WriteData(reinterpret_cast<const char*>(&p),
101 sizeof(gpu::ValueState)); 101 sizeof(gpu::ValueState));
102 } 102 }
103 103
104 bool ParamTraits<gpu::ValueState>::Read(const Message* m, 104 bool ParamTraits<gpu::ValueState> ::Read(const Message* m,
105 PickleIterator* iter, 105 base::PickleIterator* iter,
106 param_type* p) { 106 param_type* p) {
107 int length; 107 int length;
108 const char* data = NULL; 108 const char* data = NULL;
109 if (!iter->ReadData(&data, &length) || length != sizeof(gpu::ValueState)) 109 if (!iter->ReadData(&data, &length) || length != sizeof(gpu::ValueState))
110 return false; 110 return false;
111 DCHECK(data); 111 DCHECK(data);
112 memcpy(p, data, sizeof(gpu::ValueState)); 112 memcpy(p, data, sizeof(gpu::ValueState));
113 return true; 113 return true;
114 } 114 }
115 115
116 void ParamTraits<gpu::ValueState>::Log(const param_type& p, std::string* l) { 116 void ParamTraits<gpu::ValueState>::Log(const param_type& p, std::string* l) {
117 l->append("<ValueState ("); 117 l->append("<ValueState (");
118 for (size_t i = 0; i < sizeof(p.int_value); ++i) 118 for (size_t i = 0; i < sizeof(p.int_value); ++i)
119 *l += base::StringPrintf("%i ", p.int_value[i]); 119 *l += base::StringPrintf("%i ", p.int_value[i]);
120 l->append(" int values "); 120 l->append(" int values ");
121 for (size_t i = 0; i < sizeof(p.float_value); ++i) 121 for (size_t i = 0; i < sizeof(p.float_value); ++i)
122 *l += base::StringPrintf("%f ", p.float_value[i]); 122 *l += base::StringPrintf("%f ", p.float_value[i]);
123 l->append(" float values)>"); 123 l->append(" float values)>");
124 } 124 }
125 125
126 } // namespace IPC 126 } // namespace IPC
OLDNEW
« no previous file with comments | « extensions/renderer/user_script_set.cc ('k') | ipc/ipc_channel_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698