diff options
author | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 22:40:37 +0000 |
---|---|---|
committer | apatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-16 22:40:37 +0000 |
commit | 9821d0de8b140ce1cd1917260afad5f803b43ed1 (patch) | |
tree | 748eb7558cd58a8591c1ba92b30a4ddf9605580d /webkit | |
parent | 8549f5e3dd6e920fd7c72a44ba3d89b15cc03e41 (diff) | |
download | chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.zip chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.tar.gz chromium_src-9821d0de8b140ce1cd1917260afad5f803b43ed1.tar.bz2 |
New experimental Pepper device API.
- makes device contexts opaque to the plugin
- can get / set multiple attributes and flush with a single call (and underlying IPC message exchange)
- currently works in parallel with old API
- adapted pepper test plugin to use new API if use_new_npdevice_api=1
TEST=trybots, visual confirmation that pepper test plugin works with new API
BUG=none
Review URL: http://codereview.chromium.org/1529005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.cc | 115 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_3d_device_delegate.h | 30 | ||||
-rw-r--r-- | webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.cc | 35 | ||||
-rw-r--r-- | webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.h | 4 |
4 files changed, 172 insertions, 12 deletions
diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index 141d960..100beef 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -277,6 +277,82 @@ static NPError Device3DMapBuffer(NPP id, return NPERR_GENERIC_ERROR; } +// Experimental 3D device API -------------------------------------------------- + +static NPError Device3DGetNumConfigs(NPP id, int32* num_configs) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DGetNumConfigs(num_configs); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DGetConfigAttribs(NPP id, + int32 config, + int32* attrib_list) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DGetConfigAttribs( + config, + attrib_list); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DCreateContext(NPP id, + int32 config, + const int32* attrib_list, + NPDeviceContext** context) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DCreateContext( + config, + attrib_list, + reinterpret_cast<NPDeviceContext3D**>(context)); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DSynchronizeContext( + NPP id, + NPDeviceContext* context, + NPDeviceSynchronizationMode mode, + const int32* input_attrib_list, + int32* output_attrib_list, + NPDeviceSynchronizeContextCallbackPtr callback, + void* callback_data) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DSynchronizeContext( + id, + static_cast<NPDeviceContext3D*>(context), + mode, + input_attrib_list, + output_attrib_list, + callback, + callback_data); + } + return NPERR_GENERIC_ERROR; +} + +static NPError Device3DRegisterCallback( + NPP id, + NPDeviceContext* context, + int32 callback_type, + NPDeviceGenericCallbackPtr callback, + void* callback_data) { + scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); + if (plugin) { + return plugin->webplugin()->delegate()->Device3DRegisterCallback( + id, + static_cast<NPDeviceContext3D*>(context), + callback_type, + callback, + callback_data); + } + return NPERR_GENERIC_ERROR; +} + // Audio device API ------------------------------------------------------------ static NPError DeviceAudioQueryCapability(NPP id, int32 capability, @@ -367,6 +443,11 @@ static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { Device2DMapBuffer, Device2DThemeGetSize, Device2DThemePaint, + NULL, + NULL, + NULL, + NULL, + NULL, }; static NPDevice device_3d = { Device3DQueryCapability, @@ -381,20 +462,30 @@ static NPDevice* AcquireDevice(NPP id, NPDeviceID device_id) { Device3DMapBuffer, NULL, NULL, + Device3DGetNumConfigs, + Device3DGetConfigAttribs, + Device3DCreateContext, + Device3DRegisterCallback, + Device3DSynchronizeContext, }; static NPDevice device_audio = { - DeviceAudioQueryCapability, - DeviceAudioQueryConfig, - DeviceAudioInitializeContext, - DeviceAudioSetStateContext, - DeviceAudioGetStateContext, - DeviceAudioFlushContext, - DeviceAudioDestroyContext, - NULL, - NULL, - NULL, - NULL, - NULL, + DeviceAudioQueryCapability, + DeviceAudioQueryConfig, + DeviceAudioInitializeContext, + DeviceAudioSetStateContext, + DeviceAudioGetStateContext, + DeviceAudioFlushContext, + DeviceAudioDestroyContext, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, }; switch (device_id) { diff --git a/webkit/glue/plugins/webplugin_3d_device_delegate.h b/webkit/glue/plugins/webplugin_3d_device_delegate.h index c2c98f3..fbb46eb 100644 --- a/webkit/glue/plugins/webplugin_3d_device_delegate.h +++ b/webkit/glue/plugins/webplugin_3d_device_delegate.h @@ -60,6 +60,36 @@ class WebPlugin3DDeviceDelegate { NPDeviceBuffer* buffer) { return NPERR_GENERIC_ERROR; } + virtual NPError Device3DGetNumConfigs(int32* num_configs) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DGetConfigAttribs(int32 config, + int32* attrib_list) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DCreateContext(int32 config, + const int32* attrib_list, + NPDeviceContext3D** context) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DRegisterCallback( + NPP id, + NPDeviceContext* context, + int32 callback_type, + NPDeviceGenericCallbackPtr callback, + void* callback_data) { + return NPERR_GENERIC_ERROR; + } + virtual NPError Device3DSynchronizeContext( + NPP id, + NPDeviceContext3D* context, + NPDeviceSynchronizationMode mode, + const int32* input_attrib_list, + int32* output_attrib_list, + NPDeviceSynchronizeContextCallbackPtr callback, + void* callback_data) { + return NPERR_GENERIC_ERROR; + } protected: WebPlugin3DDeviceDelegate() {} diff --git a/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.cc b/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.cc index d5df069..a440dc6 100644 --- a/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.cc +++ b/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.cc @@ -14,8 +14,13 @@ Pepper3DTest::Pepper3DTest(NPP id, NPNetscapeFuncs *host_functions) : PluginTest(id, host_functions), pepper_extensions_(NULL), device_3d_(NULL), +#if defined(ENABLE_NEW_NPDEVICE_API) + context_3d_(NULL), +#endif pgl_context_(PGL_NO_CONTEXT) { +#if !defined(ENABLE_NEW_NPDEVICE_API) memset(&context_3d_, 0, sizeof(context_3d_)); +#endif esInitContext(&es_context_); memset(&es_data_, 0, sizeof(es_data_)); @@ -70,6 +75,25 @@ void Pepper3DTest::CreateContext() { } // Initialize a 3D context. +#if defined(ENABLE_NEW_NPDEVICE_API) + int32 attrib_list[] = { + NP3DAttrib_CommandBufferSize, kCommandBufferSize, + NPAttrib_End + }; + if (device_3d_->createContext(id(), 0, attrib_list, + reinterpret_cast<NPDeviceContext**>(&context_3d_)) != NPERR_NO_ERROR) { + SetError("Could not initialize 3D context"); + SignalTestCompleted(); + return; + } + + device_3d_->registerCallback( + id(), + context_3d_, + NP3DCallback_Repaint, + reinterpret_cast<NPDeviceGenericCallbackPtr>(RepaintCallback), + NULL); +#else NPDeviceContext3DConfig config; config.commandBufferSize = kCommandBufferSize; if (device_3d_->initializeContext(id(), &config, &context_3d_) @@ -79,6 +103,7 @@ void Pepper3DTest::CreateContext() { return; } context_3d_.repaintCallback = RepaintCallback; +#endif // ENABLE_NEW_NPDEVICE_API // Initialize PGL and create a PGL context. if (!pglInitialize()) { @@ -86,7 +111,11 @@ void Pepper3DTest::CreateContext() { SignalTestCompleted(); return; } +#if defined(ENABLE_NEW_NPDEVICE_API) + pgl_context_ = pglCreateContext(id(), device_3d_, context_3d_); +#else pgl_context_ = pglCreateContext(id(), device_3d_, &context_3d_); +#endif if (pgl_context_ == PGL_NO_CONTEXT) { SetError("Could not initialize PGL context"); SignalTestCompleted(); @@ -110,9 +139,15 @@ void Pepper3DTest::DestroyContext() { } pgl_context_ = PGL_NO_CONTEXT; +#if defined(ENABLE_NEW_NPDEVICE_API) + if (device_3d_->destroyContext(id(), context_3d_) != NPERR_NO_ERROR) { + SetError("Could not destroy 3D context"); + } +#else if (device_3d_->destroyContext(id(), &context_3d_) != NPERR_NO_ERROR) { SetError("Could not destroy 3D context"); } +#endif } void Pepper3DTest::MakeContextCurrent() { diff --git a/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.h b/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.h index 20b10ed..7b3e2db 100644 --- a/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.h +++ b/webkit/tools/npapi_pepper_test_plugin/pepper_3d_test.h @@ -44,7 +44,11 @@ class Pepper3DTest : public PluginTest { NPExtensions* pepper_extensions_; NPDevice* device_3d_; +#if defined(ENABLE_NEW_NPDEVICE_API) + NPDeviceContext3D* context_3d_; +#else NPDeviceContext3D context_3d_; +#endif PGLContext pgl_context_; ESContext es_context_; |