OLD | NEW |
(Empty) | |
| 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/c/pp_errors.h" |
| 6 #include "ppapi/c/private/ppb_flash.h" |
| 7 #include "ppapi/shared_impl/ppapi_globals.h" |
| 8 #include "ppapi/shared_impl/proxy_lock.h" |
| 9 #include "ppapi/shared_impl/var.h" |
| 10 #include "ppapi/thunk/enter.h" |
| 11 #include "ppapi/thunk/ppb_flash_api.h" |
| 12 #include "ppapi/thunk/ppb_instance_api.h" |
| 13 #include "ppapi/thunk/thunk.h" |
| 14 |
| 15 namespace ppapi { |
| 16 namespace thunk { |
| 17 |
| 18 namespace { |
| 19 |
| 20 void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) { |
| 21 EnterInstance enter(instance); |
| 22 if (enter.failed()) |
| 23 return; |
| 24 enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top); |
| 25 } |
| 26 |
| 27 PP_Bool DrawGlyphs(PP_Instance instance, |
| 28 PP_Resource pp_image_data, |
| 29 const PP_FontDescription_Dev* font_desc, |
| 30 uint32_t color, |
| 31 const PP_Point* position, |
| 32 const PP_Rect* clip, |
| 33 const float transformation[3][3], |
| 34 PP_Bool allow_subpixel_aa, |
| 35 uint32_t glyph_count, |
| 36 const uint16_t glyph_indices[], |
| 37 const PP_Point glyph_advances[]) { |
| 38 EnterInstance enter(instance); |
| 39 if (enter.failed()) |
| 40 return PP_FALSE; |
| 41 return enter.functions()->GetFlashAPI()->DrawGlyphs( |
| 42 instance, pp_image_data, font_desc, color, position, clip, transformation, |
| 43 allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances); |
| 44 } |
| 45 |
| 46 PP_Bool DrawGlyphs11(PP_Instance instance, |
| 47 PP_Resource pp_image_data, |
| 48 const PP_FontDescription_Dev* font_desc, |
| 49 uint32_t color, |
| 50 PP_Point position, |
| 51 PP_Rect clip, |
| 52 const float transformation[3][3], |
| 53 uint32_t glyph_count, |
| 54 const uint16_t glyph_indices[], |
| 55 const PP_Point glyph_advances[]) { |
| 56 // Backwards-compatible version. DrawGlyphs locks; no need to lock here. |
| 57 return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, |
| 58 &clip, transformation, PP_TRUE, glyph_count, glyph_indices, |
| 59 glyph_advances); |
| 60 } |
| 61 |
| 62 PP_Var GetProxyForURL(PP_Instance instance, const char* url) { |
| 63 EnterInstance enter(instance); |
| 64 if (enter.failed()) |
| 65 return PP_MakeUndefined(); |
| 66 return enter.functions()->GetFlashAPI()->GetProxyForURL(instance, url); |
| 67 } |
| 68 |
| 69 int32_t Navigate(PP_Resource request_id, |
| 70 const char* target, |
| 71 PP_Bool from_user_action) { |
| 72 // TODO(brettw): this function should take an instance. |
| 73 // To work around this, use the PP_Instance from the resource. |
| 74 PP_Instance instance; |
| 75 { |
| 76 thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); |
| 77 if (enter.failed()) |
| 78 return PP_ERROR_BADRESOURCE; |
| 79 instance = enter.resource()->pp_instance(); |
| 80 } |
| 81 |
| 82 EnterInstance enter(instance); |
| 83 if (enter.failed()) |
| 84 return PP_ERROR_BADARGUMENT; |
| 85 return enter.functions()->GetFlashAPI()->Navigate(instance, request_id, |
| 86 target, from_user_action); |
| 87 } |
| 88 |
| 89 int32_t Navigate11(PP_Resource request_id, |
| 90 const char* target, |
| 91 bool from_user_action) { |
| 92 // Backwards-compatible version. Navigate locks; no need to lock here. |
| 93 return Navigate(request_id, target, PP_FromBool(from_user_action)); |
| 94 } |
| 95 |
| 96 void RunMessageLoop(PP_Instance instance) { |
| 97 EnterInstance enter(instance); |
| 98 if (enter.failed()) |
| 99 return; |
| 100 enter.functions()->GetFlashAPI()->RunMessageLoop(instance); |
| 101 } |
| 102 |
| 103 void QuitMessageLoop(PP_Instance instance) { |
| 104 EnterInstance enter(instance); |
| 105 if (enter.failed()) |
| 106 return; |
| 107 enter.functions()->GetFlashAPI()->QuitMessageLoop(instance); |
| 108 } |
| 109 |
| 110 double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { |
| 111 EnterInstance enter(instance); |
| 112 if (enter.failed()) |
| 113 return 0.0; |
| 114 return enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset(instance, t); |
| 115 } |
| 116 |
| 117 PP_Var GetCommandLineArgs(PP_Module /* pp_module */) { |
| 118 // There's no instance so we have to reach into the globals without thunking. |
| 119 ProxyAutoLock lock; |
| 120 return StringVar::StringToPPVar(PpapiGlobals::Get()->GetCommandLine()); |
| 121 } |
| 122 |
| 123 void PreLoadFontWin(const void* logfontw) { |
| 124 // There's no instance so we have to reach into the delegate without |
| 125 // thunking. |
| 126 ProxyAutoLock lock; |
| 127 PpapiGlobals::Get()->PreCacheFontForFlash(logfontw); |
| 128 } |
| 129 |
| 130 PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) { |
| 131 EnterInstance enter(instance); |
| 132 if (enter.failed()) |
| 133 return PP_FALSE; |
| 134 return enter.functions()->GetFlashAPI()->IsRectTopmost(instance, rect); |
| 135 } |
| 136 |
| 137 int32_t InvokePrinting(PP_Instance instance) { |
| 138 EnterInstance enter(instance); |
| 139 if (enter.failed()) |
| 140 return PP_ERROR_BADARGUMENT; |
| 141 return enter.functions()->GetFlashAPI()->InvokePrinting(instance); |
| 142 } |
| 143 |
| 144 void UpdateActivity(PP_Instance instance) { |
| 145 EnterInstance enter(instance); |
| 146 if (enter.failed()) |
| 147 return; |
| 148 enter.functions()->GetFlashAPI()->UpdateActivity(instance); |
| 149 } |
| 150 |
| 151 PP_Var GetDeviceID(PP_Instance instance) { |
| 152 EnterInstance enter(instance); |
| 153 if (enter.failed()) |
| 154 return PP_MakeUndefined(); |
| 155 return enter.functions()->GetFlashAPI()->GetDeviceID(instance); |
| 156 } |
| 157 |
| 158 const PPB_Flash_11 g_ppb_flash_11_thunk = { |
| 159 &SetInstanceAlwaysOnTop, |
| 160 &DrawGlyphs11, |
| 161 &GetProxyForURL, |
| 162 &Navigate11, |
| 163 &RunMessageLoop, |
| 164 &QuitMessageLoop, |
| 165 &GetLocalTimeZoneOffset, |
| 166 &GetCommandLineArgs |
| 167 }; |
| 168 |
| 169 const PPB_Flash_12_0 g_ppb_flash_12_0_thunk = { |
| 170 &SetInstanceAlwaysOnTop, |
| 171 &DrawGlyphs, |
| 172 &GetProxyForURL, |
| 173 &Navigate, |
| 174 &RunMessageLoop, |
| 175 &QuitMessageLoop, |
| 176 &GetLocalTimeZoneOffset, |
| 177 &GetCommandLineArgs, |
| 178 &PreLoadFontWin |
| 179 }; |
| 180 |
| 181 const PPB_Flash_12_1 g_ppb_flash_12_1_thunk = { |
| 182 &SetInstanceAlwaysOnTop, |
| 183 &DrawGlyphs, |
| 184 &GetProxyForURL, |
| 185 &Navigate, |
| 186 &RunMessageLoop, |
| 187 &QuitMessageLoop, |
| 188 &GetLocalTimeZoneOffset, |
| 189 &GetCommandLineArgs, |
| 190 &PreLoadFontWin, |
| 191 &IsRectTopmost, |
| 192 &InvokePrinting, |
| 193 &UpdateActivity |
| 194 }; |
| 195 |
| 196 const PPB_Flash_12_2 g_ppb_flash_12_2_thunk = { |
| 197 &SetInstanceAlwaysOnTop, |
| 198 &DrawGlyphs, |
| 199 &GetProxyForURL, |
| 200 &Navigate, |
| 201 &RunMessageLoop, |
| 202 &QuitMessageLoop, |
| 203 &GetLocalTimeZoneOffset, |
| 204 &GetCommandLineArgs, |
| 205 &PreLoadFontWin, |
| 206 &IsRectTopmost, |
| 207 &InvokePrinting, |
| 208 &UpdateActivity, |
| 209 &GetDeviceID |
| 210 }; |
| 211 |
| 212 } // namespace |
| 213 |
| 214 const PPB_Flash_11* GetPPB_Flash_11_Thunk() { |
| 215 return &g_ppb_flash_11_thunk; |
| 216 } |
| 217 |
| 218 const PPB_Flash_12_0* GetPPB_Flash_12_0_Thunk() { |
| 219 return &g_ppb_flash_12_0_thunk; |
| 220 } |
| 221 |
| 222 const PPB_Flash_12_1* GetPPB_Flash_12_1_Thunk() { |
| 223 return &g_ppb_flash_12_1_thunk; |
| 224 } |
| 225 |
| 226 const PPB_Flash_12_2* GetPPB_Flash_12_2_Thunk() { |
| 227 return &g_ppb_flash_12_2_thunk; |
| 228 } |
| 229 |
| 230 } // namespace thunk |
| 231 } // namespace ppapi |
OLD | NEW |