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 <string> 9 #include <vector> 10 11 #include "base/logging.h" 12 #include "base/memory/shared_memory.h" 13 #include "build/build_config.h" 14 #include "ppapi/c/dev/ppb_truetype_font_dev.h" 15 #include "ppapi/c/pp_bool.h" 16 #include "ppapi/c/pp_instance.h" 17 #include "ppapi/c/pp_point.h" 18 #include "ppapi/c/pp_rect.h" 19 #include "ppapi/proxy/ppapi_proxy_export.h" 20 #include "ppapi/shared_impl/host_resource.h" 21 22 class Pickle; 23 struct PP_FontDescription_Dev; 24 struct PP_BrowserFont_Trusted_Description; 25 26 namespace ppapi { 27 namespace proxy { 28 29 // PP_FontDescription_Dev/PP_BrowserFontDescription (same definition, different 30 // names) has to be redefined with a string in place of the PP_Var used for the 31 // face name. 32 struct PPAPI_PROXY_EXPORT SerializedFontDescription { 33 SerializedFontDescription(); 34 ~SerializedFontDescription(); 35 36 // Converts a PP_FontDescription_Dev to a SerializedFontDescription. 37 // 38 // The reference of |face| owned by the PP_FontDescription_Dev will be 39 // unchanged and the caller is responsible for freeing it. 40 void SetFromPPFontDescription(const PP_FontDescription_Dev& desc); 41 void SetFromPPBrowserFontDescription( 42 const PP_BrowserFont_Trusted_Description& desc); 43 44 // Converts to a PP_FontDescription_Dev. The face name will have one ref 45 // assigned to it. The caller is responsible for freeing it. 46 void SetToPPFontDescription(PP_FontDescription_Dev* desc) const; 47 void SetToPPBrowserFontDescription( 48 PP_BrowserFont_Trusted_Description* desc) const; 49 50 std::string face; 51 int32_t family; 52 uint32_t size; 53 int32_t weight; 54 PP_Bool italic; 55 PP_Bool small_caps; 56 int32_t letter_spacing; 57 int32_t word_spacing; 58 }; 59 60 struct PPAPI_PROXY_EXPORT SerializedTrueTypeFontDesc { 61 SerializedTrueTypeFontDesc(); 62 ~SerializedTrueTypeFontDesc(); 63 64 // Sets this to correspond to the contents of a PP_TrueTypeFontDesc_Dev. 65 // 66 // The reference count of the desc.family PP_Var will be unchanged and the 67 // caller is responsible for releasing it. 68 void SetFromPPTrueTypeFontDesc(const PP_TrueTypeFontDesc_Dev& desc); 69 70 // Converts this to a PP_FontDescription_Dev. 71 // 72 // The desc.family PP_Var will have one reference assigned to it. The caller 73 // is responsible for releasing it. 74 void CopyToPPTrueTypeFontDesc(PP_TrueTypeFontDesc_Dev* desc) const; 75 76 std::string family; 77 PP_TrueTypeFontFamily_Dev generic_family; 78 PP_TrueTypeFontStyle_Dev style; 79 PP_TrueTypeFontWeight_Dev weight; 80 PP_TrueTypeFontWidth_Dev width; 81 PP_TrueTypeFontCharset_Dev charset; 82 }; 83 84 struct SerializedDirEntry { 85 std::string name; 86 bool is_dir; 87 }; 88 89 struct PPAPI_PROXY_EXPORT PPBFlash_DrawGlyphs_Params { 90 PPBFlash_DrawGlyphs_Params(); 91 ~PPBFlash_DrawGlyphs_Params(); 92 93 PP_Instance instance; 94 ppapi::HostResource image_data; 95 SerializedFontDescription font_desc; 96 uint32_t color; 97 PP_Point position; 98 PP_Rect clip; 99 float transformation[3][3]; 100 PP_Bool allow_subpixel_aa; 101 std::vector<uint16_t> glyph_indices; 102 std::vector<PP_Point> glyph_advances; 103 }; 104 105 struct PPBURLLoader_UpdateProgress_Params { 106 PP_Instance instance; 107 ppapi::HostResource resource; 108 int64_t bytes_sent; 109 int64_t total_bytes_to_be_sent; 110 int64_t bytes_received; 111 int64_t total_bytes_to_be_received; 112 }; 113 114 struct PPPDecryptor_Buffer { 115 ppapi::HostResource resource; 116 uint32_t size; 117 base::SharedMemoryHandle handle; 118 }; 119 120 // TODO(raymes): Make ImageHandle compatible with SerializedHandle. 121 #if defined(OS_WIN) 122 typedef HANDLE ImageHandle; 123 #elif defined(TOOLKIT_GTK) 124 // On legacy X Windows this is a SysV shared memory key. 125 typedef int ImageHandle; 126 #else 127 typedef base::SharedMemoryHandle ImageHandle; 128 #endif 129 130 } // namespace proxy 131 } // namespace ppapi 132 133 #endif // PPAPI_PROXY_SERIALIZED_STRUCTS_H_ 134