• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "ppapi/proxy/serialized_structs.h"
6 
7 #include "base/pickle.h"
8 #include "build/build_config.h"
9 #include "ppapi/c/dev/ppb_font_dev.h"
10 #include "ppapi/c/pp_file_info.h"
11 #include "ppapi/c/pp_rect.h"
12 #include "ppapi/c/trusted/ppb_browser_font_trusted.h"
13 #include "ppapi/shared_impl/var.h"
14 
15 namespace ppapi {
16 namespace proxy {
17 
SerializedFontDescription()18 SerializedFontDescription::SerializedFontDescription()
19     : face(),
20       family(0),
21       size(0),
22       weight(0),
23       italic(PP_FALSE),
24       small_caps(PP_FALSE),
25       letter_spacing(0),
26       word_spacing(0) {
27 }
28 
~SerializedFontDescription()29 SerializedFontDescription::~SerializedFontDescription() {}
30 
SetFromPPFontDescription(const PP_FontDescription_Dev & desc)31 void SerializedFontDescription::SetFromPPFontDescription(
32     const PP_FontDescription_Dev& desc) {
33   StringVar* string_var = StringVar::FromPPVar(desc.face);
34   face = string_var ? string_var->value() : std::string();
35 
36   family = desc.family;
37   size = desc.size;
38   weight = desc.weight;
39   italic = desc.italic;
40   small_caps = desc.small_caps;
41   letter_spacing = desc.letter_spacing;
42   word_spacing = desc.word_spacing;
43 }
44 
SetFromPPBrowserFontDescription(const PP_BrowserFont_Trusted_Description & desc)45 void SerializedFontDescription::SetFromPPBrowserFontDescription(
46     const PP_BrowserFont_Trusted_Description& desc) {
47   StringVar* string_var = StringVar::FromPPVar(desc.face);
48   face = string_var ? string_var->value() : std::string();
49 
50   family = desc.family;
51   size = desc.size;
52   weight = desc.weight;
53   italic = desc.italic;
54   small_caps = desc.small_caps;
55   letter_spacing = desc.letter_spacing;
56   word_spacing = desc.word_spacing;
57 }
58 
SetToPPFontDescription(PP_FontDescription_Dev * desc) const59 void SerializedFontDescription::SetToPPFontDescription(
60     PP_FontDescription_Dev* desc) const {
61   desc->face = StringVar::StringToPPVar(face);
62   desc->family = static_cast<PP_FontFamily_Dev>(family);
63   desc->size = size;
64   desc->weight = static_cast<PP_FontWeight_Dev>(weight);
65   desc->italic = italic;
66   desc->small_caps = small_caps;
67   desc->letter_spacing = letter_spacing;
68   desc->word_spacing = word_spacing;
69 }
70 
SetToPPBrowserFontDescription(PP_BrowserFont_Trusted_Description * desc) const71 void SerializedFontDescription::SetToPPBrowserFontDescription(
72     PP_BrowserFont_Trusted_Description* desc) const {
73   desc->face = StringVar::StringToPPVar(face);
74   desc->family = static_cast<PP_BrowserFont_Trusted_Family>(family);
75   desc->size = size;
76   desc->weight = static_cast<PP_BrowserFont_Trusted_Weight>(weight);
77   desc->italic = italic;
78   desc->small_caps = small_caps;
79   desc->letter_spacing = letter_spacing;
80   desc->word_spacing = word_spacing;
81 }
82 
SerializedNetworkInfo()83 SerializedNetworkInfo::SerializedNetworkInfo()
84     : type(PP_NETWORKLIST_TYPE_UNKNOWN),
85       state(PP_NETWORKLIST_STATE_DOWN),
86       mtu(0) {
87 }
88 
~SerializedNetworkInfo()89 SerializedNetworkInfo::~SerializedNetworkInfo() {}
90 
SerializedTrueTypeFontDesc()91 SerializedTrueTypeFontDesc::SerializedTrueTypeFontDesc()
92     : family(),
93       generic_family(),
94       style(),
95       weight(),
96       width(),
97       charset() {
98 }
99 
~SerializedTrueTypeFontDesc()100 SerializedTrueTypeFontDesc::~SerializedTrueTypeFontDesc() {}
101 
SetFromPPTrueTypeFontDesc(const PP_TrueTypeFontDesc_Dev & desc)102 void SerializedTrueTypeFontDesc::SetFromPPTrueTypeFontDesc(
103     const PP_TrueTypeFontDesc_Dev& desc) {
104   StringVar* string_var = StringVar::FromPPVar(desc.family);
105   family = string_var ? string_var->value() : std::string();
106 
107   generic_family = desc.generic_family;
108   style = desc.style;
109   weight = desc.weight;
110   width = desc.width;
111   charset = desc.charset;
112 }
113 
CopyToPPTrueTypeFontDesc(PP_TrueTypeFontDesc_Dev * desc) const114 void SerializedTrueTypeFontDesc::CopyToPPTrueTypeFontDesc(
115     PP_TrueTypeFontDesc_Dev* desc) const {
116   desc->family = StringVar::StringToPPVar(family);
117 
118   desc->generic_family = generic_family;
119   desc->style = style;
120   desc->weight = weight;
121   desc->width = width;
122   desc->charset = charset;
123 }
124 
PPBFlash_DrawGlyphs_Params()125 PPBFlash_DrawGlyphs_Params::PPBFlash_DrawGlyphs_Params()
126     : instance(0),
127       font_desc(),
128       color(0) {
129   clip.point.x = 0;
130   clip.point.y = 0;
131   clip.size.height = 0;
132   clip.size.width = 0;
133   position.x = 0;
134   position.y = 0;
135   allow_subpixel_aa = PP_FALSE;
136 }
137 
~PPBFlash_DrawGlyphs_Params()138 PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {}
139 
140 }  // namespace proxy
141 }  // namespace ppapi
142