| OLD | NEW |
| 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 Loading... |
| 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 | |
| 90 void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) { | 84 void ParamTraits<gfx::PointF>::Write(base::Pickle* m, const gfx::PointF& p) { |
| 91 WriteParam(m, p.x()); | 85 WriteParam(m, p.x()); |
| 92 WriteParam(m, p.y()); | 86 WriteParam(m, p.y()); |
| 93 } | 87 } |
| 94 | 88 |
| 95 bool ParamTraits<gfx::PointF>::Read(const base::Pickle* m, | 89 bool ParamTraits<gfx::PointF>::Read(const base::Pickle* m, |
| 96 base::PickleIterator* iter, | 90 base::PickleIterator* iter, |
| 97 gfx::PointF* r) { | 91 gfx::PointF* r) { |
| 98 float x, y; | 92 float x, y; |
| 99 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y)) | 93 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y)) |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const float* values = reinterpret_cast<const float*>(char_values); | 163 const float* values = reinterpret_cast<const float*>(char_values); |
| 170 r->set_width(values[0]); | 164 r->set_width(values[0]); |
| 171 r->set_height(values[1]); | 165 r->set_height(values[1]); |
| 172 return true; | 166 return true; |
| 173 } | 167 } |
| 174 | 168 |
| 175 void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { | 169 void ParamTraits<gfx::SizeF>::Log(const gfx::SizeF& p, std::string* l) { |
| 176 l->append(base::StringPrintf("(%f, %f)", p.width(), p.height())); | 170 l->append(base::StringPrintf("(%f, %f)", p.width(), p.height())); |
| 177 } | 171 } |
| 178 | 172 |
| 179 void ParamTraits<gfx::Vector2d>::GetSize(base::PickleSizer* s, | |
| 180 const gfx::Vector2d& p) { | |
| 181 s->AddBytes(sizeof(int) * 2); | |
| 182 } | |
| 183 | |
| 184 void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m, | 173 void ParamTraits<gfx::Vector2d>::Write(base::Pickle* m, |
| 185 const gfx::Vector2d& p) { | 174 const gfx::Vector2d& p) { |
| 186 int values[2] = { p.x(), p.y() }; | 175 int values[2] = { p.x(), p.y() }; |
| 187 m->WriteBytes(&values, sizeof(int) * 2); | 176 m->WriteBytes(&values, sizeof(int) * 2); |
| 188 } | 177 } |
| 189 | 178 |
| 190 bool ParamTraits<gfx::Vector2d>::Read(const base::Pickle* m, | 179 bool ParamTraits<gfx::Vector2d>::Read(const base::Pickle* m, |
| 191 base::PickleIterator* iter, | 180 base::PickleIterator* iter, |
| 192 gfx::Vector2d* r) { | 181 gfx::Vector2d* r) { |
| 193 const char* char_values; | 182 const char* char_values; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 return false; | 230 return false; |
| 242 r->SetRect(values[0], values[1], values[2], values[3]); | 231 r->SetRect(values[0], values[1], values[2], values[3]); |
| 243 return true; | 232 return true; |
| 244 } | 233 } |
| 245 | 234 |
| 246 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { | 235 void ParamTraits<gfx::Rect>::Log(const gfx::Rect& p, std::string* l) { |
| 247 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), | 236 l->append(base::StringPrintf("(%d, %d, %d, %d)", p.x(), p.y(), |
| 248 p.width(), p.height())); | 237 p.width(), p.height())); |
| 249 } | 238 } |
| 250 | 239 |
| 251 void ParamTraits<gfx::RectF>::GetSize(base::PickleSizer* s, | |
| 252 const gfx::RectF& p) { | |
| 253 s->AddBytes(sizeof(float) * 4); | |
| 254 } | |
| 255 | |
| 256 void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) { | 240 void ParamTraits<gfx::RectF>::Write(base::Pickle* m, const gfx::RectF& p) { |
| 257 float values[4] = { p.x(), p.y(), p.width(), p.height() }; | 241 float values[4] = { p.x(), p.y(), p.width(), p.height() }; |
| 258 m->WriteBytes(&values, sizeof(float) * 4); | 242 m->WriteBytes(&values, sizeof(float) * 4); |
| 259 } | 243 } |
| 260 | 244 |
| 261 bool ParamTraits<gfx::RectF>::Read(const base::Pickle* m, | 245 bool ParamTraits<gfx::RectF>::Read(const base::Pickle* m, |
| 262 base::PickleIterator* iter, | 246 base::PickleIterator* iter, |
| 263 gfx::RectF* r) { | 247 gfx::RectF* r) { |
| 264 const char* char_values; | 248 const char* char_values; |
| 265 if (!iter->ReadBytes(&char_values, sizeof(float) * 4)) | 249 if (!iter->ReadBytes(&char_values, sizeof(float) * 4)) |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 389 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
| 406 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 390 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
| 407 } // namespace IPC | 391 } // namespace IPC |
| 408 | 392 |
| 409 // Generate param traits log methods. | 393 // Generate param traits log methods. |
| 410 #include "ipc/param_traits_log_macros.h" | 394 #include "ipc/param_traits_log_macros.h" |
| 411 namespace IPC { | 395 namespace IPC { |
| 412 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 396 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
| 413 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 397 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
| 414 } // namespace IPC | 398 } // namespace IPC |
| OLD | NEW |