1 // Copyright (c) 2012 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 PPAPI_PROXY_SERIALIZED_STRUCTS_H_
6 #define PPAPI_PROXY_SERIALIZED_STRUCTS_H_
7 
8 #include <stdint.h>
9 
10 #include <string>
11 #include <vector>
12 
13 #include "base/logging.h"
14 #include "build/build_config.h"
15 #include "ppapi/c/dev/ppb_truetype_font_dev.h"
16 #include "ppapi/c/pp_bool.h"
17 #include "ppapi/c/pp_codecs.h"
18 #include "ppapi/c/pp_instance.h"
19 #include "ppapi/c/pp_point.h"
20 #include "ppapi/c/pp_rect.h"
21 #include "ppapi/c/ppb_network_list.h"
22 #include "ppapi/c/private/ppb_net_address_private.h"
23 #include "ppapi/proxy/ppapi_proxy_export.h"
24 #include "ppapi/shared_impl/host_resource.h"
25 
26 struct PP_BrowserFont_Trusted_Description;
27 
28 namespace ppapi {
29 namespace proxy {
30 
31 // PP_BrowserFontDescription  has to be redefined with a string in place of the
32 // PP_Var used for the face name.
33 struct PPAPI_PROXY_EXPORT SerializedFontDescription {
34   SerializedFontDescription();
35   ~SerializedFontDescription();
36 
37   void SetFromPPBrowserFontDescription(
38       const PP_BrowserFont_Trusted_Description& desc);
39 
40   void SetToPPBrowserFontDescription(
41       PP_BrowserFont_Trusted_Description* desc) const;
42 
43   std::string face;
44   int32_t family;
45   uint32_t size;
46   int32_t weight;
47   PP_Bool italic;
48   PP_Bool small_caps;
49   int32_t letter_spacing;
50   int32_t word_spacing;
51 };
52 
53 struct PPAPI_PROXY_EXPORT SerializedNetworkInfo {
54   SerializedNetworkInfo();
55   ~SerializedNetworkInfo();
56 
57   std::string name;
58   PP_NetworkList_Type type;
59   PP_NetworkList_State state;
60   std::vector<PP_NetAddress_Private> addresses;
61   std::string display_name;
62   int mtu;
63 };
64 typedef std::vector<SerializedNetworkInfo> SerializedNetworkList;
65 
66 struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc {
67   SerializedTrueTypeFontDesc();
68   ~SerializedTrueTypeFontDesc();
69 
70   // Sets this to correspond to the contents of a PP_TrueTypeFontDesc_Dev.
71   //
72   // The reference count of the desc.family PP_Var will be unchanged and the
73   // caller is responsible for releasing it.
74   void SetFromPPTrueTypeFontDesc(const PP_TrueTypeFontDesc_Dev& desc);
75 
76   // Converts this to a PP_TrueTypeFontDesc_Dev.
77   //
78   // The desc.family PP_Var will have one reference assigned to it. The caller
79   // is responsible for releasing it.
80   void CopyToPPTrueTypeFontDesc(PP_TrueTypeFontDesc_Dev* desc) const;
81 
82   std::string family;
83   PP_TrueTypeFontFamily_Dev generic_family;
84   PP_TrueTypeFontStyle_Dev style;
85   PP_TrueTypeFontWeight_Dev weight;
86   PP_TrueTypeFontWidth_Dev width;
87   PP_TrueTypeFontCharset_Dev charset;
88 };
89 
90 struct SerializedDirEntry {
91   std::string name;
92   bool is_dir;
93 };
94 
95 struct PPAPI_PROXY_EXPORT PPBFlash_DrawGlyphs_Params {
96   PPBFlash_DrawGlyphs_Params();
97   ~PPBFlash_DrawGlyphs_Params();
98 
99   PP_Instance instance;
100   ppapi::HostResource image_data;
101   SerializedFontDescription font_desc;
102   uint32_t color;
103   PP_Point position;
104   PP_Rect clip;
105   float transformation[3][3];
106   PP_Bool allow_subpixel_aa;
107   std::vector<uint16_t> glyph_indices;
108   std::vector<PP_Point> glyph_advances;
109 };
110 
111 struct PPBURLLoader_UpdateProgress_Params {
112   PP_Instance instance;
113   ppapi::HostResource resource;
114   int64_t bytes_sent;
115   int64_t total_bytes_to_be_sent;
116   int64_t bytes_received;
117   int64_t total_bytes_to_be_received;
118 };
119 
120 struct PPB_AudioEncodeParameters {
121   uint32_t channels;
122   uint32_t input_sample_rate;
123   uint32_t input_sample_size;
124   PP_AudioProfile output_profile;
125   uint32_t initial_bitrate;
126   PP_HardwareAcceleration acceleration;
127 };
128 
129 }  // namespace proxy
130 }  // namespace ppapi
131 
132 #endif  // PPAPI_PROXY_SERIALIZED_STRUCTS_H_
133