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