summaryrefslogtreecommitdiffstats
path: root/gpu/gpu_plugin/gpu_plugin.cc
diff options
context:
space:
mode:
authorapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 19:34:24 +0000
committerapatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-24 19:34:24 +0000
commit97632e2039e3ec0b9342f5e7c074bf631c738a9f (patch)
tree71e51bad650961671a0aa96b433403fc5a8ff544 /gpu/gpu_plugin/gpu_plugin.cc
parentd4edbe5e406c5773d66d65214b963ed474b34cf4 (diff)
downloadchromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.zip
chromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.tar.gz
chromium_src-97632e2039e3ec0b9342f5e7c074bf631c738a9f.tar.bz2
Branched gpu process and command buffer code into Chrome tree. Fixed up paths and other minor changes to make it work in the Chrome tree. Will remove copy from O3D tree shortly. Only works in Windows currently.
TEST=none BUG=none Review URL: http://codereview.chromium.org/436017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32952 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/gpu_plugin/gpu_plugin.cc')
-rw-r--r--gpu/gpu_plugin/gpu_plugin.cc135
1 files changed, 135 insertions, 0 deletions
diff --git a/gpu/gpu_plugin/gpu_plugin.cc b/gpu/gpu_plugin/gpu_plugin.cc
new file mode 100644
index 0000000..35771fd
--- /dev/null
+++ b/gpu/gpu_plugin/gpu_plugin.cc
@@ -0,0 +1,135 @@
+// Copyright (c) 2006-2008 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 "gpu/gpu_plugin/gpu_plugin.h"
+#include "gpu/gpu_plugin/gpu_plugin_object_factory.h"
+#include "gpu/np_utils/np_browser.h"
+#include "gpu/np_utils/np_plugin_object.h"
+#include "gpu/np_utils/np_plugin_object_factory.h"
+#include "webkit/glue/plugins/nphostapi.h"
+
+using np_utils::NPBrowser;
+using np_utils::NPPluginObjectFactory;
+using np_utils::PluginObject;
+
+namespace gpu_plugin {
+
+// Definitions of NPAPI plugin entry points.
+
+namespace {
+NPBrowser* g_browser;
+GPUPluginObjectFactory g_plugin_object_factory;
+
+NPError NPP_New(NPMIMEType plugin_type, NPP instance,
+ uint16 mode, int16 argc, char* argn[],
+ char* argv[], NPSavedData* saved) {
+ if (!instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginObject* plugin_object =
+ NPPluginObjectFactory::get()->CreatePluginObject(instance, plugin_type);
+ if (!plugin_object)
+ return NPERR_GENERIC_ERROR;
+
+ instance->pdata = plugin_object;
+
+ NPError error = plugin_object->New(plugin_type, argc, argn, argv, saved);
+ if (error != NPERR_NO_ERROR) {
+ plugin_object->Release();
+ }
+
+ return error;
+}
+
+NPError NPP_Destroy(NPP instance, NPSavedData** saved) {
+ if (!instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata);
+ NPError error = plugin_object->Destroy(saved);
+
+ if (error == NPERR_NO_ERROR) {
+ plugin_object->Release();
+ }
+
+ return error;
+}
+
+NPError NPP_SetWindow(NPP instance, NPWindow* window) {
+ if (!instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata);
+ return plugin_object->SetWindow(window);
+}
+
+int16 NPP_HandleEvent(NPP instance, void* event) {
+ if (!instance)
+ return 0;
+
+ PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata);
+ return plugin_object->HandleEvent(static_cast<NPEvent*>(event));
+}
+
+NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value) {
+ if (!instance)
+ return NPERR_INVALID_INSTANCE_ERROR;
+
+ PluginObject* plugin_object = static_cast<PluginObject*>(instance->pdata);
+ switch (variable) {
+ case NPPVpluginScriptableNPObject:
+ *reinterpret_cast<NPObject**>(value) =
+ plugin_object->GetScriptableNPObject();
+ return NPERR_NO_ERROR;
+ default:
+ return NPERR_GENERIC_ERROR;
+ }
+}
+
+NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value) {
+ return NPERR_NO_ERROR;
+}
+}
+
+NPError NP_GetEntryPoints(NPPluginFuncs* funcs) {
+ funcs->newp = NPP_New;
+ funcs->destroy = NPP_Destroy;
+ funcs->setwindow = NPP_SetWindow;
+ funcs->event = NPP_HandleEvent;
+ funcs->getvalue = NPP_GetValue;
+ funcs->setvalue = NPP_SetValue;
+ return NPERR_NO_ERROR;
+}
+
+#if defined(OS_LINUX)
+NPError API_CALL NP_Initialize(NPNetscapeFuncs *browser_funcs,
+ NPPluginFuncs* plugin_funcs) {
+#else
+NPError NP_Initialize(NPNetscapeFuncs *browser_funcs) {
+#endif
+ if (!browser_funcs)
+ return NPERR_INVALID_FUNCTABLE_ERROR;
+
+ if (g_browser)
+ return NPERR_GENERIC_ERROR;
+
+#if defined(OS_LINUX)
+ NP_GetEntryPoints(plugin_funcs);
+#endif
+
+ g_browser = new NPBrowser(browser_funcs);
+
+ return NPERR_NO_ERROR;
+}
+
+NPError NP_Shutdown() {
+ if (!g_browser)
+ return NPERR_GENERIC_ERROR;
+
+ delete g_browser;
+ g_browser = NULL;
+
+ return NPERR_NO_ERROR;
+}
+} // namespace gpu_plugin