| 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_GEOMETRY_GFX_PARAM_TRAITS_H_ |
| 6 #define UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 6 #define UI_GFX_IPC_GEOMETRY_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/ipc/geometry/gfx_ipc_geometry_export.h" |
| 13 #include "ui/gfx/ipc/gfx_ipc_export.h" | |
| 14 #include "ui/gfx/ipc/gfx_param_traits_macros.h" | |
| 15 | |
| 16 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 17 #include "ui/gfx/mac/io_surface.h" | |
| 18 #endif | |
| 19 | 13 |
| 20 namespace gfx { | 14 namespace gfx { |
| 21 class Point; | 15 class Point; |
| 22 class PointF; | 16 class PointF; |
| 23 class Point3F; | 17 class Point3F; |
| 24 class Range; | |
| 25 class Rect; | 18 class Rect; |
| 26 class RectF; | 19 class RectF; |
| 27 class ScrollOffset; | 20 class ScrollOffset; |
| 28 class Size; | 21 class Size; |
| 29 class SizeF; | 22 class SizeF; |
| 30 class Vector2d; | 23 class Vector2d; |
| 31 class Vector2dF; | 24 class Vector2dF; |
| 32 } // namespace gfx | 25 } // namespace gfx |
| 33 | 26 |
| 34 namespace IPC { | 27 namespace IPC { |
| 35 | 28 |
| 36 template <> | 29 template <> |
| 37 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { | 30 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Point> { |
| 38 typedef gfx::Point param_type; | 31 typedef gfx::Point param_type; |
| 39 static void Write(base::Pickle* m, const param_type& p); | 32 static void Write(base::Pickle* m, const param_type& p); |
| 40 static bool Read(const base::Pickle* m, | 33 static bool Read(const base::Pickle* m, |
| 41 base::PickleIterator* iter, | 34 base::PickleIterator* iter, |
| 42 param_type* r); | 35 param_type* r); |
| 43 static void Log(const param_type& p, std::string* l); | 36 static void Log(const param_type& p, std::string* l); |
| 44 }; | 37 }; |
| 45 | 38 |
| 46 template <> | 39 template <> |
| 47 struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { | 40 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::PointF> { |
| 48 typedef gfx::PointF param_type; | 41 typedef gfx::PointF param_type; |
| 49 static void GetSize(base::PickleSizer* s, const param_type& p); | 42 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 50 static void Write(base::Pickle* m, const param_type& p); | 43 static void Write(base::Pickle* m, const param_type& p); |
| 51 static bool Read(const base::Pickle* m, | 44 static bool Read(const base::Pickle* m, |
| 52 base::PickleIterator* iter, | 45 base::PickleIterator* iter, |
| 53 param_type* r); | 46 param_type* r); |
| 54 static void Log(const param_type& p, std::string* l); | 47 static void Log(const param_type& p, std::string* l); |
| 55 }; | 48 }; |
| 56 | 49 |
| 57 template <> | 50 template <> |
| 58 struct GFX_IPC_EXPORT ParamTraits<gfx::Point3F> { | 51 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Point3F> { |
| 59 typedef gfx::Point3F param_type; | 52 typedef gfx::Point3F param_type; |
| 60 static void Write(base::Pickle* m, const param_type& p); | 53 static void Write(base::Pickle* m, const param_type& p); |
| 61 static bool Read(const base::Pickle* m, | 54 static bool Read(const base::Pickle* m, |
| 62 base::PickleIterator* iter, | 55 base::PickleIterator* iter, |
| 63 param_type* r); | 56 param_type* r); |
| 64 static void Log(const param_type& p, std::string* l); | 57 static void Log(const param_type& p, std::string* l); |
| 65 }; | 58 }; |
| 66 | 59 |
| 67 template <> | 60 template <> |
| 68 struct GFX_IPC_EXPORT ParamTraits<gfx::Size> { | 61 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Size> { |
| 69 typedef gfx::Size param_type; | 62 typedef gfx::Size param_type; |
| 70 static void Write(base::Pickle* m, const param_type& p); | 63 static void Write(base::Pickle* m, const param_type& p); |
| 71 static bool Read(const base::Pickle* m, | 64 static bool Read(const base::Pickle* m, |
| 72 base::PickleIterator* iter, | 65 base::PickleIterator* iter, |
| 73 param_type* r); | 66 param_type* r); |
| 74 static void Log(const param_type& p, std::string* l); | 67 static void Log(const param_type& p, std::string* l); |
| 75 }; | 68 }; |
| 76 | 69 |
| 77 template <> | 70 template <> |
| 78 struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { | 71 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::SizeF> { |
| 79 typedef gfx::SizeF param_type; | 72 typedef gfx::SizeF param_type; |
| 80 static void Write(base::Pickle* m, const param_type& p); | 73 static void Write(base::Pickle* m, const param_type& p); |
| 81 static bool Read(const base::Pickle* m, | 74 static bool Read(const base::Pickle* m, |
| 82 base::PickleIterator* iter, | 75 base::PickleIterator* iter, |
| 83 param_type* r); | 76 param_type* r); |
| 84 static void Log(const param_type& p, std::string* l); | 77 static void Log(const param_type& p, std::string* l); |
| 85 }; | 78 }; |
| 86 | 79 |
| 87 template <> | 80 template <> |
| 88 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { | 81 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Vector2d> { |
| 89 typedef gfx::Vector2d param_type; | 82 typedef gfx::Vector2d param_type; |
| 90 static void GetSize(base::PickleSizer* s, const param_type& p); | 83 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 91 static void Write(base::Pickle* m, const param_type& p); | 84 static void Write(base::Pickle* m, const param_type& p); |
| 92 static bool Read(const base::Pickle* m, | 85 static bool Read(const base::Pickle* m, |
| 93 base::PickleIterator* iter, | 86 base::PickleIterator* iter, |
| 94 param_type* r); | 87 param_type* r); |
| 95 static void Log(const param_type& p, std::string* l); | 88 static void Log(const param_type& p, std::string* l); |
| 96 }; | 89 }; |
| 97 | 90 |
| 98 template <> | 91 template <> |
| 99 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> { | 92 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Vector2dF> { |
| 100 typedef gfx::Vector2dF param_type; | 93 typedef gfx::Vector2dF param_type; |
| 101 static void Write(base::Pickle* m, const param_type& p); | 94 static void Write(base::Pickle* m, const param_type& p); |
| 102 static bool Read(const base::Pickle* m, | 95 static bool Read(const base::Pickle* m, |
| 103 base::PickleIterator* iter, | 96 base::PickleIterator* iter, |
| 104 param_type* r); | 97 param_type* r); |
| 105 static void Log(const param_type& p, std::string* l); | 98 static void Log(const param_type& p, std::string* l); |
| 106 }; | 99 }; |
| 107 | 100 |
| 108 template <> | 101 template <> |
| 109 struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { | 102 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Rect> { |
| 110 typedef gfx::Rect param_type; | 103 typedef gfx::Rect param_type; |
| 111 static void Write(base::Pickle* m, const param_type& p); | 104 static void Write(base::Pickle* m, const param_type& p); |
| 112 static bool Read(const base::Pickle* m, | 105 static bool Read(const base::Pickle* m, |
| 113 base::PickleIterator* iter, | 106 base::PickleIterator* iter, |
| 114 param_type* r); | 107 param_type* r); |
| 115 static void Log(const param_type& p, std::string* l); | 108 static void Log(const param_type& p, std::string* l); |
| 116 }; | 109 }; |
| 117 | 110 |
| 118 template <> | 111 template <> |
| 119 struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { | 112 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::RectF> { |
| 120 typedef gfx::RectF param_type; | 113 typedef gfx::RectF param_type; |
| 121 static void GetSize(base::PickleSizer* s, const param_type& p); | 114 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 122 static void Write(base::Pickle* m, const param_type& p); | 115 static void Write(base::Pickle* m, const param_type& p); |
| 123 static bool Read(const base::Pickle* m, | 116 static bool Read(const base::Pickle* m, |
| 124 base::PickleIterator* iter, | 117 base::PickleIterator* iter, |
| 125 param_type* r); | 118 param_type* r); |
| 126 static void Log(const param_type& p, std::string* l); | 119 static void Log(const param_type& p, std::string* l); |
| 127 }; | 120 }; |
| 128 | 121 |
| 129 template <> | 122 template <> |
| 130 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { | 123 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::ScrollOffset> { |
| 131 typedef gfx::Range param_type; | |
| 132 static void Write(base::Pickle* m, const param_type& p); | |
| 133 static bool Read(const base::Pickle* m, | |
| 134 base::PickleIterator* iter, | |
| 135 param_type* r); | |
| 136 static void Log(const param_type& p, std::string* l); | |
| 137 }; | |
| 138 | |
| 139 template <> | |
| 140 struct GFX_IPC_EXPORT ParamTraits<gfx::ScrollOffset> { | |
| 141 typedef gfx::ScrollOffset param_type; | 124 typedef gfx::ScrollOffset param_type; |
| 142 static void Write(base::Pickle* m, const param_type& p); | 125 static void Write(base::Pickle* m, const param_type& p); |
| 143 static bool Read(const base::Pickle* m, | 126 static bool Read(const base::Pickle* m, |
| 144 base::PickleIterator* iter, | 127 base::PickleIterator* iter, |
| 145 param_type* r); | 128 param_type* r); |
| 146 static void Log(const param_type& p, std::string* l); | 129 static void Log(const param_type& p, std::string* l); |
| 147 }; | 130 }; |
| 148 | 131 |
| 149 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 150 template <> | |
| 151 struct GFX_IPC_EXPORT ParamTraits<gfx::ScopedRefCountedIOSurfaceMachPort> { | |
| 152 typedef gfx::ScopedRefCountedIOSurfaceMachPort param_type; | |
| 153 static void Write(base::Pickle* m, const param_type p); | |
| 154 // Note: Read() passes ownership of the Mach send right from the IPC message | |
| 155 // to the ScopedRefCountedIOSurfaceMachPort. Therefore, Read() may only be | |
| 156 // called once for a given message, otherwise the singular right will be | |
| 157 // managed and released by two objects. | |
| 158 static bool Read(const base::Pickle* m, | |
| 159 base::PickleIterator* iter, | |
| 160 param_type* r); | |
| 161 static void Log(const param_type& p, std::string* l); | |
| 162 }; | |
| 163 #endif // defined(OS_MACOSX) && !defined(OS_IOS) | |
| 164 | |
| 165 } // namespace IPC | 132 } // namespace IPC |
| 166 | 133 |
| 167 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 134 #endif // UI_GFX_IPC_GEOMETRY_GFX_PARAM_TRAITS_H_ |
| OLD | NEW |