| 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" |
| 11 #include "ipc/param_traits_macros.h" | 11 #include "ipc/param_traits_macros.h" |
| 12 #include "ui/gfx/buffer_types.h" | 12 #include "ui/gfx/buffer_types.h" |
| 13 #include "ui/gfx/ipc/gfx_ipc_export.h" | 13 #include "ui/gfx/ipc/gfx_ipc_export.h" |
| 14 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | 14 #include "ui/gfx/ipc/gfx_param_traits_macros.h" |
| 15 | 15 |
| 16 #if defined(OS_MACOSX) && !defined(OS_IOS) | 16 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 17 #include "ui/gfx/mac/io_surface.h" | 17 #include "ui/gfx/mac/io_surface.h" |
| 18 #endif | 18 #endif |
| 19 | 19 |
| 20 class SkBitmap; | |
| 21 | |
| 22 namespace gfx { | 20 namespace gfx { |
| 23 class Point; | 21 class Point; |
| 24 class PointF; | 22 class PointF; |
| 25 class Point3F; | 23 class Point3F; |
| 26 class Range; | 24 class Range; |
| 27 class Rect; | 25 class Rect; |
| 28 class RectF; | 26 class RectF; |
| 29 class ScrollOffset; | 27 class ScrollOffset; |
| 30 class Size; | 28 class Size; |
| 31 class SizeF; | 29 class SizeF; |
| 32 class Transform; | |
| 33 class Vector2d; | 30 class Vector2d; |
| 34 class Vector2dF; | 31 class Vector2dF; |
| 35 } // namespace gfx | 32 } // namespace gfx |
| 36 | 33 |
| 37 namespace IPC { | 34 namespace IPC { |
| 38 | 35 |
| 39 template <> | 36 template <> |
| 40 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { | 37 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { |
| 41 typedef gfx::Point param_type; | 38 typedef gfx::Point param_type; |
| 42 static void Write(base::Pickle* m, const param_type& p); | 39 static void Write(base::Pickle* m, const param_type& p); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 typedef gfx::RectF param_type; | 120 typedef gfx::RectF param_type; |
| 124 static void GetSize(base::PickleSizer* s, const param_type& p); | 121 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 125 static void Write(base::Pickle* m, const param_type& p); | 122 static void Write(base::Pickle* m, const param_type& p); |
| 126 static bool Read(const base::Pickle* m, | 123 static bool Read(const base::Pickle* m, |
| 127 base::PickleIterator* iter, | 124 base::PickleIterator* iter, |
| 128 param_type* r); | 125 param_type* r); |
| 129 static void Log(const param_type& p, std::string* l); | 126 static void Log(const param_type& p, std::string* l); |
| 130 }; | 127 }; |
| 131 | 128 |
| 132 template <> | 129 template <> |
| 133 struct GFX_IPC_EXPORT ParamTraits<SkBitmap> { | |
| 134 typedef SkBitmap param_type; | |
| 135 static void Write(base::Pickle* m, const param_type& p); | |
| 136 | |
| 137 // Note: This function expects parameter |r| to be of type &SkBitmap since | |
| 138 // r->SetConfig() and r->SetPixels() are called. | |
| 139 static bool Read(const base::Pickle* m, | |
| 140 base::PickleIterator* iter, | |
| 141 param_type* r); | |
| 142 | |
| 143 static void Log(const param_type& p, std::string* l); | |
| 144 }; | |
| 145 | |
| 146 template <> | |
| 147 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { | 130 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { |
| 148 typedef gfx::Range param_type; | 131 typedef gfx::Range param_type; |
| 149 static void Write(base::Pickle* m, const param_type& p); | 132 static void Write(base::Pickle* m, const param_type& p); |
| 150 static bool Read(const base::Pickle* m, | 133 static bool Read(const base::Pickle* m, |
| 151 base::PickleIterator* iter, | 134 base::PickleIterator* iter, |
| 152 param_type* r); | 135 param_type* r); |
| 153 static void Log(const param_type& p, std::string* l); | 136 static void Log(const param_type& p, std::string* l); |
| 154 }; | 137 }; |
| 155 | 138 |
| 156 template <> | 139 template <> |
| 157 struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { | 140 struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { |
| 158 typedef gfx::ScrollOffset param_type; | 141 typedef gfx::ScrollOffset param_type; |
| 159 static void Write(base::Pickle* m, const param_type& p); | 142 static void Write(base::Pickle* m, const param_type& p); |
| 160 static bool Read(const base::Pickle* m, | 143 static bool Read(const base::Pickle* m, |
| 161 base::PickleIterator* iter, | 144 base::PickleIterator* iter, |
| 162 param_type* r); | 145 param_type* r); |
| 163 static void Log(const param_type& p, std::string* l); | 146 static void Log(const param_type& p, std::string* l); |
| 164 }; | 147 }; |
| 165 | 148 |
| 166 template <> | |
| 167 struct GFX_IPC_EXPORT ParamTraits<gfx::Transform> { | |
| 168 typedef gfx::Transform param_type; | |
| 169 static void Write(base::Pickle* m, const param_type& p); | |
| 170 static bool Read(const base::Pickle* m, | |
| 171 base::PickleIterator* iter, | |
| 172 param_type* r); | |
| 173 static void Log(const param_type& p, std::string* l); | |
| 174 }; | |
| 175 | |
| 176 #if defined(OS_MACOSX) && !defined(OS_IOS) | 149 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 177 template <> | 150 template <> |
| 178 struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { | 151 struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { |
| 179 typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; | 152 typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; |
| 180 static void Write(base::Pickle* m, const param_type p); | 153 static void Write(base::Pickle* m, const param_type p); |
| 181 // Note: Read() passes ownership of the Mach send right from the IPC message | 154 // Note: Read() passes ownership of the Mach send right from the IPC message |
| 182 // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be | 155 // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be |
| 183 // called once for a given message, otherwise the singular right will be | 156 // called once for a given message, otherwise the singular right will be |
| 184 // managed and released by two objects. | 157 // managed and released by two objects. |
| 185 static bool Read(const base::Pickle* m, | 158 static bool Read(const base::Pickle* m, |
| 186 base::PickleIterator* iter, | 159 base::PickleIterator* iter, |
| 187 param_type* r); | 160 param_type* r); |
| 188 static void Log(const param_type& p, std::string* l); | 161 static void Log(const param_type& p, std::string* l); |
| 189 }; | 162 }; |
| 190 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | 163 #endif // defined(OS_MACOSX) && !defined(OS_IOS) |
| 191 | 164 |
| 192 } // namespace IPC | 165 } // namespace IPC |
| 193 | 166 |
| 194 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 167 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ |
| OLD | NEW |