diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 05:32:04 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-24 05:32:04 +0000 |
commit | a085aed793ce5577c7a0fca65e68447dd6d6f5ef (patch) | |
tree | a0799313b93fe269db084e68b229dddfcc9b5614 /ppapi/thunk | |
parent | f2202083f44fb378bc03e784c6a02e863e686b40 (diff) | |
download | chromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.zip chromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.tar.gz chromium_src-a085aed793ce5577c7a0fca65e68447dd6d6f5ef.tar.bz2 |
Convert the PPB_Flash interface to use the thunk system.
This was a bit tricky since some of the functions had no instance context, so I added global functions on the PpapiGlobals interface for them. It would be nice to add a PP_Instance argument and fix this in the future.
I did a new style of doing the thunking. The "function APIs" haven't really worked out since it's almost always easier to add the functions directly on the instance one. Since this is a larger and more separable chunk, I just added a getter on the instance API for the flash API and thunk through that. I'd like to convert the remaining ~3 function APIs to either call directly on the instance or use this method, but that's not addressed by this patch.
I moved the flash command line switch to plugin_switches so this could be hooked up properly. It allowed me to delete the delegate API for this.
I combined the flash fullscreen functions into the new Flash API which removed a bit of code.
Review URL: https://chromiumcodereview.appspot.com/10091003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133636 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/thunk')
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private_flash.h | 25 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_api.h | 55 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_fullscreen_thunk.cc | 8 | ||||
-rw-r--r-- | ppapi/thunk/ppb_flash_thunk.cc | 231 | ||||
-rw-r--r-- | ppapi/thunk/ppb_instance_api.h | 9 | ||||
-rw-r--r-- | ppapi/thunk/thunk.h | 1 |
6 files changed, 321 insertions, 8 deletions
diff --git a/ppapi/thunk/interfaces_ppb_private_flash.h b/ppapi/thunk/interfaces_ppb_private_flash.h new file mode 100644 index 0000000..6d9fa82 --- /dev/null +++ b/ppapi/thunk/interfaces_ppb_private_flash.h @@ -0,0 +1,25 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Please see inteface_ppb_public_stable for the documentation on the format of +// this file. + +#include "ppapi/thunk/interfaces_preamble.h" + +PROXIED_API(PPB_Flash) + +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_INTERFACE_11_0, + PPB_Flash_11) +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_INTERFACE_12_0, + PPB_Flash_12_0) +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_INTERFACE_12_1, + PPB_Flash_12_1) +PROXIED_IFACE(PPB_Flash, + PPB_FLASH_INTERFACE_12_2, + PPB_Flash_12_2) + +#include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/ppb_flash_api.h b/ppapi/thunk/ppb_flash_api.h new file mode 100644 index 0000000..eacc9e8 --- /dev/null +++ b/ppapi/thunk/ppb_flash_api.h @@ -0,0 +1,55 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef PPAPI_THUNK_PPB_FLASH_API_H_ +#define PPAPI_THUNK_PPB_FLASH_API_H_ + +#include "ppapi/c/private/ppb_flash.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { +namespace thunk { + +// This class collects all of the Flash interface-related APIs into one place. +class PPAPI_THUNK_EXPORT PPB_Flash_API { + public: + virtual ~PPB_Flash_API() {} + + // Flash. + virtual void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) = 0; + virtual PP_Bool DrawGlyphs(PP_Instance instance, + PP_Resource pp_image_data, + const PP_FontDescription_Dev* font_desc, + uint32_t color, + const PP_Point* position, + const PP_Rect* clip, + const float transformation[3][3], + PP_Bool allow_subpixel_aa, + uint32_t glyph_count, + const uint16_t glyph_indices[], + const PP_Point glyph_advances[]) = 0; + virtual PP_Var GetProxyForURL(PP_Instance instance, const char* url) = 0; + virtual int32_t Navigate(PP_Instance instance, + PP_Resource request_info, + const char* target, + PP_Bool from_user_action) = 0; + virtual void RunMessageLoop(PP_Instance instance) = 0; + virtual void QuitMessageLoop(PP_Instance instance) = 0; + virtual double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) = 0; + virtual PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) = 0; + virtual int32_t InvokePrinting(PP_Instance instance) = 0; + virtual void UpdateActivity(PP_Instance instance) = 0; + virtual PP_Var GetDeviceID(PP_Instance instance) = 0; + + // FlashFullscreen. + virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0; + virtual PP_Bool FlashSetFullscreen(PP_Instance instance, + PP_Bool fullscreen) = 0; + virtual PP_Bool FlashGetScreenSize(PP_Instance instance, PP_Size* size) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_FLASH_API_H_ diff --git a/ppapi/thunk/ppb_flash_fullscreen_thunk.cc b/ppapi/thunk/ppb_flash_fullscreen_thunk.cc index ecaea96..aa9e224 100644 --- a/ppapi/thunk/ppb_flash_fullscreen_thunk.cc +++ b/ppapi/thunk/ppb_flash_fullscreen_thunk.cc @@ -7,6 +7,7 @@ #include "ppapi/thunk/thunk.h" #include "ppapi/thunk/enter.h" #include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/ppb_flash_api.h" #include "ppapi/thunk/resource_creation_api.h" namespace ppapi { @@ -18,21 +19,22 @@ PP_Bool IsFullscreen(PP_Instance instance) { EnterInstance enter(instance); if (enter.failed()) return PP_FALSE; - return enter.functions()->FlashIsFullscreen(instance); + return enter.functions()->GetFlashAPI()->FlashIsFullscreen(instance); } PP_Bool SetFullscreen(PP_Instance instance, PP_Bool fullscreen) { EnterInstance enter(instance); if (enter.failed()) return PP_FALSE; - return enter.functions()->FlashSetFullscreen(instance, fullscreen); + return enter.functions()->GetFlashAPI()->FlashSetFullscreen(instance, + fullscreen); } PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) { EnterInstance enter(instance); if (enter.failed()) return PP_FALSE; - return enter.functions()->FlashGetScreenSize(instance, size); + return enter.functions()->GetFlashAPI()->FlashGetScreenSize(instance, size); } const PPB_FlashFullscreen g_ppb_flash_fullscreen_thunk = { diff --git a/ppapi/thunk/ppb_flash_thunk.cc b/ppapi/thunk/ppb_flash_thunk.cc new file mode 100644 index 0000000..970cbac --- /dev/null +++ b/ppapi/thunk/ppb_flash_thunk.cc @@ -0,0 +1,231 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/private/ppb_flash.h" +#include "ppapi/shared_impl/ppapi_globals.h" +#include "ppapi/shared_impl/proxy_lock.h" +#include "ppapi/shared_impl/var.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppb_flash_api.h" +#include "ppapi/thunk/ppb_instance_api.h" +#include "ppapi/thunk/thunk.h" + +namespace ppapi { +namespace thunk { + +namespace { + +void SetInstanceAlwaysOnTop(PP_Instance instance, PP_Bool on_top) { + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->GetFlashAPI()->SetInstanceAlwaysOnTop(instance, on_top); +} + +PP_Bool DrawGlyphs(PP_Instance instance, + PP_Resource pp_image_data, + const PP_FontDescription_Dev* font_desc, + uint32_t color, + const PP_Point* position, + const PP_Rect* clip, + const float transformation[3][3], + PP_Bool allow_subpixel_aa, + uint32_t glyph_count, + const uint16_t glyph_indices[], + const PP_Point glyph_advances[]) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->GetFlashAPI()->DrawGlyphs( + instance, pp_image_data, font_desc, color, position, clip, transformation, + allow_subpixel_aa, glyph_count, glyph_indices, glyph_advances); +} + +PP_Bool DrawGlyphs11(PP_Instance instance, + PP_Resource pp_image_data, + const PP_FontDescription_Dev* font_desc, + uint32_t color, + PP_Point position, + PP_Rect clip, + const float transformation[3][3], + uint32_t glyph_count, + const uint16_t glyph_indices[], + const PP_Point glyph_advances[]) { + // Backwards-compatible version. DrawGlyphs locks; no need to lock here. + return DrawGlyphs(instance, pp_image_data, font_desc, color, &position, + &clip, transformation, PP_TRUE, glyph_count, glyph_indices, + glyph_advances); +} + +PP_Var GetProxyForURL(PP_Instance instance, const char* url) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetFlashAPI()->GetProxyForURL(instance, url); +} + +int32_t Navigate(PP_Resource request_id, + const char* target, + PP_Bool from_user_action) { + // TODO(brettw): this function should take an instance. + // To work around this, use the PP_Instance from the resource. + PP_Instance instance; + { + thunk::EnterResource<thunk::PPB_URLRequestInfo_API> enter(request_id, true); + if (enter.failed()) + return PP_ERROR_BADRESOURCE; + instance = enter.resource()->pp_instance(); + } + + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->Navigate(instance, request_id, + target, from_user_action); +} + +int32_t Navigate11(PP_Resource request_id, + const char* target, + bool from_user_action) { + // Backwards-compatible version. Navigate locks; no need to lock here. + return Navigate(request_id, target, PP_FromBool(from_user_action)); +} + +void RunMessageLoop(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->GetFlashAPI()->RunMessageLoop(instance); +} + +void QuitMessageLoop(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->GetFlashAPI()->QuitMessageLoop(instance); +} + +double GetLocalTimeZoneOffset(PP_Instance instance, PP_Time t) { + EnterInstance enter(instance); + if (enter.failed()) + return 0.0; + return enter.functions()->GetFlashAPI()->GetLocalTimeZoneOffset(instance, t); +} + +PP_Var GetCommandLineArgs(PP_Module /* pp_module */) { + // There's no instance so we have to reach into the globals without thunking. + ProxyAutoLock lock; + return StringVar::StringToPPVar(PpapiGlobals::Get()->GetCmdLine()); +} + +void PreLoadFontWin(const void* logfontw) { + // There's no instance so we have to reach into the delegate without + // thunking. + ProxyAutoLock lock; + PpapiGlobals::Get()->PreCacheFontForFlash(logfontw); +} + +PP_Bool IsRectTopmost(PP_Instance instance, const PP_Rect* rect) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_FALSE; + return enter.functions()->GetFlashAPI()->IsRectTopmost(instance, rect); +} + +int32_t InvokePrinting(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_ERROR_BADARGUMENT; + return enter.functions()->GetFlashAPI()->InvokePrinting(instance); +} + +void UpdateActivity(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return; + enter.functions()->GetFlashAPI()->UpdateActivity(instance); +} + +PP_Var GetDeviceID(PP_Instance instance) { + EnterInstance enter(instance); + if (enter.failed()) + return PP_MakeUndefined(); + return enter.functions()->GetFlashAPI()->GetDeviceID(instance); +} + +const PPB_Flash_11 g_ppb_flash_11_thunk = { + &SetInstanceAlwaysOnTop, + &DrawGlyphs11, + &GetProxyForURL, + &Navigate11, + &RunMessageLoop, + &QuitMessageLoop, + &GetLocalTimeZoneOffset, + &GetCommandLineArgs +}; + +const PPB_Flash_12_0 g_ppb_flash_12_0_thunk = { + &SetInstanceAlwaysOnTop, + &DrawGlyphs, + &GetProxyForURL, + &Navigate, + &RunMessageLoop, + &QuitMessageLoop, + &GetLocalTimeZoneOffset, + &GetCommandLineArgs, + &PreLoadFontWin +}; + +const PPB_Flash_12_1 g_ppb_flash_12_1_thunk = { + &SetInstanceAlwaysOnTop, + &DrawGlyphs, + &GetProxyForURL, + &Navigate, + &RunMessageLoop, + &QuitMessageLoop, + &GetLocalTimeZoneOffset, + &GetCommandLineArgs, + &PreLoadFontWin, + &IsRectTopmost, + &InvokePrinting, + &UpdateActivity +}; + +const PPB_Flash_12_2 g_ppb_flash_12_2_thunk = { + &SetInstanceAlwaysOnTop, + &DrawGlyphs, + &GetProxyForURL, + &Navigate, + &RunMessageLoop, + &QuitMessageLoop, + &GetLocalTimeZoneOffset, + &GetCommandLineArgs, + &PreLoadFontWin, + &IsRectTopmost, + &InvokePrinting, + &UpdateActivity, + &GetDeviceID +}; + +} // namespace + +const PPB_Flash_11* GetPPB_Flash_11_Thunk() { + return &g_ppb_flash_11_thunk; +} + +const PPB_Flash_12_0* GetPPB_Flash_12_0_Thunk() { + return &g_ppb_flash_12_0_thunk; +} + +const PPB_Flash_12_1* GetPPB_Flash_12_1_Thunk() { + return &g_ppb_flash_12_1_thunk; +} + +const PPB_Flash_12_2* GetPPB_Flash_12_2_Thunk() { + return &g_ppb_flash_12_2_thunk; +} + +} // namespace thunk +} // namespace ppapi diff --git a/ppapi/thunk/ppb_instance_api.h b/ppapi/thunk/ppb_instance_api.h index 0993702..05ebe8b 100644 --- a/ppapi/thunk/ppb_instance_api.h +++ b/ppapi/thunk/ppb_instance_api.h @@ -29,6 +29,8 @@ struct ViewData; namespace thunk { +class PPB_Flash_API; + class PPB_Instance_FunctionAPI { public: virtual ~PPB_Instance_FunctionAPI() {} @@ -77,11 +79,8 @@ class PPB_Instance_FunctionAPI { PP_Bool fullscreen) = 0; virtual PP_Bool GetScreenSize(PP_Instance instance, PP_Size* size) = 0; - // FlashFullscreen. - virtual PP_Bool FlashIsFullscreen(PP_Instance instance) = 0; - virtual PP_Bool FlashSetFullscreen(PP_Instance instance, - PP_Bool fullscreen) = 0; - virtual PP_Bool FlashGetScreenSize(PP_Instance instance, PP_Size* size) = 0; + // Flash. + virtual PPB_Flash_API* GetFlashAPI() = 0; // Gamepad. virtual void SampleGamepads(PP_Instance instance, diff --git a/ppapi/thunk/thunk.h b/ppapi/thunk/thunk.h index e98e71b..09a7e5f 100644 --- a/ppapi/thunk/thunk.h +++ b/ppapi/thunk/thunk.h @@ -38,6 +38,7 @@ #define UNPROXIED_IFACE IFACE #include "ppapi/thunk/interfaces_ppb_private.h" +#include "ppapi/thunk/interfaces_ppb_private_flash.h" #include "ppapi/thunk/interfaces_ppb_public_stable.h" #include "ppapi/thunk/interfaces_ppb_public_dev.h" |