Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ui / gfx / ipc / gfx_param_traits.h
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
3 // found in the LICENSE file.
4
5 #ifndef UI_GFX_IPC_GFX_PARAM_TRAITS_H_
6 #define UI_GFX_IPC_GFX_PARAM_TRAITS_H_
7
8 #include <string>
9
10 #include "ipc/ipc_message_utils.h"
11 #include "ui/gfx/ipc/gfx_ipc_export.h"
12 #include "ui/gfx/ipc/gfx_param_traits.h"
13
14 class SkBitmap;
15
16 namespace gfx {
17 class Point;
18 class PointF;
19 class Rect;
20 class RectF;
21 class Size;
22 class SizeF;
23 class Vector2d;
24 class Vector2dF;
25 }  // namespace gfx
26
27 namespace IPC {
28
29 template <>
30 struct GFX_IPC_EXPORT ParamTraits<gfx::Point> {
31   typedef gfx::Point param_type;
32   static void Write(Message* m, const param_type& p);
33   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
34   static void Log(const param_type& p, std::string* l);
35 };
36
37 template <>
38 struct GFX_IPC_EXPORT ParamTraits<gfx::PointF> {
39   typedef gfx::PointF param_type;
40   static void Write(Message* m, const param_type& p);
41   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
42   static void Log(const param_type& p, std::string* l);
43 };
44
45 template <>
46 struct GFX_IPC_EXPORT ParamTraits<gfx::Size> {
47   typedef gfx::Size param_type;
48   static void Write(Message* m, const param_type& p);
49   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
50   static void Log(const param_type& p, std::string* l);
51 };
52
53 template <>
54 struct GFX_IPC_EXPORT ParamTraits<gfx::SizeF> {
55   typedef gfx::SizeF param_type;
56   static void Write(Message* m, const param_type& p);
57   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
58   static void Log(const param_type& p, std::string* l);
59 };
60
61 template <>
62 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2d> {
63   typedef gfx::Vector2d param_type;
64   static void Write(Message* m, const param_type& p);
65   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
66   static void Log(const param_type& p, std::string* l);
67 };
68
69 template <>
70 struct GFX_IPC_EXPORT ParamTraits<gfx::Vector2dF> {
71   typedef gfx::Vector2dF param_type;
72   static void Write(Message* m, const param_type& p);
73   static bool Read(const Message* m, PickleIterator* iter, 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::Rect> {
79   typedef gfx::Rect param_type;
80   static void Write(Message* m, const param_type& p);
81   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
82   static void Log(const param_type& p, std::string* l);
83 };
84
85 template <>
86 struct GFX_IPC_EXPORT ParamTraits<gfx::RectF> {
87   typedef gfx::RectF param_type;
88   static void Write(Message* m, const param_type& p);
89   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
90   static void Log(const param_type& p, std::string* l);
91 };
92
93 template <>
94 struct GFX_IPC_EXPORT ParamTraits<SkBitmap> {
95   typedef SkBitmap param_type;
96   static void Write(Message* m, const param_type& p);
97
98   // Note: This function expects parameter |r| to be of type &SkBitmap since
99   // r->SetConfig() and r->SetPixels() are called.
100   static bool Read(const Message* m, PickleIterator* iter, param_type* r);
101
102   static void Log(const param_type& p, std::string* l);
103 };
104
105 }  // namespace IPC
106
107 #endif  // UI_GFX_IPC_GFX_PARAM_TRAITS_H_