OLD | NEW |
---|---|
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/sync_token.h" | 8 #include "gpu/command_buffer/common/sync_token.h" |
9 #include "gpu/command_buffer/common/value_state.h" | 9 #include "gpu/command_buffer/common/value_state.h" |
10 | 10 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 return false; | 50 return false; |
51 } | 51 } |
52 } | 52 } |
53 | 53 |
54 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p, | 54 void ParamTraits<gpu::CommandBuffer::State> ::Log(const param_type& p, |
55 std::string* l) { | 55 std::string* l) { |
56 l->append("<CommandBuffer::State>"); | 56 l->append("<CommandBuffer::State>"); |
57 } | 57 } |
58 | 58 |
59 void ParamTraits<gpu::SyncToken>::Write(Message* m, const param_type& p) { | 59 void ParamTraits<gpu::SyncToken>::Write(Message* m, const param_type& p) { |
60 DCHECK(!p.HasData() || p.verified_flush()); | |
61 const bool verified_flush = p.verified_flush(); | |
60 const int namespace_id = static_cast<int>(p.namespace_id()); | 62 const int namespace_id = static_cast<int>(p.namespace_id()); |
61 const uint64_t command_buffer_id = p.command_buffer_id(); | 63 const uint64_t command_buffer_id = p.command_buffer_id(); |
62 const uint64_t release_count = p.release_count(); | 64 const uint64_t release_count = p.release_count(); |
63 | 65 |
64 m->WriteBytes(&namespace_id, sizeof(namespace_id)); | 66 m->WriteBool(verified_flush); |
65 m->WriteBytes(&command_buffer_id, sizeof(command_buffer_id)); | 67 m->WriteInt(namespace_id); |
66 m->WriteBytes(&release_count, sizeof(release_count)); | 68 m->WriteUInt64(command_buffer_id); |
69 m->WriteUInt64(release_count); | |
67 } | 70 } |
68 | 71 |
69 bool ParamTraits<gpu::SyncToken>::Read(const Message* m, | 72 bool ParamTraits<gpu::SyncToken>::Read(const Message* m, |
70 base::PickleIterator* iter, | 73 base::PickleIterator* iter, |
71 param_type* p) { | 74 param_type* p) { |
75 bool verified_flush = false; | |
76 if (!iter->ReadBool(&verified_flush)) | |
77 return false; | |
78 | |
72 int namespace_id = -1; | 79 int namespace_id = -1; |
73 if (!iter->ReadInt(&namespace_id)) | 80 if (!iter->ReadInt(&namespace_id)) |
74 return false; | 81 return false; |
75 | 82 |
76 uint64_t command_buffer_id = 0; | 83 uint64_t command_buffer_id = 0; |
77 if (!iter->ReadUInt64(&command_buffer_id)) | 84 if (!iter->ReadUInt64(&command_buffer_id)) |
78 return false; | 85 return false; |
79 | 86 |
80 uint64_t release_count = 0; | 87 uint64_t release_count = 0; |
81 if (!iter->ReadUInt64(&release_count)) | 88 if (!iter->ReadUInt64(&release_count)) |
82 return false; | 89 return false; |
83 | 90 |
84 p->Set(static_cast<gpu::CommandBufferNamespace>(namespace_id), | 91 p->Set(static_cast<gpu::CommandBufferNamespace>(namespace_id), |
85 command_buffer_id, | 92 command_buffer_id, |
86 release_count); | 93 release_count); |
94 | |
95 if (p->HasData()) { | |
96 if (!verified_flush) | |
97 return false; | |
98 p->SetVerifyFlush(); | |
99 } | |
100 | |
87 return true; | 101 return true; |
88 } | 102 } |
89 | 103 |
90 void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) { | 104 void ParamTraits<gpu::SyncToken>::Log(const param_type& p, std::string* l) { |
91 *l += | 105 *l += |
92 base::StringPrintf("[%d:%llX] %llu", static_cast<int>(p.namespace_id()), | 106 base::StringPrintf("[%d:%llX] %llu", static_cast<int>(p.namespace_id()), |
93 static_cast<unsigned long long>(p.command_buffer_id()), | 107 static_cast<unsigned long long>(p.command_buffer_id()), |
94 static_cast<unsigned long long>(p.release_count())); | 108 static_cast<unsigned long long>(p.release_count())); |
95 } | 109 } |
96 | 110 |
(...skipping 12 matching lines...) Expand all Loading... | |
109 return true; | 123 return true; |
110 } | 124 } |
111 | 125 |
112 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) { | 126 void ParamTraits<gpu::Mailbox>::Log(const param_type& p, std::string* l) { |
113 for (size_t i = 0; i < sizeof(p.name); ++i) | 127 for (size_t i = 0; i < sizeof(p.name); ++i) |
114 *l += base::StringPrintf("%02x", p.name[i]); | 128 *l += base::StringPrintf("%02x", p.name[i]); |
115 } | 129 } |
116 | 130 |
117 void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) { | 131 void ParamTraits<gpu::MailboxHolder>::Write(Message* m, const param_type& p) { |
118 WriteParam(m, p.mailbox); | 132 WriteParam(m, p.mailbox); |
133 WriteParam(m, p.sync_token); | |
119 WriteParam(m, p.texture_target); | 134 WriteParam(m, p.texture_target); |
120 WriteParam(m, p.sync_point); | |
121 } | 135 } |
122 | 136 |
123 bool ParamTraits<gpu::MailboxHolder> ::Read(const Message* m, | 137 bool ParamTraits<gpu::MailboxHolder> ::Read(const Message* m, |
124 base::PickleIterator* iter, | 138 base::PickleIterator* iter, |
125 param_type* p) { | 139 param_type* p) { |
126 if (!ReadParam(m, iter, &p->mailbox) || | 140 if (!ReadParam(m, iter, &p->mailbox) || |
127 !ReadParam(m, iter, &p->texture_target) || | 141 !ReadParam(m, iter, &p->sync_token) || |
128 !ReadParam(m, iter, &p->sync_point)) | 142 !ReadParam(m, iter, &p->texture_target)) |
129 return false; | 143 return false; |
130 return true; | 144 return true; |
131 } | 145 } |
132 | 146 |
133 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) { | 147 void ParamTraits<gpu::MailboxHolder>::Log(const param_type& p, std::string* l) { |
134 ParamTraits<gpu::Mailbox>::Log(p.mailbox, l); | 148 ParamTraits<gpu::Mailbox>::Log(p.mailbox, l); |
135 *l += base::StringPrintf(":%04x@%d", p.texture_target, p.sync_point); | 149 ParamTraits<gpu::SyncToken>::Log(p.sync_token, l); |
dcheng
2015/11/03 07:39:29
Nit: LogParam (here and previous line) for magical
David Yen
2015/11/03 18:09:28
Done.
| |
150 *l += base::StringPrintf(":%04x@", p.texture_target); | |
136 } | 151 } |
137 | 152 |
138 void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) { | 153 void ParamTraits<gpu::ValueState>::Write(Message* m, const param_type& p) { |
139 m->WriteData(reinterpret_cast<const char*>(&p), | 154 m->WriteData(reinterpret_cast<const char*>(&p), |
140 sizeof(gpu::ValueState)); | 155 sizeof(gpu::ValueState)); |
141 } | 156 } |
142 | 157 |
143 bool ParamTraits<gpu::ValueState> ::Read(const Message* m, | 158 bool ParamTraits<gpu::ValueState> ::Read(const Message* m, |
144 base::PickleIterator* iter, | 159 base::PickleIterator* iter, |
145 param_type* p) { | 160 param_type* p) { |
(...skipping 10 matching lines...) Expand all Loading... | |
156 l->append("<ValueState ("); | 171 l->append("<ValueState ("); |
157 for (int value : p.int_value) | 172 for (int value : p.int_value) |
158 *l += base::StringPrintf("%i ", value); | 173 *l += base::StringPrintf("%i ", value); |
159 l->append(" int values "); | 174 l->append(" int values "); |
160 for (float value : p.float_value) | 175 for (float value : p.float_value) |
161 *l += base::StringPrintf("%f ", value); | 176 *l += base::StringPrintf("%f ", value); |
162 l->append(" float values)>"); | 177 l->append(" float values)>"); |
163 } | 178 } |
164 | 179 |
165 } // namespace IPC | 180 } // namespace IPC |
OLD | NEW |