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 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 29 SerializedFontDescription::~SerializedFontDescription() {} 30 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 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 59 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 71 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 83 SerializedTrueTypeFontDesc::SerializedTrueTypeFontDesc() 84 : family(), 85 generic_family(), 86 style(), 87 weight(), 88 width(), 89 charset() { 90 } 91 92 SerializedTrueTypeFontDesc::~SerializedTrueTypeFontDesc() {} 93 94 void SerializedTrueTypeFontDesc::SetFromPPTrueTypeFontDesc( 95 const PP_TrueTypeFontDesc_Dev& desc) { 96 StringVar* string_var = StringVar::FromPPVar(desc.family); 97 family = string_var ? string_var->value() : std::string(); 98 99 generic_family = desc.generic_family; 100 style = desc.style; 101 weight = desc.weight; 102 width = desc.width; 103 charset = desc.charset; 104 } 105 106 void SerializedTrueTypeFontDesc::CopyToPPTrueTypeFontDesc( 107 PP_TrueTypeFontDesc_Dev* desc) const { 108 desc->family = StringVar::StringToPPVar(family); 109 110 desc->generic_family = generic_family; 111 desc->style = style; 112 desc->weight = weight; 113 desc->width = width; 114 desc->charset = charset; 115 } 116 117 PPBFlash_DrawGlyphs_Params::PPBFlash_DrawGlyphs_Params() 118 : instance(0), 119 font_desc(), 120 color(0) { 121 clip.point.x = 0; 122 clip.point.y = 0; 123 clip.size.height = 0; 124 clip.size.width = 0; 125 position.x = 0; 126 position.y = 0; 127 allow_subpixel_aa = PP_FALSE; 128 } 129 130 PPBFlash_DrawGlyphs_Params::~PPBFlash_DrawGlyphs_Params() {} 131 132 } // namespace proxy 133 } // namespace ppapi 134