diff options
author | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 16:51:38 +0000 |
---|---|---|
committer | sehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-03 16:51:38 +0000 |
commit | 5f6745ebf3f595e6cddaf70b76d78699e40b0a44 (patch) | |
tree | 32addee40780977d039c520fb12087dccf1ef8fc | |
parent | 194b41be7fdce80b33da38a844fb70a7b5eadb78 (diff) | |
download | chromium_src-5f6745ebf3f595e6cddaf70b76d78699e40b0a44.zip chromium_src-5f6745ebf3f595e6cddaf70b76d78699e40b0a44.tar.gz chromium_src-5f6745ebf3f595e6cddaf70b76d78699e40b0a44.tar.bz2 |
To implement Pepper in Native Client we need access to the implementation of the
Pepper APIs in Chrome. Specifically, we need to be able to get the base::SharedMemory
or TransportDIB memory regions used to communicate with devices. To enable doing this,
especially in 64-bit Chrome, I needed to change the GetStateContext and SetStateContext
functions to manipulate 64-bit values. This CL does not include the Native Client
hookup to the new APIs, but is needed to do so.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/569004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37975 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/pepper_devices.h | 4 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.cc | 34 | ||||
-rw-r--r-- | chrome/renderer/webplugin_delegate_pepper.h | 12 | ||||
-rw-r--r-- | third_party/npapi/bindings/npapi_extensions.h | 4 | ||||
-rw-r--r-- | third_party/npapi/bindings/npapi_extensions_private.h | 18 | ||||
-rw-r--r-- | webkit/glue/plugins/npapi_extension_thunk.cc | 12 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_2d_device_delegate.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_3d_device_delegate.h | 4 | ||||
-rw-r--r-- | webkit/glue/plugins/webplugin_audio_device_delegate.h | 4 |
9 files changed, 69 insertions, 27 deletions
diff --git a/chrome/renderer/pepper_devices.h b/chrome/renderer/pepper_devices.h index 50b3013..1abd554 100644 --- a/chrome/renderer/pepper_devices.h +++ b/chrome/renderer/pepper_devices.h @@ -31,6 +31,8 @@ class Graphics2DDeviceContext { NPDeviceFlushContextCallbackPtr callback, NPP id, void* user_data); + TransportDIB* transport_dib() { return transport_dib_.get(); } + private: static int32 next_buffer_id_; scoped_ptr<TransportDIB> transport_dib_; @@ -63,6 +65,8 @@ class AudioDeviceContext : public AudioMessageFilter::Delegate { virtual void OnVolume(double volume); // End of AudioMessageFilter::Delegate implementation + base::SharedMemory* shared_memory() { return shared_memory_.get(); } + private: void OnDestroy(); diff --git a/chrome/renderer/webplugin_delegate_pepper.cc b/chrome/renderer/webplugin_delegate_pepper.cc index 4c02715..048a796 100644 --- a/chrome/renderer/webplugin_delegate_pepper.cc +++ b/chrome/renderer/webplugin_delegate_pepper.cc @@ -20,6 +20,7 @@ #include "chrome/renderer/render_thread.h" #include "chrome/renderer/webplugin_delegate_proxy.h" #include "third_party/npapi/bindings/npapi_extensions.h" +#include "third_party/npapi/bindings/npapi_extensions_private.h" #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" #include "webkit/glue/plugins/plugin_constants_win.h" #include "webkit/glue/plugins/plugin_instance.h" @@ -272,14 +273,24 @@ NPError WebPluginDelegatePepper::Device2DInitializeContext( NPError WebPluginDelegatePepper::Device2DSetStateContext( NPDeviceContext2D* context, int32 state, - int32 value) { + intptr_t value) { return NPERR_GENERIC_ERROR; } NPError WebPluginDelegatePepper::Device2DGetStateContext( NPDeviceContext2D* context, int32 state, - int32* value) { + intptr_t* value) { + if (state == NPExtensionsReservedStateSharedMemory) { + if (!context) + return NPERR_INVALID_PARAM; + Graphics2DDeviceContext* ctx = graphic2d_contexts_.Lookup( + reinterpret_cast<intptr_t>(context->reserved)); + if (!ctx) + return NPERR_INVALID_PARAM; + *value = reinterpret_cast<intptr_t>(ctx->transport_dib()); + return NPERR_NO_ERROR; + } return NPERR_GENERIC_ERROR; } @@ -388,14 +399,14 @@ NPError WebPluginDelegatePepper::Device3DInitializeContext( NPError WebPluginDelegatePepper::Device3DSetStateContext( NPDeviceContext3D* context, int32 state, - int32 value) { + intptr_t value) { return NPERR_GENERIC_ERROR; } NPError WebPluginDelegatePepper::Device3DGetStateContext( NPDeviceContext3D* context, int32 state, - int32* value) { + intptr_t* value) { return NPERR_GENERIC_ERROR; } @@ -504,7 +515,7 @@ NPError WebPluginDelegatePepper::DeviceAudioInitializeContext( NPError WebPluginDelegatePepper::DeviceAudioSetStateContext( NPDeviceContextAudio* context, int32 state, - int32 value) { + intptr_t value) { // TODO(neb,cpu) implement SetStateContext return NPERR_GENERIC_ERROR; } @@ -512,8 +523,17 @@ NPError WebPluginDelegatePepper::DeviceAudioSetStateContext( NPError WebPluginDelegatePepper::DeviceAudioGetStateContext( NPDeviceContextAudio* context, int32 state, - int32* value) { - // TODO(neb,cpu) implement GetStateContext + intptr_t* value) { + if (state == NPExtensionsReservedStateSharedMemory) { + if (!context) + return NPERR_INVALID_PARAM; + AudioDeviceContext* ctx = audio_contexts_.Lookup( + reinterpret_cast<intptr_t>(context->reserved)); + if (!ctx) + return NPERR_INVALID_PARAM; + *value = reinterpret_cast<intptr_t>(ctx->shared_memory()); + return NPERR_NO_ERROR; + } return NPERR_GENERIC_ERROR; } diff --git a/chrome/renderer/webplugin_delegate_pepper.h b/chrome/renderer/webplugin_delegate_pepper.h index b316789..85db1a92 100644 --- a/chrome/renderer/webplugin_delegate_pepper.h +++ b/chrome/renderer/webplugin_delegate_pepper.h @@ -82,10 +82,10 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { NPDeviceContext2D* context); virtual NPError Device2DSetStateContext(NPDeviceContext2D* context, int32 state, - int32 value); + intptr_t value); virtual NPError Device2DGetStateContext(NPDeviceContext2D* context, int32 state, - int32* value); + intptr_t* value); virtual NPError Device2DFlushContext(NPP id, NPDeviceContext2D* context, NPDeviceFlushContextCallbackPtr callback, @@ -101,10 +101,10 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { NPDeviceContext3D* context); virtual NPError Device3DSetStateContext(NPDeviceContext3D* context, int32 state, - int32 value); + intptr_t value); virtual NPError Device3DGetStateContext(NPDeviceContext3D* context, int32 state, - int32* value); + intptr_t* value); virtual NPError Device3DFlushContext(NPP id, NPDeviceContext3D* context, NPDeviceFlushContextCallbackPtr callback, @@ -128,9 +128,9 @@ class WebPluginDelegatePepper : public webkit_glue::WebPluginDelegate { const NPDeviceContextAudioConfig* config, NPDeviceContextAudio* context); virtual NPError DeviceAudioSetStateContext(NPDeviceContextAudio* context, - int32 state, int32 value); + int32 state, intptr_t value); virtual NPError DeviceAudioGetStateContext(NPDeviceContextAudio* context, - int32 state, int32* value); + int32 state, intptr_t* value); virtual NPError DeviceAudioFlushContext( NPP id, NPDeviceContextAudio* context, NPDeviceFlushContextCallbackPtr callback, void* user_data); diff --git a/third_party/npapi/bindings/npapi_extensions.h b/third_party/npapi/bindings/npapi_extensions.h index f4530ef..1b775ba 100644 --- a/third_party/npapi/bindings/npapi_extensions.h +++ b/third_party/npapi/bindings/npapi_extensions.h @@ -54,13 +54,13 @@ typedef NPError (*NPDeviceGetStateContextPtr) ( NPP instance, NPDeviceContext* context, int32 state, - int32 *value); + intptr_t* value); /* poke device state */ typedef NPError (*NPDeviceSetStateContextPtr) ( NPP instance, NPDeviceContext* context, int32 state, - int32 value); + intptr_t value); /* flush context, if callback, userData are NULL */ /* this becomes a blocking call */ typedef NPError (*NPDeviceFlushContextPtr)( diff --git a/third_party/npapi/bindings/npapi_extensions_private.h b/third_party/npapi/bindings/npapi_extensions_private.h new file mode 100644 index 0000000..ea84024 --- /dev/null +++ b/third_party/npapi/bindings/npapi_extensions_private.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2006-2010 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 _NP_EXTENSIONS_PRIVATE_H_ +#define _NP_EXTENSIONS_PRIVATE_H_ + +#include "third_party/npapi/bindings/npapi.h" + +// Some reserved GetStateContext/SetStateContext selectors. +typedef enum { + NPExtensionsReservedStateSharedMemory = 66536 + // Used by the Device2D and Audio devices to return a pointer to the + // structure used to implement the shared memory buffer for the device. +} NPExtensionsReservedStates; + +#endif /* _NP_EXTENSIONS_PRIVATE_H_ */ diff --git a/webkit/glue/plugins/npapi_extension_thunk.cc b/webkit/glue/plugins/npapi_extension_thunk.cc index 5700ef5..61054c7 100644 --- a/webkit/glue/plugins/npapi_extension_thunk.cc +++ b/webkit/glue/plugins/npapi_extension_thunk.cc @@ -61,7 +61,7 @@ static NPError Device2DInitializeContext(NPP id, static NPError Device2DSetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32 value) { + intptr_t value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin) { return plugin->webplugin()->delegate()->Device2DSetStateContext( @@ -73,7 +73,7 @@ static NPError Device2DSetStateContext(NPP id, static NPError Device2DGetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32* value) { + intptr_t* value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin) { return plugin->webplugin()->delegate()->Device2DGetStateContext( @@ -173,7 +173,7 @@ static NPError Device3DInitializeContext(NPP id, static NPError Device3DSetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32 value) { + intptr_t value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin) { return plugin->webplugin()->delegate()->Device3DSetStateContext( @@ -185,7 +185,7 @@ static NPError Device3DSetStateContext(NPP id, static NPError Device3DGetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32* value) { + intptr_t* value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin) { return plugin->webplugin()->delegate()->Device3DGetStateContext( @@ -292,7 +292,7 @@ static NPError DeviceAudioInitializeContext(NPP id, static NPError DeviceAudioSetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32 value) { + intptr_t value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); if (plugin) { return plugin->webplugin()->delegate()->DeviceAudioSetStateContext( @@ -304,7 +304,7 @@ static NPError DeviceAudioSetStateContext(NPP id, static NPError DeviceAudioGetStateContext(NPP id, NPDeviceContext* context, int32 state, - int32* value) { + intptr_t* value) { scoped_refptr<NPAPI::PluginInstance> plugin = FindInstance(id); return plugin->webplugin()->delegate()->DeviceAudioGetStateContext( static_cast<NPDeviceContextAudio*>(context), state, value); diff --git a/webkit/glue/plugins/webplugin_2d_device_delegate.h b/webkit/glue/plugins/webplugin_2d_device_delegate.h index 55b50b7..69bd53a 100644 --- a/webkit/glue/plugins/webplugin_2d_device_delegate.h +++ b/webkit/glue/plugins/webplugin_2d_device_delegate.h @@ -29,12 +29,12 @@ class WebPlugin2DDeviceDelegate { } virtual NPError Device2DSetStateContext(NPDeviceContext2D* context, int32 state, - int32 value) { + intptr_t value) { return NPERR_GENERIC_ERROR; } virtual NPError Device2DGetStateContext(NPDeviceContext2D* context, int32 state, - int32* value) { + intptr_t* value) { return NPERR_GENERIC_ERROR; } virtual NPError Device2DFlushContext(NPP id, diff --git a/webkit/glue/plugins/webplugin_3d_device_delegate.h b/webkit/glue/plugins/webplugin_3d_device_delegate.h index 42dc300..c2c98f3 100644 --- a/webkit/glue/plugins/webplugin_3d_device_delegate.h +++ b/webkit/glue/plugins/webplugin_3d_device_delegate.h @@ -29,12 +29,12 @@ class WebPlugin3DDeviceDelegate { } virtual NPError Device3DSetStateContext(NPDeviceContext3D* context, int32 state, - int32 value) { + intptr_t value) { return NPERR_GENERIC_ERROR; } virtual NPError Device3DGetStateContext(NPDeviceContext3D* context, int32 state, - int32* value) { + intptr_t* value) { return NPERR_GENERIC_ERROR; } virtual NPError Device3DFlushContext(NPP id, diff --git a/webkit/glue/plugins/webplugin_audio_device_delegate.h b/webkit/glue/plugins/webplugin_audio_device_delegate.h index 260bcbd..3f37246 100644 --- a/webkit/glue/plugins/webplugin_audio_device_delegate.h +++ b/webkit/glue/plugins/webplugin_audio_device_delegate.h @@ -29,11 +29,11 @@ class WebPluginAudioDeviceDelegate { return NPERR_GENERIC_ERROR; } virtual NPError DeviceAudioSetStateContext(NPDeviceContextAudio* context, - int32 state, int32 value) { + int32 state, intptr_t value) { return NPERR_GENERIC_ERROR; } virtual NPError DeviceAudioGetStateContext(NPDeviceContextAudio* context, - int32 state, int32* value) { + int32 state, intptr_t* value) { return NPERR_GENERIC_ERROR; } virtual NPError DeviceAudioFlushContext( |