| 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 #ifndef UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 5 #ifndef UI_GFX_IPC_GFX_PARAM_TRAITS_H_ |
| 6 #define UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 6 #define UI_GFX_IPC_GFX_PARAM_TRAITS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "ipc/ipc_message_utils.h" | 10 #include "ipc/ipc_message_utils.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 class SizeF; | 31 class SizeF; |
| 32 class Vector2d; | 32 class Vector2d; |
| 33 class Vector2dF; | 33 class Vector2dF; |
| 34 } // namespace gfx | 34 } // namespace gfx |
| 35 | 35 |
| 36 namespace IPC { | 36 namespace IPC { |
| 37 | 37 |
| 38 template <> | 38 template <> |
| 39 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { | 39 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { |
| 40 typedef gfx::Point param_type; | 40 typedef gfx::Point param_type; |
| 41 static void Write(Message* m, const param_type& p); | 41 static void Write(base::Pickle* m, const param_type& p); |
| 42 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 42 static bool Read(const base::Pickle* m, |
| 43 base::PickleIterator* iter, |
| 44 param_type* r); |
| 43 static void Log(const param_type& p, std::string* l); | 45 static void Log(const param_type& p, std::string* l); |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 template <> | 48 template <> |
| 47 struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { | 49 struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { |
| 48 typedef gfx::PointF param_type; | 50 typedef gfx::PointF param_type; |
| 49 static void Write(Message* m, const param_type& p); | 51 static void Write(base::Pickle* m, const param_type& p); |
| 50 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 52 static bool Read(const base::Pickle* m, |
| 53 base::PickleIterator* iter, |
| 54 param_type* r); |
| 51 static void Log(const param_type& p, std::string* l); | 55 static void Log(const param_type& p, std::string* l); |
| 52 }; | 56 }; |
| 53 | 57 |
| 54 template <> | 58 template <> |
| 55 struct GFX_IPC_EXPORT ParamTraits<gfx::Point3F> { | 59 struct GFX_IPC_EXPORT ParamTraits<gfx::Point3F> { |
| 56 typedef gfx::Point3F param_type; | 60 typedef gfx::Point3F param_type; |
| 57 static void Write(Message* m, const param_type& p); | 61 static void Write(base::Pickle* m, const param_type& p); |
| 58 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 62 static bool Read(const base::Pickle* m, |
| 63 base::PickleIterator* iter, |
| 64 param_type* r); |
| 59 static void Log(const param_type& p, std::string* l); | 65 static void Log(const param_type& p, std::string* l); |
| 60 }; | 66 }; |
| 61 | 67 |
| 62 template <> | 68 template <> |
| 63 struct GFX_IPC_EXPORT ParamTraits<gfx::Size> { | 69 struct GFX_IPC_EXPORT ParamTraits<gfx::Size> { |
| 64 typedef gfx::Size param_type; | 70 typedef gfx::Size param_type; |
| 65 static void Write(Message* m, const param_type& p); | 71 static void Write(base::Pickle* m, const param_type& p); |
| 66 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 72 static bool Read(const base::Pickle* m, |
| 73 base::PickleIterator* iter, |
| 74 param_type* r); |
| 67 static void Log(const param_type& p, std::string* l); | 75 static void Log(const param_type& p, std::string* l); |
| 68 }; | 76 }; |
| 69 | 77 |
| 70 template <> | 78 template <> |
| 71 struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { | 79 struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { |
| 72 typedef gfx::SizeF param_type; | 80 typedef gfx::SizeF param_type; |
| 73 static void Write(Message* m, const param_type& p); | 81 static void Write(base::Pickle* m, const param_type& p); |
| 74 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 82 static bool Read(const base::Pickle* m, |
| 83 base::PickleIterator* iter, |
| 84 param_type* r); |
| 75 static void Log(const param_type& p, std::string* l); | 85 static void Log(const param_type& p, std::string* l); |
| 76 }; | 86 }; |
| 77 | 87 |
| 78 template <> | 88 template <> |
| 79 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { | 89 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { |
| 80 typedef gfx::Vector2d param_type; | 90 typedef gfx::Vector2d param_type; |
| 81 static void Write(Message* m, const param_type& p); | 91 static void Write(base::Pickle* m, const param_type& p); |
| 82 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 92 static bool Read(const base::Pickle* m, |
| 93 base::PickleIterator* iter, |
| 94 param_type* r); |
| 83 static void Log(const param_type& p, std::string* l); | 95 static void Log(const param_type& p, std::string* l); |
| 84 }; | 96 }; |
| 85 | 97 |
| 86 template <> | 98 template <> |
| 87 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> { | 99 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> { |
| 88 typedef gfx::Vector2dF param_type; | 100 typedef gfx::Vector2dF param_type; |
| 89 static void Write(Message* m, const param_type& p); | 101 static void Write(base::Pickle* m, const param_type& p); |
| 90 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 102 static bool Read(const base::Pickle* m, |
| 103 base::PickleIterator* iter, |
| 104 param_type* r); |
| 91 static void Log(const param_type& p, std::string* l); | 105 static void Log(const param_type& p, std::string* l); |
| 92 }; | 106 }; |
| 93 | 107 |
| 94 template <> | 108 template <> |
| 95 struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { | 109 struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { |
| 96 typedef gfx::Rect param_type; | 110 typedef gfx::Rect param_type; |
| 97 static void Write(Message* m, const param_type& p); | 111 static void Write(base::Pickle* m, const param_type& p); |
| 98 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 112 static bool Read(const base::Pickle* m, |
| 113 base::PickleIterator* iter, |
| 114 param_type* r); |
| 99 static void Log(const param_type& p, std::string* l); | 115 static void Log(const param_type& p, std::string* l); |
| 100 }; | 116 }; |
| 101 | 117 |
| 102 template <> | 118 template <> |
| 103 struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { | 119 struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { |
| 104 typedef gfx::RectF param_type; | 120 typedef gfx::RectF param_type; |
| 105 static void Write(Message* m, const param_type& p); | 121 static void Write(base::Pickle* m, const param_type& p); |
| 106 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 122 static bool Read(const base::Pickle* m, |
| 123 base::PickleIterator* iter, |
| 124 param_type* r); |
| 107 static void Log(const param_type& p, std::string* l); | 125 static void Log(const param_type& p, std::string* l); |
| 108 }; | 126 }; |
| 109 | 127 |
| 110 template <> | 128 template <> |
| 111 struct GFX_IPC_EXPORT ParamTraits<SkBitmap> { | 129 struct GFX_IPC_EXPORT ParamTraits<SkBitmap> { |
| 112 typedef SkBitmap param_type; | 130 typedef SkBitmap param_type; |
| 113 static void Write(Message* m, const param_type& p); | 131 static void Write(base::Pickle* m, const param_type& p); |
| 114 | 132 |
| 115 // Note: This function expects parameter |r| to be of type &SkBitmap since | 133 // Note: This function expects parameter |r| to be of type &SkBitmap since |
| 116 // r->SetConfig() and r->SetPixels() are called. | 134 // r->SetConfig() and r->SetPixels() are called. |
| 117 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 135 static bool Read(const base::Pickle* m, |
| 136 base::PickleIterator* iter, |
| 137 param_type* r); |
| 118 | 138 |
| 119 static void Log(const param_type& p, std::string* l); | 139 static void Log(const param_type& p, std::string* l); |
| 120 }; | 140 }; |
| 121 | 141 |
| 122 template <> | 142 template <> |
| 123 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { | 143 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { |
| 124 typedef gfx::Range param_type; | 144 typedef gfx::Range param_type; |
| 125 static void Write(Message* m, const param_type& p); | 145 static void Write(base::Pickle* m, const param_type& p); |
| 126 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 146 static bool Read(const base::Pickle* m, |
| 147 base::PickleIterator* iter, |
| 148 param_type* r); |
| 127 static void Log(const param_type& p, std::string* l); | 149 static void Log(const param_type& p, std::string* l); |
| 128 }; | 150 }; |
| 129 | 151 |
| 130 template <> | 152 template <> |
| 131 struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { | 153 struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { |
| 132 typedef gfx::ScrollOffset param_type; | 154 typedef gfx::ScrollOffset param_type; |
| 133 static void Write(Message* m, const param_type& p); | 155 static void Write(base::Pickle* m, const param_type& p); |
| 134 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 156 static bool Read(const base::Pickle* m, |
| 157 base::PickleIterator* iter, |
| 158 param_type* r); |
| 135 static void Log(const param_type& p, std::string* l); | 159 static void Log(const param_type& p, std::string* l); |
| 136 }; | 160 }; |
| 137 | 161 |
| 138 #if defined(OS_MACOSX) && !defined(OS_IOS) | 162 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 139 template <> | 163 template <> |
| 140 struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { | 164 struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { |
| 141 typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; | 165 typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; |
| 142 static void Write(Message* m, const param_type p); | 166 static void Write(base::Pickle* m, const param_type p); |
| 143 // Note: Read() passes ownership of the Mach send right from the IPC message | 167 // Note: Read() passes ownership of the Mach send right from the IPC message |
| 144 // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be | 168 // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be |
| 145 // called once for a given message, otherwise the singular right will be | 169 // called once for a given message, otherwise the singular right will be |
| 146 // managed and released by two objects. | 170 // managed and released by two objects. |
| 147 static bool Read(const Message* m, base::PickleIterator* iter, param_type* r); | 171 static bool Read(const base::Pickle* m, |
| 172 base::PickleIterator* iter, |
| 173 param_type* r); |
| 148 static void Log(const param_type& p, std::string* l); | 174 static void Log(const param_type& p, std::string* l); |
| 149 }; | 175 }; |
| 150 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 176 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 151 | 177 |
| 152 } // namespace IPC | 178 } // namespace IPC |
| 153 | 179 |
| 154 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 180 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ |
| OLD | NEW |