| 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" | 13 #include "ui/gfx/ipc/geometry/gfx_param_traits_macros.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 | 14 |
| 20 namespace gfx { | 15 namespace gfx { |
| 21 class Point; | 16 class Point; |
| 22 class PointF; | 17 class PointF; |
| 23 class Point3F; | 18 class Point3F; |
| 24 class Range; | 19 class Range; |
| 25 class Rect; | 20 class Rect; |
| 26 class RectF; | 21 class RectF; |
| 27 class ScrollOffset; | 22 class ScrollOffset; |
| 28 class Size; | 23 class Size; |
| 29 class SizeF; | 24 class SizeF; |
| 30 class Vector2d; | 25 class Vector2d; |
| 31 class Vector2dF; | 26 class Vector2dF; |
| 32 } // namespace gfx | 27 } // namespace gfx |
| 33 | 28 |
| 34 namespace IPC { | 29 namespace IPC { |
| 35 | 30 |
| 36 template <> | 31 template <> |
| 37 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> { | 32 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Point> { |
| 38 typedef gfx::Point param_type; | 33 typedef gfx::Point param_type; |
| 39 static void Write(base::Pickle* m, const param_type& p); | 34 static void Write(base::Pickle* m, const param_type& p); |
| 40 static bool Read(const base::Pickle* m, | 35 static bool Read(const base::Pickle* m, |
| 41 base::PickleIterator* iter, | 36 base::PickleIterator* iter, |
| 42 param_type* r); | 37 param_type* r); |
| 43 static void Log(const param_type& p, std::string* l); | 38 static void Log(const param_type& p, std::string* l); |
| 44 }; | 39 }; |
| 45 | 40 |
| 46 template <> | 41 template <> |
| 47 struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> { | 42 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::PointF> { |
| 48 typedef gfx::PointF param_type; | 43 typedef gfx::PointF param_type; |
| 49 static void GetSize(base::PickleSizer* s, const param_type& p); | 44 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 50 static void Write(base::Pickle* m, const param_type& p); | 45 static void Write(base::Pickle* m, const param_type& p); |
| 51 static bool Read(const base::Pickle* m, | 46 static bool Read(const base::Pickle* m, |
| 52 base::PickleIterator* iter, | 47 base::PickleIterator* iter, |
| 53 param_type* r); | 48 param_type* r); |
| 54 static void Log(const param_type& p, std::string* l); | 49 static void Log(const param_type& p, std::string* l); |
| 55 }; | 50 }; |
| 56 | 51 |
| 57 template <> | 52 template <> |
| 58 struct GFX_IPC_EXPORT ParamTraits<gfx::Point3F> { | 53 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Point3F> { |
| 59 typedef gfx::Point3F param_type; | 54 typedef gfx::Point3F param_type; |
| 60 static void Write(base::Pickle* m, const param_type& p); | 55 static void Write(base::Pickle* m, const param_type& p); |
| 61 static bool Read(const base::Pickle* m, | 56 static bool Read(const base::Pickle* m, |
| 62 base::PickleIterator* iter, | 57 base::PickleIterator* iter, |
| 63 param_type* r); | 58 param_type* r); |
| 64 static void Log(const param_type& p, std::string* l); | 59 static void Log(const param_type& p, std::string* l); |
| 65 }; | 60 }; |
| 66 | 61 |
| 67 template <> | 62 template <> |
| 68 struct GFX_IPC_EXPORT ParamTraits<gfx::Size> { | 63 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Size> { |
| 69 typedef gfx::Size param_type; | 64 typedef gfx::Size param_type; |
| 70 static void Write(base::Pickle* m, const param_type& p); | 65 static void Write(base::Pickle* m, const param_type& p); |
| 71 static bool Read(const base::Pickle* m, | 66 static bool Read(const base::Pickle* m, |
| 72 base::PickleIterator* iter, | 67 base::PickleIterator* iter, |
| 73 param_type* r); | 68 param_type* r); |
| 74 static void Log(const param_type& p, std::string* l); | 69 static void Log(const param_type& p, std::string* l); |
| 75 }; | 70 }; |
| 76 | 71 |
| 77 template <> | 72 template <> |
| 78 struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> { | 73 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::SizeF> { |
| 79 typedef gfx::SizeF param_type; | 74 typedef gfx::SizeF param_type; |
| 80 static void Write(base::Pickle* m, const param_type& p); | 75 static void Write(base::Pickle* m, const param_type& p); |
| 81 static bool Read(const base::Pickle* m, | 76 static bool Read(const base::Pickle* m, |
| 82 base::PickleIterator* iter, | 77 base::PickleIterator* iter, |
| 83 param_type* r); | 78 param_type* r); |
| 84 static void Log(const param_type& p, std::string* l); | 79 static void Log(const param_type& p, std::string* l); |
| 85 }; | 80 }; |
| 86 | 81 |
| 87 template <> | 82 template <> |
| 88 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> { | 83 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Vector2d> { |
| 89 typedef gfx::Vector2d param_type; | 84 typedef gfx::Vector2d param_type; |
| 90 static void GetSize(base::PickleSizer* s, const param_type& p); | 85 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 91 static void Write(base::Pickle* m, const param_type& p); | 86 static void Write(base::Pickle* m, const param_type& p); |
| 92 static bool Read(const base::Pickle* m, | 87 static bool Read(const base::Pickle* m, |
| 93 base::PickleIterator* iter, | 88 base::PickleIterator* iter, |
| 94 param_type* r); | 89 param_type* r); |
| 95 static void Log(const param_type& p, std::string* l); | 90 static void Log(const param_type& p, std::string* l); |
| 96 }; | 91 }; |
| 97 | 92 |
| 98 template <> | 93 template <> |
| 99 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> { | 94 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Vector2dF> { |
| 100 typedef gfx::Vector2dF param_type; | 95 typedef gfx::Vector2dF param_type; |
| 101 static void Write(base::Pickle* m, const param_type& p); | 96 static void Write(base::Pickle* m, const param_type& p); |
| 102 static bool Read(const base::Pickle* m, | 97 static bool Read(const base::Pickle* m, |
| 103 base::PickleIterator* iter, | 98 base::PickleIterator* iter, |
| 104 param_type* r); | 99 param_type* r); |
| 105 static void Log(const param_type& p, std::string* l); | 100 static void Log(const param_type& p, std::string* l); |
| 106 }; | 101 }; |
| 107 | 102 |
| 108 template <> | 103 template <> |
| 109 struct GFX_IPC_EXPORT ParamTraits<gfx::Rect> { | 104 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::Rect> { |
| 110 typedef gfx::Rect param_type; | 105 typedef gfx::Rect param_type; |
| 111 static void Write(base::Pickle* m, const param_type& p); | 106 static void Write(base::Pickle* m, const param_type& p); |
| 112 static bool Read(const base::Pickle* m, | 107 static bool Read(const base::Pickle* m, |
| 113 base::PickleIterator* iter, | 108 base::PickleIterator* iter, |
| 114 param_type* r); | 109 param_type* r); |
| 115 static void Log(const param_type& p, std::string* l); | 110 static void Log(const param_type& p, std::string* l); |
| 116 }; | 111 }; |
| 117 | 112 |
| 118 template <> | 113 template <> |
| 119 struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> { | 114 struct GFX_IPC_GEOMETRY_EXPORT ParamTraits<gfx::RectF> { |
| 120 typedef gfx::RectF param_type; | 115 typedef gfx::RectF param_type; |
| 121 static void GetSize(base::PickleSizer* s, const param_type& p); | 116 static void GetSize(base::PickleSizer* s, const param_type& p); |
| 122 static void Write(base::Pickle* m, const param_type& p); | 117 static void Write(base::Pickle* m, const param_type& p); |
| 123 static bool Read(const base::Pickle* m, | 118 static bool Read(const base::Pickle* m, |
| 124 base::PickleIterator* iter, | 119 base::PickleIterator* iter, |
| 125 param_type* r); | 120 param_type* r); |
| 126 static void Log(const param_type& p, std::string* l); | 121 static void Log(const param_type& p, std::string* l); |
| 127 }; | 122 }; |
| 128 | 123 |
| 129 template <> | 124 template <> |
| 130 struct GFX_IPC_EXPORT ParamTraits<gfx::Range> { | 125 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; | 126 typedef gfx::ScrollOffset param_type; |
| 142 static void Write(base::Pickle* m, const param_type& p); | 127 static void Write(base::Pickle* m, const param_type& p); |
| 143 static bool Read(const base::Pickle* m, | 128 static bool Read(const base::Pickle* m, |
| 144 base::PickleIterator* iter, | 129 base::PickleIterator* iter, |
| 145 param_type* r); | 130 param_type* r); |
| 146 static void Log(const param_type& p, std::string* l); | 131 static void Log(const param_type& p, std::string* l); |
| 147 }; | 132 }; |
| 148 | 133 |
| 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 | 134 } // namespace IPC |
| 166 | 135 |
| 167 #endif // UI_GFX_IPC_GFX_PARAM_TRAITS_H_ | 136 #endif // UI_GFX_IPC_GEOMETRY_GFX_PARAM_TRAITS_H_ |
| OLD | NEW |