summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 01:10:24 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-11 01:10:24 +0000
commitfcad492f2e69ba9b91b5eb2108ee381dbe5047d5 (patch)
tree25cd50fc6ea104e7f8db0da0d199dc1a9a395b62 /gpu
parentf753af6865f1724c3e5adde6917bb2b1f24713ce (diff)
downloadchromium_src-fcad492f2e69ba9b91b5eb2108ee381dbe5047d5.zip
chromium_src-fcad492f2e69ba9b91b5eb2108ee381dbe5047d5.tar.gz
chromium_src-fcad492f2e69ba9b91b5eb2108ee381dbe5047d5.tar.bz2
Implemented linux-specific NPAPI interface for pepper demos.
BUG=26099 Review URL: http://codereview.chromium.org/599020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@38727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/demos/framework/main_pepper.cc53
1 files changed, 46 insertions, 7 deletions
diff --git a/gpu/demos/framework/main_pepper.cc b/gpu/demos/framework/main_pepper.cc
index 4d4ae4e..6937b62 100644
--- a/gpu/demos/framework/main_pepper.cc
+++ b/gpu/demos/framework/main_pepper.cc
@@ -8,11 +8,20 @@
#include "gpu/pgl/pgl.h"
#include "webkit/glue/plugins/nphostapi.h"
+#if __GNUC__ >= 4
+#define EXPORT __attribute__ ((visibility("default")))
+#else
+// We use .def file to export symbols on OS_WIN. We could potentially use
+// __declspec(dllexport) but API_CALL always adds something to the function
+// signature even inside extern "C" {}
+#define EXPORT
+#endif // GNUC
+
namespace {
// AtExitManager is used by singleton classes to delete themselves when
// the program terminates. There should be only one instance of this class
// per thread;
-base::AtExitManager* g_at_exit_manager_;
+base::AtExitManager* g_at_exit_manager;
} // namespace
namespace gpu {
@@ -92,8 +101,19 @@ NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
NPError err = NPERR_NO_ERROR;
switch (variable) {
+#if defined(OS_LINUX)
+ case NPPVpluginNameString:
+ *(static_cast<const char**>(value)) = "Pepper GPU Demo";
+ break;
+ case NPPVpluginDescriptionString:
+ *(static_cast<const char**>(value)) = "Pepper plug-in for GPU demo.";
+ break;
+ case NPPVpluginNeedsXEmbed:
+ *(static_cast<NPBool*>(value)) = TRUE;
+ break;
+#endif
case NPPVpluginScriptableNPObject: {
- void** v = reinterpret_cast<void**>(value);
+ void** v = static_cast<void**>(value);
Plugin* plugin = static_cast<Plugin*>(instance->pdata);
// Return value is expected to be retained
g_browser->retainobject(plugin);
@@ -117,7 +137,7 @@ NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
// NP entry points
extern "C" {
-NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
+EXPORT NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
plugin_funcs->version = NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL;
plugin_funcs->size = sizeof(plugin_funcs);
plugin_funcs->newp = gpu::demos::NPP_New;
@@ -137,15 +157,34 @@ NPError API_CALL NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
return NPERR_NO_ERROR;
}
-NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs) {
- g_at_exit_manager_ = new base::AtExitManager();
+EXPORT NPError API_CALL NP_Initialize(NPNetscapeFuncs* browser_funcs
+#if defined(OS_LINUX)
+ , NPPluginFuncs* plugin_funcs
+#endif // OS_LINUX
+ ) {
+ g_at_exit_manager = new base::AtExitManager();
gpu::demos::g_browser = browser_funcs;
pglInitialize();
+
+#if defined(OS_LINUX)
+ NP_GetEntryPoints(plugin_funcs);
+#endif // OS_LINUX
return NPERR_NO_ERROR;
}
-void API_CALL NP_Shutdown() {
+EXPORT void API_CALL NP_Shutdown() {
pglTerminate();
- delete g_at_exit_manager_;
+ delete g_at_exit_manager;
+}
+
+#if defined(OS_LINUX)
+EXPORT NPError API_CALL NP_GetValue(NPP instance, NPPVariable variable,
+ void* value) {
+ return gpu::demos::NPP_GetValue(instance, variable, value);
+}
+
+EXPORT const char* API_CALL NP_GetMIMEDescription() {
+ return "pepper-application/x-gpu-demo::Pepper GPU Demo";
}
+#endif // OS_LINUX
} // extern "C"