OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ | 5 #ifndef SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ |
6 #define SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ | 6 #define SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "mojo/public/cpp/bindings/type_converter.h" | 12 #include "mojo/public/cpp/bindings/type_converter.h" |
| 13 #include "services/ui/public/cpp/ui_export.h" |
13 | 14 |
14 class SkBitmap; | 15 class SkBitmap; |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Rect; | 18 class Rect; |
18 class Size; | 19 class Size; |
19 } | 20 } |
20 | 21 |
21 namespace mojo { | 22 namespace mojo { |
22 | 23 |
23 // TODO(beng): these methods serialize types used for standard properties | 24 // TODO(beng): these methods serialize types used for standard properties |
24 // to vectors of bytes used by Window::SetSharedProperty(). | 25 // to vectors of bytes used by Window::SetSharedProperty(). |
25 // replace this with serialization code generated @ bindings. | 26 // replace this with serialization code generated @ bindings. |
26 // This would be especially useful for SkBitmap, which could be | 27 // This would be especially useful for SkBitmap, which could be |
27 // replaced with the skia.Bitmap mojom struct serialization. | 28 // replaced with the skia.Bitmap mojom struct serialization. |
28 | 29 |
29 template <> | 30 template <> |
30 struct TypeConverter<std::vector<uint8_t>, gfx::Rect> { | 31 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, gfx::Rect> { |
31 static std::vector<uint8_t> Convert(const gfx::Rect& input); | 32 static std::vector<uint8_t> Convert(const gfx::Rect& input); |
32 }; | 33 }; |
33 template <> | 34 template <> |
34 struct TypeConverter<gfx::Rect, std::vector<uint8_t>> { | 35 struct UI_EXPORT TypeConverter<gfx::Rect, std::vector<uint8_t>> { |
35 static gfx::Rect Convert(const std::vector<uint8_t>& input); | 36 static gfx::Rect Convert(const std::vector<uint8_t>& input); |
36 }; | 37 }; |
37 | 38 |
38 template <> | 39 template <> |
39 struct TypeConverter<std::vector<uint8_t>, gfx::Size> { | 40 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, gfx::Size> { |
40 static std::vector<uint8_t> Convert(const gfx::Size& input); | 41 static std::vector<uint8_t> Convert(const gfx::Size& input); |
41 }; | 42 }; |
42 template <> | 43 template <> |
43 struct TypeConverter<gfx::Size, std::vector<uint8_t>> { | 44 struct UI_EXPORT TypeConverter<gfx::Size, std::vector<uint8_t>> { |
44 static gfx::Size Convert(const std::vector<uint8_t>& input); | 45 static gfx::Size Convert(const std::vector<uint8_t>& input); |
45 }; | 46 }; |
46 | 47 |
47 template <> | 48 template <> |
48 struct TypeConverter<std::vector<uint8_t>, int32_t> { | 49 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, int32_t> { |
49 static std::vector<uint8_t> Convert(const int32_t& input); | 50 static std::vector<uint8_t> Convert(const int32_t& input); |
50 }; | 51 }; |
51 template <> | 52 template <> |
52 struct TypeConverter<int32_t, std::vector<uint8_t>> { | 53 struct UI_EXPORT TypeConverter<int32_t, std::vector<uint8_t>> { |
53 static int32_t Convert(const std::vector<uint8_t>& input); | 54 static int32_t Convert(const std::vector<uint8_t>& input); |
54 }; | 55 }; |
55 | 56 |
56 template <> | 57 template <> |
57 struct TypeConverter<std::vector<uint8_t>, base::string16> { | 58 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, base::string16> { |
58 static std::vector<uint8_t> Convert(const base::string16& input); | 59 static std::vector<uint8_t> Convert(const base::string16& input); |
59 }; | 60 }; |
60 template <> | 61 template <> |
61 struct TypeConverter<base::string16, std::vector<uint8_t>> { | 62 struct UI_EXPORT TypeConverter<base::string16, std::vector<uint8_t>> { |
62 static base::string16 Convert(const std::vector<uint8_t>& input); | 63 static base::string16 Convert(const std::vector<uint8_t>& input); |
63 }; | 64 }; |
64 | 65 |
65 template <> | 66 template <> |
66 struct TypeConverter<std::vector<uint8_t>, std::string> { | 67 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, std::string> { |
67 static std::vector<uint8_t> Convert(const std::string& input); | 68 static std::vector<uint8_t> Convert(const std::string& input); |
68 }; | 69 }; |
69 template <> | 70 template <> |
70 struct TypeConverter<std::string, std::vector<uint8_t>> { | 71 struct UI_EXPORT TypeConverter<std::string, std::vector<uint8_t>> { |
71 static std::string Convert(const std::vector<uint8_t>& input); | 72 static std::string Convert(const std::vector<uint8_t>& input); |
72 }; | 73 }; |
73 | 74 |
74 // NOTE: These methods only serialize and deserialize the common case of RGBA | 75 // NOTE: These methods only serialize and deserialize the common case of RGBA |
75 // 8888 bitmaps with premultiplied alpha. | 76 // 8888 bitmaps with premultiplied alpha. |
76 template <> | 77 template <> |
77 struct TypeConverter<std::vector<uint8_t>, SkBitmap> { | 78 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, SkBitmap> { |
78 static std::vector<uint8_t> Convert(const SkBitmap& input); | 79 static std::vector<uint8_t> Convert(const SkBitmap& input); |
79 }; | 80 }; |
80 template <> | 81 template <> |
81 struct TypeConverter<SkBitmap, std::vector<uint8_t>> { | 82 struct UI_EXPORT TypeConverter<SkBitmap, std::vector<uint8_t>> { |
82 static SkBitmap Convert(const std::vector<uint8_t>& input); | 83 static SkBitmap Convert(const std::vector<uint8_t>& input); |
83 }; | 84 }; |
84 | 85 |
85 template <> | 86 template <> |
86 struct TypeConverter<std::vector<uint8_t>, bool> { | 87 struct UI_EXPORT TypeConverter<std::vector<uint8_t>, bool> { |
87 static std::vector<uint8_t> Convert(bool input); | 88 static std::vector<uint8_t> Convert(bool input); |
88 }; | 89 }; |
89 template <> | 90 template <> |
90 struct TypeConverter<bool, std::vector<uint8_t>> { | 91 struct UI_EXPORT TypeConverter<bool, std::vector<uint8_t>> { |
91 static bool Convert(const std::vector<uint8_t>& input); | 92 static bool Convert(const std::vector<uint8_t>& input); |
92 }; | 93 }; |
93 | 94 |
94 } // namespace mojo | 95 } // namespace mojo |
95 | 96 |
96 #endif // SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ | 97 #endif // SERVICES_UI_PUBLIC_CPP_PROPERTY_TYPE_CONVERTERS_H_ |
OLD | NEW |