| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "ui/gfx/geometry/point3_f.h" |
| 10 #include "ui/gfx/geometry/rect.h" | 11 #include "ui/gfx/geometry/rect.h" |
| 11 #include "ui/gfx/geometry/rect_f.h" | 12 #include "ui/gfx/geometry/rect_f.h" |
| 12 #include "ui/gfx/range/range.h" | 13 #include "ui/gfx/range/range.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 struct SkBitmap_Data { | 17 struct SkBitmap_Data { |
| 17 // The color type for the bitmap (bits per pixel, etc). | 18 // The color type for the bitmap (bits per pixel, etc). |
| 18 SkColorType fColorType; | 19 SkColorType fColorType; |
| 19 | 20 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 46 memcpy(bitmap->getPixels(), pixels, pixels_size); | 47 memcpy(bitmap->getPixels(), pixels, pixels_size); |
| 47 return true; | 48 return true; |
| 48 } | 49 } |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 } // namespace | 52 } // namespace |
| 52 | 53 |
| 53 namespace IPC { | 54 namespace IPC { |
| 54 | 55 |
| 55 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { | 56 void ParamTraits<gfx::Point>::Write(Message* m, const gfx::Point& p) { |
| 56 m->WriteInt(p.x()); | 57 WriteParam(m, p.x()); |
| 57 m->WriteInt(p.y()); | 58 WriteParam(m, p.y()); |
| 58 } | 59 } |
| 59 | 60 |
| 60 bool ParamTraits<gfx::Point>::Read(const Message* m, | 61 bool ParamTraits<gfx::Point>::Read(const Message* m, |
| 61 base::PickleIterator* iter, | 62 base::PickleIterator* iter, |
| 62 gfx::Point* r) { | 63 gfx::Point* r) { |
| 63 int x, y; | 64 int x, y; |
| 64 if (!iter->ReadInt(&x) || | 65 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y)) |
| 65 !iter->ReadInt(&y)) | |
| 66 return false; | 66 return false; |
| 67 r->set_x(x); | 67 r->set_x(x); |
| 68 r->set_y(y); | 68 r->set_y(y); |
| 69 return true; | 69 return true; |
| 70 } | 70 } |
| 71 | 71 |
| 72 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { | 72 void ParamTraits<gfx::Point>::Log(const gfx::Point& p, std::string* l) { |
| 73 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); | 73 l->append(base::StringPrintf("(%d, %d)", p.x(), p.y())); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void ParamTraits<gfx::PointF>::Write(Message* m, const gfx::PointF& v) { | 76 void ParamTraits<gfx::PointF>::Write(Message* m, const gfx::PointF& p) { |
| 77 ParamTraits<float>::Write(m, v.x()); | 77 WriteParam(m, p.x()); |
| 78 ParamTraits<float>::Write(m, v.y()); | 78 WriteParam(m, p.y()); |
| 79 } | 79 } |
| 80 | 80 |
| 81 bool ParamTraits<gfx::PointF>::Read(const Message* m, | 81 bool ParamTraits<gfx::PointF>::Read(const Message* m, |
| 82 base::PickleIterator* iter, | 82 base::PickleIterator* iter, |
| 83 gfx::PointF* r) { | 83 gfx::PointF* r) { |
| 84 float x, y; | 84 float x, y; |
| 85 if (!ParamTraits<float>::Read(m, iter, &x) || | 85 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y)) |
| 86 !ParamTraits<float>::Read(m, iter, &y)) | |
| 87 return false; | 86 return false; |
| 88 r->set_x(x); | 87 r->set_x(x); |
| 89 r->set_y(y); | 88 r->set_y(y); |
| 90 return true; | 89 return true; |
| 91 } | 90 } |
| 92 | 91 |
| 93 void ParamTraits<gfx::PointF>::Log(const gfx::PointF& v, std::string* l) { | 92 void ParamTraits<gfx::PointF>::Log(const gfx::PointF& p, std::string* l) { |
| 94 l->append(base::StringPrintf("(%f, %f)", v.x(), v.y())); | 93 l->append(base::StringPrintf("(%f, %f)", p.x(), p.y())); |
| 94 } |
| 95 |
| 96 void ParamTraits<gfx::Point3F>::Write(Message* m, const gfx::Point3F& p) { |
| 97 WriteParam(m, p.x()); |
| 98 WriteParam(m, p.y()); |
| 99 WriteParam(m, p.z()); |
| 100 } |
| 101 |
| 102 bool ParamTraits<gfx::Point3F>::Read(const Message* m, |
| 103 base::PickleIterator* iter, |
| 104 gfx::Point3F* r) { |
| 105 float x, y, z; |
| 106 if (!ReadParam(m, iter, &x) || !ReadParam(m, iter, &y) || |
| 107 !ReadParam(m, iter, &z)) |
| 108 return false; |
| 109 r->set_x(x); |
| 110 r->set_y(y); |
| 111 r->set_z(z); |
| 112 return true; |
| 113 } |
| 114 |
| 115 void ParamTraits<gfx::Point3F>::Log(const gfx::Point3F& p, std::string* l) { |
| 116 l->append(base::StringPrintf("(%f, %f, %f)", p.x(), p.y(), p.z())); |
| 95 } | 117 } |
| 96 | 118 |
| 97 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { | 119 void ParamTraits<gfx::Size>::Write(Message* m, const gfx::Size& p) { |
| 98 DCHECK_GE(p.width(), 0); | 120 DCHECK_GE(p.width(), 0); |
| 99 DCHECK_GE(p.height(), 0); | 121 DCHECK_GE(p.height(), 0); |
| 100 int values[2] = { p.width(), p.height() }; | 122 int values[2] = { p.width(), p.height() }; |
| 101 m->WriteBytes(&values, sizeof(int) * 2); | 123 m->WriteBytes(&values, sizeof(int) * 2); |
| 102 } | 124 } |
| 103 | 125 |
| 104 bool ParamTraits<gfx::Size>::Read(const Message* m, | 126 bool ParamTraits<gfx::Size>::Read(const Message* m, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 324 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
| 303 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 325 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
| 304 } // namespace IPC | 326 } // namespace IPC |
| 305 | 327 |
| 306 // Generate param traits log methods. | 328 // Generate param traits log methods. |
| 307 #include "ipc/param_traits_log_macros.h" | 329 #include "ipc/param_traits_log_macros.h" |
| 308 namespace IPC { | 330 namespace IPC { |
| 309 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ | 331 #undef UI_GFX_IPC_GFX_PARAM_TRAITS_MACROS_H_ |
| 310 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 332 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
| 311 } // namespace IPC | 333 } // namespace IPC |
| OLD | NEW |