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

Side by Side Diff: ui/gfx/ipc/gfx_param_traits.cc

Issue 1695783002: IPC::ParamTraits for ui::Event (towards ui::Events over mojo IPC) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/gfx/ipc/gfx_param_traits.h" 5 #include "ui/gfx/ipc/gfx_param_traits.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return false; 74 return false;
75 r->set_x(x); 75 r->set_x(x);
76 r->set_y(y); 76 r->set_y(y);
77 return true; 77 return true;
78 } 78 }
79 79
80 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { 80 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) {
81 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); 81 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y()));
82 } 82 }
83 83
84 void ParamTraits<gfx::PointF>::GetSize(base::PickleSizer* s,
85 const gfx::PointF& p) {
86 GetParamSize(s, p.x());
87 GetParamSize(s, p.y());
88 }
89
84 void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) { 90 void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) {
85 WriteParam(m, p.x()); 91 WriteParam(m, p.x());
86 WriteParam(m, p.y()); 92 WriteParam(m, p.y());
87 } 93 }
88 94
89 bool ParamTraits<gfx::PointF>::Read(const base::Pickle* m, 95 bool ParamTraits<gfx::PointF>::Read(const base::Pickle* m,
90 base::PickleIterator* iter, 96 base::PickleIterator* iter,
91 gfx::PointF* r) { 97 gfx::PointF* r) {
92 float x, y; 98 float x, y;
93 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y)) 99 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y))
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 const float* values = reinterpret_cast<const float*>(char_values); 169 const float* values = reinterpret_cast<const float*>(char_values);
164 r->set_width(values[0]); 170 r->set_width(values[0]);
165 r->set_height(values[1]); 171 r->set_height(values[1]);
166 return true; 172 return true;
167 } 173 }
168 174
169 void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { 175 void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) {
170 l->append(base::StringPrintf("(%f, %f)", p.width(), p.height())); 176 l->append(base::StringPrintf("(%f, %f)", p.width(), p.height()));
171 } 177 }
172 178
179 void ParamTraits<gfx::Vector2d>::GetSize(base::PickleSizer* s,
180 const gfx::Vector2d& p) {
181 s->AddBytes(sizeof(int) * 2);
182 }
183
173 void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m, 184 void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m,
174 const gfx::Vector2d& p) { 185 const gfx::Vector2d& p) {
175 int values[2] = { p.x(), p.y() }; 186 int values[2] = { p.x(), p.y() };
176 m->WriteBytes(&values, sizeof(int) * 2); 187 m->WriteBytes(&values, sizeof(int) * 2);
177 } 188 }
178 189
179 bool ParamTraits<gfx::Vector2d>::Read(const base::Pickle* m, 190 bool ParamTraits<gfx::Vector2d>::Read(const base::Pickle* m,
180 base::PickleIterator* iter, 191 base::PickleIterator* iter,
181 gfx::Vector2d* r) { 192 gfx::Vector2d* r) {
182 const char* char_values; 193 const char* char_values;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 return false; 241 return false;
231 r->SetRect(values[0], values[1], values[2], values[3]); 242 r->SetRect(values[0], values[1], values[2], values[3]);
232 return true; 243 return true;
233 } 244 }
234 245
235 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { 246 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) {
236 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), 247 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(),
237 p.width(), p.height())); 248 p.width(), p.height()));
238 } 249 }
239 250
251 void ParamTraits<gfx::RectF>::GetSize(base::PickleSizer* s,
252 const gfx::RectF& p) {
253 s->AddBytes(sizeof(float) * 4);
254 }
255
240 void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) { 256 void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) {
241 float values[4] = { p.x(), p.y(), p.width(), p.height() }; 257 float values[4] = { p.x(), p.y(), p.width(), p.height() };
242 m->WriteBytes(&values, sizeof(float) * 4); 258 m->WriteBytes(&values, sizeof(float) * 4);
243 } 259 }
244 260
245 bool ParamTraits<gfx::RectF>::Read(const base::Pickle* m, 261 bool ParamTraits<gfx::RectF>::Read(const base::Pickle* m,
246 base::PickleIterator* iter, 262 base::PickleIterator* iter,
247 gfx::RectF* r) { 263 gfx::RectF* r) {
248 const char* char_values; 264 const char* char_values;
249 if (!iter->ReadBytes(&char_values, sizeof(float) * 4)) 265 if (!iter->ReadBytes(&char_values, sizeof(float) * 4))
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 405 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
390 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 406 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
391 } // namespace IPC 407 } // namespace IPC
392 408
393 // Generate param traits log methods. 409 // Generate param traits log methods.
394 #include "ipc/param_traits_log_macros.h" 410 #include "ipc/param_traits_log_macros.h"
395 namespace IPC { 411 namespace IPC {
396 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ 412 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_
397 #include "ui/gfx/ipc/gfx_param_traits_macros.h" 413 #include "ui/gfx/ipc/gfx_param_traits_macros.h"
398 } // namespace IPC 414 } // namespace IPC
OLDNEW
« ui/events/ipc/event_param_traits_unittest.cc ('K') | « ui/gfx/ipc/gfx_param_traits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698